nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d); // Can't use 0d, specify value < .5d
public void simplify(double tolerance) { value = TopologyPreservingSimplifier.simplify(value, tolerance); }
public void simplify(double tolerance) { value = TopologyPreservingSimplifier.simplify(value, tolerance); }
/** * Simplifies a geometry and ensures that the result is a valid geometry * having the same dimension and number of components as the input, and with * the components having the same topological relationship. * * @param geometry * @param distance * @return */ public static Geometry simplyPreserve(Geometry geometry, double distance) { if(geometry == null){ return null; } return TopologyPreservingSimplifier.simplify(geometry, distance); } }
/** * Simplifies a geometry and ensures that the result is a valid geometry * having the same dimension and number of components as the input, and with * the components having the same topological relationship. * * @param geometry * @param distance * @return */ public static Geometry simplyPreserve(Geometry geometry, double distance) { if(geometry == null){ return null; } return TopologyPreservingSimplifier.simplify(geometry, distance); } }
public static GeometryType simplifyPreserveTopology( GeometryType geom, double tolerance) throws FunctionExecutionException { return getGeometryType(TopologyPreservingSimplifier.simplify(getGeometry(geom), tolerance)); }
public static GeometryType simplifyPreserveTopology( GeometryType geom, double tolerance) throws FunctionExecutionException { return getGeometryType(TopologyPreservingSimplifier.simplify(getGeometry(geom), tolerance), geom.getSrid()); }
public static GeometryType simplifyPreserveTopology( GeometryType geom, double tolerance) throws FunctionExecutionException { return getGeometryType(TopologyPreservingSimplifier.simplify(getGeometry(geom), tolerance), geom.getSrid()); }
/** * Create a circular polygon from a lat, lon, radius, vertices, and distanceTolerance. * * @param lat - latitude in EPSG:4326 decimal degrees * @param lon - longitude in EPSG:4326 decimal degrees * @return radius - distance from the center point in meters * @return maxVertices - the maximum number of vertices in the finished circle polygon * @return distanceTolerance - the maximum distance from the original vertices a reduced vertex * may lie on a simplified circular polygon */ public static Geometry createCirclePolygon( double lat, double lon, double radius, int maxVertices, double distanceTolerance) { double step = distanceTolerance; Measure measure = Measure.valueOf(radius, SI.METER); Point jtsPoint = new GeometryFactory().createPoint(new Coordinate(lon, lat)); Geometry bufferedCircle = createBufferedCircleFromPoint(measure, DefaultGeographicCRS.WGS84, jtsPoint); Geometry simplifiedCircle = createBufferedCircleFromPoint(measure, DefaultGeographicCRS.WGS84, jtsPoint); int maxVerticesWithClosedPoint = maxVertices + 1; while (simplifiedCircle.getCoordinates().length > maxVerticesWithClosedPoint) { simplifiedCircle = TopologyPreservingSimplifier.simplify(bufferedCircle, distanceTolerance); distanceTolerance += step; } return simplifiedCircle; }
lr = (LinearRing) TopologyPreservingSimplifier.simplify(lr, 1e-3); outerRings.add(lr); } else {
lr = (LinearRing) TopologyPreservingSimplifier.simplify(lr, 1e-3); outerRings.add(lr); } else {
Geometry out = TopologyPreservingSimplifier.simplify(in, tolerance);
public SimpleFeature next() throws NoSuchElementException { SimpleFeature f = delegate.next(); for (Object attribute : f.getAttributes()) { if (attribute instanceof Geometry) { if (preserveTopology) { attribute = DouglasPeuckerSimplifier.simplify((Geometry) attribute, distance); } else { attribute = TopologyPreservingSimplifier.simplify((Geometry) attribute, distance); } } fb.add(attribute); } return fb.buildFeature(f.getID()); }
@Override public Field[] createIndexableFields(Shape shape) { Geometry geo = ((JtsSpatialContext)ctx).getGeometryFrom(shape); WKBWriter writer = new WKBWriter(); BytesRef wkb = new BytesRef(writer.write(geo)); if (max_wkb_length > 0 && wkb.length > max_wkb_length) { long last = wkb.length; Envelope env = geo.getEnvelopeInternal(); double mins = Math.min(env.getWidth(), env.getHeight()); double div = 1000; while (true) { double tolerance = mins / div; if (logger.isInfoEnabled()) { logger.info("Simplifying long geometry: WKB.length=" + wkb.length + " tolerance=" + tolerance); } Geometry simple = TopologyPreservingSimplifier.simplify(geo, tolerance); wkb = new BytesRef(writer.write(simple)); if (wkb.length < max_wkb_length) { break; } if (wkb.length == last) { throw new InvalidShapeException("Can not simplify geometry smaller then max. " + last); } last = wkb.length; div *= .70; } } return new Field[]{new SortedDocValuesField(getFieldName(), wkb)}; }
SimpleFeature genFeature = w.next(); genFeature.setAttributes(feature.getAttributes()); Geometry newGeom = TopologyPreservingSimplifier.simplify((Geometry) feature .getDefaultGeometry(), distanceArray[i]); genFeature.setDefaultGeometry(newGeom);
public SimpleFeature next() throws NoSuchElementException { SimpleFeature feature = delegate.next(); Double distanceTolerance = tolerance.evaluate(feature, Double.class); for (Object attribute : feature.getAttributes()) { if (attribute instanceof Geometry) { if (distanceTolerance != null && distanceTolerance > 0) { Geometry geometry = (Geometry) attribute; if (preserveTopology) { geometry = TopologyPreservingSimplifier.simplify(geometry, distanceTolerance); } else { geometry = DouglasPeuckerSimplifier.simplify(geometry, distanceTolerance); } if (geometry != null && !geometry.isEmpty()) { geometry.setUserData(((Geometry) attribute).getUserData()); attribute = geometry; } } } builder.add(attribute); } return builder.buildFeature(feature.getID()); } }