@Test public void testDistance() throws Exception { LineString ls = gf.createLineString(csf.create(new double[] {0,0,1,1,2,2,3,3,4,4,5,5})); MathTransform identity = new AffineTransform2D(new AffineTransform()); Decimator d = new Decimator(identity, new Rectangle(0,0,5,5), 0.8); d.decimateTransformGeneralize((Geometry) ls.clone(), identity); assertEquals(6, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0,0,5,5), 1); d.decimateTransformGeneralize(ls, identity); assertEquals(4, ls.getNumPoints()); d = new Decimator(identity, new Rectangle(0,0,5,5), 6); d.decimateTransformGeneralize(ls, identity); assertEquals(2, ls.getNumPoints()); }
public final void decimateTransformGeneralize(Geometry geometry, MathTransform transform) throws TransformException { if (geometry instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geometry; final int length = collection.getNumGeometries(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(collection.getGeometryN(i), transform); } } else if (geometry instanceof Point) { LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry) .getCoordinateSequence(); decimateTransformGeneralize(seq, transform, false); } else if (geometry instanceof Polygon) { Polygon polygon = (Polygon) geometry; decimateTransformGeneralize(polygon.getExteriorRing(), transform); final int length = polygon.getNumInteriorRing(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(polygon.getInteriorRingN(i), transform); } } else if (geometry instanceof LineString) { LineString ls = (LineString) geometry; LiteCoordinateSequence seq = (LiteCoordinateSequence) ls.getCoordinateSequence(); boolean loop = ls instanceof LinearRing; if(!loop && seq.size() > 1) { double x0 = seq.getOrdinate(0, 0); double y0 = seq.getOrdinate(0, 1); double x1 = seq.getOrdinate(seq.size() - 1, 0); double y1 = seq.getOrdinate(seq.size() - 1, 1); loop = Math.abs(x0 - x1) < EPS && Math.abs(y0 - y1) < EPS; } decimateTransformGeneralize(seq, transform, loop); } }
Decimator { public final void decimateTransformGeneralize(Geometry geometry, MathTransform transform) throws TransformException { if (geometry instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geometry; final int length = collection.getNumGeometries(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(collection.getGeometryN(i), transform); } } else if (geometry instanceof Point) { LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry) .getCoordinateSequence(); decimateTransformGeneralize(seq, transform, false); } else if (geometry instanceof Polygon) { Polygon polygon = (Polygon) geometry; decimateTransformGeneralize(polygon.getExteriorRing(), transform); final int length = polygon.getNumInteriorRing(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(polygon.getInteriorRingN(i), transform); } } else if (geometry instanceof LineString) { LineString ls = (LineString) geometry; LiteCoordinateSequence seq = (LiteCoordinateSequence) ls.getCoordinateSequence(); boolean loop = ls instanceof LinearRing; if(!loop && seq.size() > 1) { double x0 = seq.getOrdinate(0, 0); double y0 = seq.getOrdinate(0, 1); double x1 = seq.getOrdinate(seq.size() - 1, 0); double y1 = seq.getOrdinate(seq.size() - 1, 1); loop = Math.abs(x0 - x1) < EPS && Math.abs(y0 - y1) < EPS; } decimateTransformGeneralize(seq, transform, loop); } } }
Decimator { public final void decimateTransformGeneralize(Geometry geometry, MathTransform transform) throws TransformException { if (geometry instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geometry; final int length = collection.getNumGeometries(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(collection.getGeometryN(i), transform); } } else if (geometry instanceof Point) { LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry) .getCoordinateSequence(); decimateTransformGeneralize(seq, transform, false); } else if (geometry instanceof Polygon) { Polygon polygon = (Polygon) geometry; decimateTransformGeneralize(polygon.getExteriorRing(), transform); final int length = polygon.getNumInteriorRing(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(polygon.getInteriorRingN(i), transform); } } else if (geometry instanceof LineString) { LineString ls = (LineString) geometry; LiteCoordinateSequence seq = (LiteCoordinateSequence) ls.getCoordinateSequence(); boolean loop = ls instanceof LinearRing; if(!loop && seq.size() > 1) { double x0 = seq.getOrdinate(0, 0); double y0 = seq.getOrdinate(0, 1); double x1 = seq.getOrdinate(seq.size() - 1, 0); double y1 = seq.getOrdinate(seq.size() - 1, 1); loop = Math.abs(x0 - x1) < EPS && Math.abs(y0 - y1) < EPS; } decimateTransformGeneralize(seq, transform, loop); } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(MathTransform screenToWorld);  Decimator(double spanx, double spany); }
Decimator { public final void decimateTransformGeneralize(Geometry geometry, MathTransform transform) throws TransformException { if (geometry instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geometry; final int length = collection.getNumGeometries(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(collection.getGeometryN(i), transform); } } else if (geometry instanceof Point) { LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry) .getCoordinateSequence(); decimateTransformGeneralize(seq, transform, false); } else if (geometry instanceof Polygon) { Polygon polygon = (Polygon) geometry; decimateTransformGeneralize(polygon.getExteriorRing(), transform); final int length = polygon.getNumInteriorRing(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(polygon.getInteriorRingN(i), transform); } } else if (geometry instanceof LineString) { LineString ls = (LineString) geometry; LiteCoordinateSequence seq = (LiteCoordinateSequence) ls.getCoordinateSequence(); boolean loop = ls instanceof LinearRing; if(!loop && seq.size() > 1) { double x0 = seq.getOrdinate(0, 0); double y0 = seq.getOrdinate(0, 1); double x1 = seq.getOrdinate(seq.size() - 1, 0); double y1 = seq.getOrdinate(seq.size() - 1, 1); loop = Math.abs(x0 - x1) < EPS && Math.abs(y0 - y1) < EPS; } decimateTransformGeneralize(seq, transform, loop); } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(MathTransform screenToWorld);  Decimator(double spanx, double spany); static double[] computeGeneralizationDistances(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance); final void decimateTransformGeneralize(Geometry geometry,
			MathTransform transform); final void decimate(Geometry geom); }
