7

I am trying to conceptualize the best process for editing topology from PostGIS in a web browser. Ideally what I would like to accomplish is the loading of a topology (imagine the lower 48 states of the US), adjusting the borders, and updating a PostGIS table with the changes. I am fairly comfortable with the delivery, representation, and uploading of the geometry, but I am a bit stuck on the editing part.

Although it seems like OpenLayers 3 supports topology editing (despite this answer), it does not seem to enforce any rules (for example, it allows the user to drag a boundary to overlap another polygon), nor does it seem like OpenLayers supports exporting vector layers as a GeoJSON, though I'm sure it's possible to write that functionality. Likewise, Leaflet offers the excellent Leaflet.draw plugin along with GeoJSON export functionality, but does not offer the ability to edit a topology.

Unless I'm missing something, it seems like my best bet at this point is to write a tool that allows for the topological editing of polygons, most likely for Leaflet because I am more comfortable with it. I imagine the process would be something like:

  • Click on a boundary
  • Find all features that have a geometry at this location
  • Create a vertex at this location in all found feature geometries
  • While dragging, update all features that share this vertex
  • When done dragging, make sure that no segments of the altered geometries intersect other features

Ideally it would function very similarly to the OpenLayers example above, but would also enforce some rules and make exporting easy. Does this sound like a reasonable process? Am I missing anything? Do you have any specific suggestions for any part of the process, i.e. any existing tools that accomplish these pieces of functionality?

2

I ended up writing a Leaflet plugin, Leaflet.draw.topology, to accomplish this task. The only thing not implemented in the plugin is geometry validation, though in the future it certainly could be. It is currently handled server side with PostGIS.

0

We had similar problem in one of our projects.We've used open layers 2 modify feature (http://openlayers.org/dev/examples/modify-feature.html) to implement editing topology and it works quite well.You can implement some simple basic checks on the client side (open layer have a good support for working with geometries), but we've decided to do most of them on a server side (check if geometry is correct, no intersections etc.) because of the amout of data involved and nature of checks. You can export geometries in open layers to GeoJSON using OpenLayers.Format.GeoJSON:

var geoJSON = new OpenLayers.Format.GeoJSON(),
    geoJSONText = geoJSON.write(geometryObject);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.