[mapserver-users] How to add attributes to feature/shape with mapscript java?

rai 8 max1000 at gmail.com
Mon Dec 6 09:41:27 PST 2010


Hi!,

I trying to add features to a layer with mapscript in a WFS server, there
isn't any method to set attributes directly to a feature or a shape.

I found initValues and setValue to set value to a shape object but in a
xml/gml response it doesn't appear. Anyone knows a way to do this?

 // add feature
    shapeObj shape = new shapeObj( mapscriptConstants.MS_SHP_POINTM );
    shape.initValues(8);
    lineObj line = new lineObj();
    pointObj point = new pointObj(2.160690, 41.479881, 1);
    line.add(point);
    shape.add( line);
    shape.setValue(0, "attr1");
    shape.setValue(1, "attr2");
    System.out.println( shape.getValue(0) + " " + shape.getValue(1) + " " +
shape.getValue(2) );
 layer.addFeature(shape );
 shape = new shapeObj( mapscriptConstants.MS_SHP_POINTM );
    line = new lineObj();
    point = new pointObj(2.170000, 41.480000, 1);
    line.add(point);
    shape.add( line);
layer.addFeature(shape );

Another workaround I found is generated a dbf file with all features and
attributes that I want and then load a mapfile pointing to this dbf file,
but this is inefficient.


thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20101206/9f8f419b/attachment.htm>


More information about the MapServer-users mailing list