[OpenLayers-Dev] Split polygon
Nathan Gerber
ngerber999 at gmail.com
Fri Feb 13 13:16:26 EST 2009
Aurelien,
What you want to do is fairly simple to accomplish if you have a
postgres/postGIS database. One method would be to have a select box with
each polygon so that you had a reference on which polygon you are splitting
based on the select box, then do a draw tool with an event to submit a
request to a server with the WKT of the polygon you wish to split and the
line to split it with. The sevrerside script would run the following exampel
query:
SELECT astext(geom) FROM dump ((
SELECT polygonize(geomunion(boundary(poly), line)) AS mpoly FROM
(SELECT '$segment'::geometry AS poly) AS a,
(SELECT '$splitWKT'::geometry AS line) AS b
))
Several polugons should be returned by the query. With the new polygons
generated you can nuke the old polygon and then add the new polygons into
the vector layer while being sure to refresh your select box (or however you
choose manage it).
// Destroy the old vector
for (var i=0;i<vectors.features.length;i++) {
if (vectors.features[i].id == oldPolyID) {
vectors.features[i].destroy();
}
}
//Add new
var features = wkt.read(wktPolygon);
vectors.addFeatures(features);
PS Ivan, sorry that previous email went to you and you alone, forgot to do a
reply all.
--
Nathan Gerber
On Fri, Feb 13, 2009 at 11:14 AM, Aurélien Pelletier <
aurelien.pelletier at atosorigin.com> wrote:
> Hello,
>
> I'd like to have an idea of how hard it would be to implement the "split
> polygon" feature in openLayer as it is done in geomajas:
>
> http://www.geomajas.org/majas-tutorial/applications/tutorial/html/sample-editing.html
>
> The polygon and the line are send to the server, the polygon is splitted
> using the JTS library on the server side and send back to the client.
>
> Thanks
>
> Aurélien
>
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20090213/a2373e15/attachment.html
More information about the Dev
mailing list