File: drawmap.cs

package info (click to toggle)
mapserver 5.0.3-3%2Blenny7
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,556 kB
  • ctags: 12,645
  • sloc: ansic: 168,024; cs: 8,534; python: 4,618; sh: 4,213; cpp: 4,059; perl: 2,781; makefile: 787; lex: 564; java: 415; yacc: 334; tcl: 158; ruby: 53
file content (59 lines) | stat: -rwxr-xr-x 1,708 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using OSGeo.MapServer;
	
/**
 * <p>Title: Mapscript shape dump example.</p>
 * <p>Description: A C# based mapscript example to create an image given a mapfile.</p>
 * @author Yew K Choo 	ykchoo@geozervice.com
 * @version 1.0  
*/

/// <summary>
/// A C# based mapscript mapscript example to create an image given a mapfile.
/// </summary>
class DrawMap
{
  public static void usage() 
  { 
	Console.WriteLine("usage: DrawMap {mapfile} {outfile} {imagetype optional}");
	System.Environment.Exit(-1);
  }
		  
  public static void Main(string[] args)
  {
    if (args.Length < 2) usage();
    
	mapObj m_obj = new mapObj(args[0]);

	if (args.Length >= 3) 
	{
      Console.WriteLine("Setting the imagetype to " + args[2]);
	  m_obj.setImageType(args[2]);
	}

	Console.WriteLine ("# Map layers " + m_obj.numlayers + "; Map name = " + m_obj.name);	
	for (int i=0; i<m_obj.numlayers; i++) 
	{
	  Console.WriteLine("Layer [" + i + "] name: " + m_obj.getLayer(i).name);
	}
	
    imageObj i_obj = m_obj.draw();
	Console.WriteLine("Image URL = " + i_obj.imageurl + "; Image path = " + i_obj.imagepath);    
	Console.WriteLine("Image height = " + i_obj.height + "; width = " + i_obj.width); 
	try 
	{
	  i_obj.save(args[1],m_obj);
    } 
	catch (Exception ex) 
	{
                Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                Console.WriteLine( 
                    "\nHelpLink ---\n{0}", ex.HelpLink );
                Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                Console.WriteLine( 
                    "\nStackTrace ---\n{0}", ex.StackTrace );
                Console.WriteLine( 
                    "\nTargetSite ---\n{0}", ex.TargetSite );	}	
  }
}