source: trunk/mapserver/mapscript/csharp/examples/drawmap.cs

Last change on this file was 7418, checked in by nsavard, 16 years ago

Standardized header.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/******************************************************************************
2 * $Id: drawmap.cs 7418 2008-02-29 00:02:49Z nsavard $
3 *
4 * Project: MapServer
5 * Purpose: A C# based mapscript example to create an image given a mapfile.
6 * Author: Tamas Szekeres, szekerest@gmail.com
7 * Yew K Choo, ykchoo@geozervice.com
8 *
9 ******************************************************************************
10 * Copyright (c) 1996-2008 Regents of the University of Minnesota.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in
20 * all copies of this Software or works derived from this Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 *****************************************************************************/
30
31using System;
32using OSGeo.MapServer;
33
34/// <summary>
35/// A C# based mapscript mapscript example to create an image given a mapfile.
36/// </summary>
37class DrawMap
38{
39 public static void usage()
40 {
41 Console.WriteLine("usage: DrawMap {mapfile} {outfile} {imagetype optional}");
42 System.Environment.Exit(-1);
43 }
44
45 public static void Main(string[] args)
46 {
47 Console.WriteLine("");
48 if (args.Length < 2) usage();
49
50 mapObj m_obj = new mapObj(args[0]);
51
52 if (args.Length >= 3)
53 {
54 Console.WriteLine("Setting the imagetype to " + args[2]);
55 m_obj.setImageType(args[2]);
56 }
57
58 Console.WriteLine ("# Map layers " + m_obj.numlayers + "; Map name = " + m_obj.name);
59 for (int i=0; i<m_obj.numlayers; i++)
60 {
61 Console.WriteLine("Layer [" + i + "] name: " + m_obj.getLayer(i).name);
62 }
63
64 imageObj i_obj = m_obj.draw();
65 Console.WriteLine("Image URL = " + i_obj.imageurl + "; Image path = " + i_obj.imagepath);
66 Console.WriteLine("Image height = " + i_obj.height + "; width = " + i_obj.width);
67 try
68 {
69 i_obj.save(args[1],m_obj);
70 }
71 catch (Exception ex)
72 {
73 Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
74 Console.WriteLine(
75 "\nHelpLink ---\n{0}", ex.HelpLink );
76 Console.WriteLine( "\nSource ---\n{0}", ex.Source );
77 Console.WriteLine(
78 "\nStackTrace ---\n{0}", ex.StackTrace );
79 Console.WriteLine(
80 "\nTargetSite ---\n{0}", ex.TargetSite ); }
81 }
82}
83
Note: See TracBrowser for help on using the repository browser.