Little Help - C#
Ian Erickson
ierickson at ANALYGIS.COM
Wed Dec 14 19:13:39 PST 2005
Alright,
I've compiled a working version of the mapscript_csharp assembly and
everything seems to be working fine. I can load, enumerate the layers,
and save a copy of the image to the file system. However, I need to add
a point to a dynamically created layer (all of this mind you in C#).
Here's what I've got:
mapObj m_obj = new mapObj(@"C:\base.map");
layerObj layer = new layerObj(m_obj);
layer.name = "PointLayer";
layer.type = MS_LAYER_TYPE.MS_LAYER_POINT;
layer.setProjection("init=epsg:4326");
layer.status = 1;
classObj c = new classObj(layer);
c.label.type = MS_FONT_TYPE.MS_TRUETYPE;
c.label.font = "arial";
c.label.size = 7;
c.label.color.setRGB(0, 0, 0);
c.label.outlinecolor.setRGB(255, 255, 255);
styleObj style = new styleObj(c);
style.symbolname = "circle";
style.size = 14;
style.color.setRGB(0, 255, 0);
style.outlinecolor.setRGB(0, 0, 0);
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();
pointObj p = new pointObj(-111.4752, 33.377321, 0.0, 0.0);
lineObj l = new lineObj();
l.add(p);
shapeObj s = new shapeObj(0);
s.add(l);
s.text = "TEXT";
layer.addFeature(s);
p.draw(m_obj, layer, i_obj, 0, "TEXT");
s.Dispose();
l.Dispose();
p.Dispose();
Console.ReadLine();
As I mentioned, the assembly is creating the appropriate file, and
everything seems to be working - with the exception of creating a point
symbol on the new layer. No exceptions are thrown so I must be missing
something crucial. If anyone can provide some hints, I'd be grateful!
--
Ian Erickson
AnalyGIS, LLC
http:// www.analygis.com
More information about the MapServer-users
mailing list