[Mapserver-users] Adding Features to PostGIS Layer - Confused

Benjamin Wragg bwragg at tpg.com.au
Tue Jan 14 17:49:31 EST 2003


Hi all,

Currently were running PHP-MapScript and PostGIS and I’m trying to build
into my site the ability to add a feature to a map by specifying one or
more XY coordinates. The feature that’s created, whether it be a point,
line or polygon, must be able to be drawn on the map with a label, used
to select features from another layer and the layer must be displayed in
the legend. My initial thoughts for doing this were something along the
lines of:

1. Create a feature according to the needed type. E.g PointObj for a
point.
2. Pass the feature object to the LayerObj->addFeature() method.
2. Turn the LayerObj on.
3. Draw the map.

But after looking at the documentation I couldn't get this concept to
fit because it says that only a ShapeObj can be passed to the
LayerObj->addFeature method. The only way to create a ShapeObj is to use
the ShapeObj->add() method. This method though only accepts LineObj's.
So as a result of my understanding of the documentation, no matter what
type of feature I want to create, I must create a LineObj first, pass
this to the ShapeObj and then pass the ShapObj to the
LayerObj->addFeature(). So now I’ve came up with the following way of
tackling the problem, but I’m not sure if I’m using the correct
functions and objects or if I have the correct understanding at all:

1. Create a LineObj for every XY coordinate that’s received, even if
it’s a point or polygon that needed.
2. Use the LineObj->setXY() method to set the coordinates for the line.
3. Create a ShapeObj, specifying the Type as point, line or polygon.
4. Use the ShapeObj->add() method to add each LineObj to the ShapeObj.
5. Pass the ShapeObj to the LayerObj->addFeature() method. (Remember the
layer is in PostGIS)
6. Turn the LayerObj on.
7. Draw the map. (Since it’s a PostGIS layer the new feature should be
displayed instantly)
8. Draw the legend

Am I way off the track??? Help???

Benjamin





More information about the mapserver-users mailing list