[Mapserver-users] Adding Features to PostGIS Layer - Confused
Paul Ramsey
pramsey at refractions.net
Tue Jan 14 15:00:22 PST 2003
Yes, quite a ways off track... the writable aspects of
Mapserver/Mapscript layers all adhere to Shape file data sources only.
This is a legacy issue from back when that was the only data source, and
therefor the only one worthy of enhancement :)
HOWEVER: you can add features to a PostGIS data source via the back
door. Use a direct pgsql connection within PHP to connect to the PostGIS
database, and run a SQL 'insert' command on the table to add your new
feature.
DEVELOPERS: should the layer concepts be extended to allow all layer
types to be read/writable via the same scripting mechanisms?
Benjamin Wragg wrote:
> Hi all,
>
> Currently were running PHP-MapScript and PostGIS and Im trying to build
> into my site the ability to add a feature to a map by specifying one or
> more XY coordinates. The feature thats 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 Ive came up with the following way of
> tackling the problem, but Im not sure if Im using the correct
> functions and objects or if I have the correct understanding at all:
>
> 1. Create a LineObj for every XY coordinate thats received, even if
> its 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 its a PostGIS layer the new feature should be
> displayed instantly)
> 8. Draw the legend
>
> Am I way off the track??? Help???
>
> Benjamin
>
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
More information about the MapServer-users
mailing list