[OpenLayers-Dev] Saving drawn polygons

Alex G. unseen.wizard at gmail.com
Wed Feb 3 07:11:28 EST 2010


Thanks for the idea.

I am currently using something like this:

vectors.onFeatureInsert=
function(feature) {

    var wktwriter=new OpenLayers.Format.WKT();
    var wkt=wktwriter.write(feature);
}

vectors being the vector layer obviously.

Not sure if the above is correct but at least the output is something I can
use to store and retrieve from the DB.
I am probably going to save the output temporarily in the variable and save
it in the DB when the user is done editing the map.

Now on to deleting/removing a feature...

Thanks again.


On Wed, Feb 3, 2010 at 12:15 PM, John Powell <john.powell at emapsite.com>wrote:

> In response to the question about saving polygons, it is also worth
> looking at Format.WKT as this produces polygons in OGC compliant format
> which can then be inserted into a spatially enabled database such as
> Postgres or MySQL.
>
> Somthing like
>
>
> layer.events.register('featureadded', this, function(obj){
>    var wktwriter=new OpenLayers.Format.WKT();
>    var wkt=wktwriter.write(obj.feature);
> }
>
> wkt will now look something like POLYGON(( x1 y1, x2 y2, .....x1, y1))
>
> and you can insert this into a geometry column of a db using the
> geomfromtext function.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20100203/312017d5/attachment.html


More information about the Dev mailing list