I think you're heading down a hard road here, Doug. I think you're going to have a hard time preventing vertices from snapping to things they shouldn't.

IMO the best way to simplify polygonal coverages like this is to convert the coverage to an edge-node topology, simplify the edges, and then repolygonize.

There's bits and pieces in JTS to help you do this, but nothing "off-the-shelf". (I also have experimental code to do this, but it's not ready for release.)

You can also use existing tools in JUMP to at least experiment with this - and if you're keen you can always look at how they work and bundle the code into a library for your own use. Try extracting all the unique, line segments, merging them, simplify, then repolygonize.

Doug Smith wrote:
Hi Everyone,

I'm wondering if this is possible: I have a bunch of postal code polygons that 
are pretty complex. I'd like to simplify them, then cause the adjacent points 
of polygons to snap together so that there is no overlap.  (Pre-simplify, they 
align to one another perfectly.)

Here is the code I'm currently trying:

-----
GeometryCollection geomColl = createGeometryCollectionFromWKT(polygonsAsWTK);
GeometryCollectionIterator iter = new GeometryCollectionIterator(geomColl);

while (iter.hasNext()) {
        Geometry g = (Geometry)iter.next();
        Geometry simpleG = TopologyPreservingSimplifier.simplify(g, 0.01);
        if (snappyGeometries.size() > 0) {
                GeometrySnapper snapper = new GeometrySnapper(simpleG);
                Geometry lastGeometry = 
snappyGeometries.get(snappyGeometries.size()-1);
                double snapTolerance = 
GeometrySnapper.computeOverlaySnapTolerance(lastGeometry, simpleG);
                simpleG = 
snapper.snapTo(snappyGeometries.get(snappyGeometries.size()-1), snapTolerance);
        }
        snappyGeometries.add(simpleG);
}

Geometry[] geometriesAsArray = (Geometry[]) snappyGeometries.toArray(new 
Geometry[snappyGeometries.size()]);
Geometry snappyGeomCollection = new GeometryCollection(geometriesAsArray, 
geometriesAsArray[0].getFactory());
-----

And here is what "snappyGeomCollection" looks like in OpenJUMP:

http://drop.io/mapster/asset/snaptest-jpg

The code above assumes that the GeometryCollectionIterator will return 
Geometries in an order that will snap appropriately. I'm pretty much flying 
blind on this though, because I don't clearly know the capabilities of the 
Iterator or the GeometrySnapper.

Any pointers would be very welcome!

Thanks,

Doug
---
Doug Smith
ELP Web Developer
http://www.daveramsey.com
"Life is an occasion, rise to it" -- Mr. Magorium

_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel


--
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022

_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel

Reply via email to