Ian,

Down in the heart of the MapServer code, style.symbol is all that counts. The symbolname attribute is (only) for convenience. The closest thing we have in mapscript now is

    symbol_index = map.symbolset.index("some_name")
    style.symbol = symbol_index

cheers,
Sean

On Dec 15, 2005, at 9:03 AM, Ian Erickson wrote:

Alright,

Got it working - Thanks! The following code is what I ended up using -
in case anyone else needs it.  Also, I noticed that the styleObj does
not seem to work properly when using the symbolname property.  I was
forced to user the symbol index instead. Any reason why this might be?
Code follows:

        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.name = "MARKER";
        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.symbol = 7;
//        style.symbolname = "circle";
        style.antialias = 1;
        style.minsize = 12;
        style.maxsize = 12;
        style.size = 12;
        style.color.setRGB(192, 0, 0);
        style.outlinecolor.setRGB(255, 0, 0);

        imageObj i_obj = m_obj.draw();

        pointObj p = new pointObj(-111.4752, 33.377321, 0.0, 0.0);
        Console.WriteLine("p.x = " + p.x);
        Console.WriteLine("p.y = " + p.y);

        p.draw(m_obj, layer, i_obj, 0, "TEXT");

        p.Dispose();

        try
        {
            i_obj.save(@"C:\output.png",m_obj);
        }  catch (Exception e)
        {
            Console.Writeln(e.printStackTrace());
         }



Sean Gillies wrote:

On Dec 14, 2005, at 8:13 PM, Ian Erickson wrote:

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");


Ian,

The last two lines here are redundant. There are 3 different ways to
render a point.

1) pointObj#draw
2) shapeObj#draw
3) layer#addFeature and then layer#draw

You're doing a little bit of each. I recommend that you go with #1
and delete the lines in between the creation of the new point, and
p.draw().


        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!


How do you know that points are not drawn? Are you saving the
imageObj? I can't tell from the code.

---
Sean Gillies
sgillies at frii dot com
http://zcologia.com/news


--
Ian Erickson
AnalyGIS, LLC
Gold Canyon, AZ  85218
http:// www.analygis.com

tel: 480.677.6260
mob: 480.221.7173
fax: 480.677.6261

See AnalyGIS at work:
http://65.39.85.13/google/
http://65.39.85.13/virtualearth/

---
Sean Gillies
sgillies at frii dot com
http://zcologia.com/news

Reply via email to