use of org.locationtech.jts.simplify.DouglasPeuckerSimplifier in project OpenTripPlanner by opentripplanner.
the class GraphUtils method makeBuffer.
public static Geometry makeBuffer(Graph graph) {
Geometry geom = geometryCollectionFromVertices(graph).buffer(.04, 6);
DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier(geom);
simplifier.setDistanceTolerance(0.00001);
return simplifier.getResultGeometry();
}
use of org.locationtech.jts.simplify.DouglasPeuckerSimplifier in project teiid by teiid.
the class GeometryUtils method simplify.
public static GeometryType simplify(GeometryType geom, double tolerance) throws FunctionExecutionException {
DouglasPeuckerSimplifier douglasPeuckerSimplifier = new DouglasPeuckerSimplifier(getGeometry(geom));
douglasPeuckerSimplifier.setEnsureValid(false);
douglasPeuckerSimplifier.setDistanceTolerance(tolerance);
Geometry resultGeometry = douglasPeuckerSimplifier.getResultGeometry();
return getGeometryType(resultGeometry, geom.getSrid());
}
use of org.locationtech.jts.simplify.DouglasPeuckerSimplifier in project hortonmachine by TheHortonMachine.
the class OmsVectorSimplifier method process.
// PARAM DESC END
@Execute
public void process() throws Exception {
if (!concatOr(outVector == null, doReset)) {
return;
}
FeatureIterator<SimpleFeature> inFeatureIterator = inVector.features();
outVector = new DefaultFeatureCollection();
FeatureGeometrySubstitutor fGS = new FeatureGeometrySubstitutor(inVector.getSchema());
GeometryPrecisionReducer geometryReducer = null;
int size = inVector.size();
pm.beginTask("Simplifing features...", size);
while (inFeatureIterator.hasNext()) {
SimpleFeature feature = inFeatureIterator.next();
Geometry geometry = (Geometry) feature.getDefaultGeometry();
List<Geometry> geomList = new ArrayList<Geometry>();
int numGeometries = geometry.getNumGeometries();
for (int i = 0; i < numGeometries; i++) {
Geometry geometryN = geometry.getGeometryN(i);
switch(pType) {
case TOPOLOGYPRESERVINGSIMPLIFIER:
TopologyPreservingSimplifier tpSimplifier = new TopologyPreservingSimplifier(geometryN);
tpSimplifier.setDistanceTolerance(pTolerance);
Geometry tpsGeometry = tpSimplifier.getResultGeometry();
geomList.add(tpsGeometry);
break;
case DOUGLAS_PEUCKER:
DouglasPeuckerSimplifier dpSimplifier = new DouglasPeuckerSimplifier(geometryN);
dpSimplifier.setDistanceTolerance(pTolerance);
Geometry dpsGeometry = dpSimplifier.getResultGeometry();
geomList.add(dpsGeometry);
break;
case PRECISION_REDUCER:
if (geometryReducer == null) {
if (pScale == null) {
throw new ModelsIllegalargumentException("To reduce the precision the scale parameter needs to be set.", this);
}
geometryReducer = new GeometryPrecisionReducer(new PrecisionModel(pScale));
}
geomList.add(geometryReducer.reduce(geometryN));
default:
}
}
Geometry newGeometry = null;
if (geomList.size() == 1) {
newGeometry = geomList.get(0);
} else {
Geometry[] geomArray = (Geometry[]) geomList.toArray(new Geometry[geomList.size()]);
newGeometry = new GeometryCollection(geomArray, gf);
}
SimpleFeature newFeature = fGS.substituteGeometry(feature, newGeometry);
((DefaultFeatureCollection) outVector).add(newFeature);
pm.worked(1);
}
pm.done();
inFeatureIterator.close();
}
use of org.locationtech.jts.simplify.DouglasPeuckerSimplifier in project snap-idepix by bcdev.
the class IdepixOlciUtils method computeProductGeometry.
static Geometry computeProductGeometry(Product product) {
try {
final GeneralPath[] paths = GeoUtils.createGeoBoundaryPaths(product);
final Polygon[] polygons = new Polygon[paths.length];
final GeometryFactory factory = new GeometryFactory();
for (int i = 0; i < paths.length; i++) {
polygons[i] = convertAwtPathToJtsPolygon(paths[i], factory);
}
final DouglasPeuckerSimplifier peuckerSimplifier = new DouglasPeuckerSimplifier(polygons.length == 1 ? polygons[0] : factory.createMultiPolygon(polygons));
return peuckerSimplifier.getResultGeometry();
} catch (Exception e) {
return null;
}
}
Aggregations