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

Benjamin Wragg bwragg at tpg.com.au
Wed Jan 15 14:00:13 PST 2003


Thanks for your comments Daniel. I just have a few more questions from
what you wrote.

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

So when a feature is added this way, can it be labeled as well as used
to select features in another layer (PostGIS layer)?


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

What else do you recommend? 

As has been pointed out, the editing functions of MapServer don't
support PostGIS layers, but are there any other methods that don't
support PostGIS layers. ie Any of the queryByxxxxxx functions?

Thanks,

Benjamin Wragg

-----Original Message-----
From: Daniel Morissette [mailto:morissette at dmsolutions.ca] 
Sent: Wednesday, 15 January 2003 3:36 PM
To: Paul Ramsey
Cc: bwragg at tpg.com.au; mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] Adding Features to PostGIS Layer -
Confused

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