Decimator { public final void decimateTransformGeneralize(Geometry geometry, MathTransform transform) throws TransformException { if (geometry instanceof GeometryCollection) { GeometryCollection collection = (GeometryCollection) geometry; final int length = collection.getNumGeometries(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(collection.getGeometryN(i), transform); } } else if (geometry instanceof Point) { LiteCoordinateSequence seq = (LiteCoordinateSequence) ((Point) geometry) .getCoordinateSequence(); decimateTransformGeneralize(seq, transform, false); } else if (geometry instanceof Polygon) { Polygon polygon = (Polygon) geometry; decimateTransformGeneralize(polygon.getExteriorRing(), transform); final int length = polygon.getNumInteriorRing(); for (int i = 0; i < length; i++) { decimateTransformGeneralize(polygon.getInteriorRingN(i), transform); } } else if (geometry instanceof LineString) { LineString ls = (LineString) geometry; LiteCoordinateSequence seq = (LiteCoordinateSequence) ls.getCoordinateSequence(); boolean loop = ls instanceof LinearRing; if(!loop && seq.size() > 1) { double x0 = seq.getOrdinate(0, 0); double y0 = seq.getOrdinate(0, 1); double x1 = seq.getOrdinate(seq.size() - 1, 0); double y1 = seq.getOrdinate(seq.size() - 1, 1); loop = Math.abs(x0 - x1) < EPS && Math.abs(y0 - y1) < EPS; } decimateTransformGeneralize(seq, transform, loop); } } Decimator(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance);  Decimator(MathTransform screenToWorld, Rectangle paintArea);  Decimator(MathTransform screenToWorld);  Decimator(double spanx, double spany); static double[] computeGeneralizationDistances(MathTransform screenToWorld, Rectangle paintArea, double pixelDistance); final void decimateTransformGeneralize(Geometry geometry,
			MathTransform transform); final void decimate(Geometry geom);  }