Posting again as plain text (without attachments) -
Hi All,
I am trying to simplify a number of polygons using
DouglasPeuckerSimplifier, and occasionally (5 out of approx 16000
cases) find that most of the polygon is thrown away and only the top
protruding edge is retained. All the cases that I found had protruding
edge on the top. Using the TopologyPreservingSimplifier seems to work
fine - at least in the case mentioned in my example.
I am pasting the problem code example below as well as attaching the
source and screenshots of the generated polygons. I am using the
current latest version of JTS (1.13).
Is anyone aware of this issue or any workarounds. I have about 16000
polygons to process and I have identified this issue on only about 5
of them (at a given tolerance). I will try using the
TopologyPreservingSimplifier but not sure if it will uncover any new
issues.
Any help or guidance on this will be highly appreciated.
Thanks and Regards,
Neetish.
CODE EXAMPLE
==============
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader;
import com.vividsolutions.jts.io.WKTWriter;
import com.vividsolutions.jts.simplify.DouglasPeuckerSimplifier;
import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
public class JTSSimplifierIssue {
public static void main(String args[]) throws ParseException {
String originalPolygonWKT = "POLYGON ((151.0862232434861
-33.23519198113195, 151.102165965858 -33.23168640161714,
151.1066061590301 -33.23127789308165, 151.106561082659
-33.23075990116803, 151.1066734725971 -33.23075312219226,
151.10672967655 -33.23166969002676, 151.1062554896681
-33.23247728212027, 151.1062630592991 -33.2336855300988,
151.106063405211 -33.23417996855341, 151.1046763522011
-33.23521464061082, 151.0862232434861 -33.23519198113195))";
Geometry originalPolygon = new WKTReader().read(originalPolygonWKT);
System.out.println("Initial Points = " +
originalPolygon.getNumPoints());
//The Douglas Peucker Simplifier works fine at some other tolerances e.g. 0.0005
double tolerance = 0.0004;
//This one just capture the tip on the right hand top corner - see
simpify-dp.jpg for details
Geometry simplifiedPolygonDouglasPeucker =
DouglasPeuckerSimplifier.simplify(originalPolygon, tolerance);
//This one works as expected - see simplify-tp.jpg for details
Geometry simplifiedPolygonTopologyPreserving =
TopologyPreservingSimplifier.simplify(originalPolygon, tolerance);
logDetails(simplifiedPolygonDouglasPeucker, "Douglas Peucker
Simplified Geometry");
logDetails(simplifiedPolygonTopologyPreserving, "Topology
Preserving Simplified Geometry");
}
public static void logDetails(Geometry geometry, String label) {
System.out.println("**************************************************************************************");
System.out.println(label);
System.out.println("**************************************************************************************");
System.out.println("Number of points = " + geometry.getNumPoints());
System.out.println(new WKTWriter().write(geometry));
System.out.println();
System.out.println();
}
}
OUTPUT
=======
Initial Points = 11
**************************************************************************************
Douglas Peucker Simplified Geometry
**************************************************************************************
Number of points = 4
POLYGON ((151.1065796150313 -33.23128033519389, 151.1066734725971
-33.23075312219226, 151.1066061590301 -33.23127789308165,
151.1065796150313 -33.23128033519389))
**************************************************************************************
Topology Preserving Simplified Geometry
**************************************************************************************
Number of points = 8
POLYGON ((151.0862232434861 -33.23519198113195, 151.102165965858
-33.23168640161714, 151.1066061590301 -33.23127789308165,
151.1066734725971 -33.23075312219226, 151.10672967655
-33.23166969002676, 151.106063405211 -33.23417996855341,
151.1046763522011 -33.23521464061082, 151.0862232434861
-33.23519198113195))
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Jts-topo-suite-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user