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

Daniel Morissette morissette at dmsolutions.ca
Wed Jan 15 00:06:05 EST 2003


Paul Ramsey wrote:
> 
> 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 :)
> 

Unless I'm mistaken, the $layer->addFeature() method doesn't even apply
to shapefiles.  It is only there to create inline features in a layer
(in memory).

To write to a shapefile you have to use the shapefileObj class.


> 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.
> 

I think this should remain the preferred way to add features to a RDBMS
layer anyway.  Doing it via MapServer is just going to add overhead and
restrict your ability to take full advantage of the features of the
layer format (PostGIS in this case).

> DEVELOPERS: should the layer concepts be extended to allow all layer
> types to be read/writable via the same scripting mechanisms?
> 

As mentioned above the layerObj are read-only and making them support
write access may not be the best thing to do.

Instead we could consider creating a clone of the shapefileObj that
would use OGR at the lower level (or extending shapefileObj to support
OGR formats).  Since OGR already supports most formats that MapServer
does (including PostGIS), that would keep things much simpler: only one
interface to maintain instead of having to extend all format drivers in
MapServer and making them more complicated than they need to be.

And once again, for databases like PostGIS I think doing direct SQL
calls to add or update feature should be the preferred approach.

(Note that this is just my opinion.  Other developers may have a
different opinion.)

Daniel
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------




More information about the mapserver-users mailing list