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

Reply via email to