/** * Create a new concave hull construction for the input {@link Geometry}. * * @param geometry * @param threshold */ public ConcaveHull(Geometry geometry, double threshold) { this.geometries = transformIntoPointGeometryCollection(geometry); this.threshold = threshold; this.geomFactory = geometry.getFactory(); }
private Geometry removeDuplicatePoints(Geometry routeGeometry) { List<Coordinate> coords = new ArrayList<Coordinate>(); Coordinate last = null; for (Coordinate c : routeGeometry.getCoordinates()) { if (!c.equals(last)) { last = c; coords.add(c); } } if (coords.size() < 2) { return null; } Coordinate[] coordArray = new Coordinate[coords.size()]; return routeGeometry.getFactory().createLineString(coords.toArray(coordArray)); }
/** * Transform into GeometryCollection. * * @param geom * input geometry * @return * a geometry collection */ private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) { UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter(); geom.apply(filter); Coordinate[] coord = filter.getCoordinates(); Geometry[] geometries = new Geometry[coord.length]; for (int i = 0 ; i < coord.length ; i++) { Coordinate[] c = new Coordinate[] { coord[i] }; CoordinateArraySequence cs = new CoordinateArraySequence(c); geometries[i] = new Point(cs, geom.getFactory()); } return new GeometryCollection(geometries, geom.getFactory()); }
public BoundaryOp(Geometry geom, BoundaryNodeRule bnRule) { this.geom = geom; geomFact = geom.getFactory(); this.bnRule = bnRule; }
/** * Extracts the GeometryFactory used by the geometries in a collection * * @param geoms * @return a GeometryFactory */ public static GeometryFactory extractFactory(Collection geoms) { if (geoms.isEmpty()) return null; return ((Geometry) geoms.iterator().next()).getFactory(); }
public InteriorPointArea(Geometry g) { factory = g.getFactory(); add(g); } public Coordinate getInteriorPoint()
/** * Create a new convex hull construction for the input {@link Geometry}. */ public ConvexHull(Geometry geometry) { this(extractCoordinates(geometry), geometry.getFactory()); } /**
public void filter(Geometry geom) { if (isForcedToLineString && geom instanceof LinearRing) { LineString line = geom.getFactory().createLineString( ((LinearRing) geom).getCoordinateSequence()); lines.add(line); return; } // if not being forced, and this is a linear component if (geom instanceof LineString) lines.add(geom); // else this is not a linear component, so skip it }
private Geometry bufferUnion(List geoms) { GeometryFactory factory = ((Geometry) geoms.get(0)).getFactory(); Geometry gColl = factory.buildGeometry(geoms); Geometry unionAll = gColl.buffer(0.0); return unionAll; }
public static Point createPointFromInternalCoord(Coordinate coord, Geometry exemplar) { exemplar.getPrecisionModel().makePrecise(coord); return exemplar.getFactory().createPoint(coord); }
private Point createPointFromInternalCoord(Coordinate coord, Geometry exemplar) { exemplar.getPrecisionModel().makePrecise(coord); return exemplar.getFactory().createPoint(coord); }
public static void unionUsingBuffer(Geometry[] geom) { GeometryFactory fact = geom[0].getFactory(); Geometry geomColl = fact.createGeometryCollection(geom); Geometry union = geomColl.buffer(0.0); System.out.println(union); }
/** * Gets the segment forming the base of the minimum diameter * * @return the segment forming the base of the minimum diameter */ public LineString getSupportingSegment() { computeMinimumDiameter(); return inputGeom.getFactory().createLineString(new Coordinate[] { minBaseSeg.p0, minBaseSeg.p1 } ); }
private Geometry bufferUnion(Geometry g0, Geometry g1) { GeometryFactory factory = g0.getFactory(); Geometry gColl = factory.createGeometryCollection(new Geometry[] { g0, g1 } ); Geometry unionAll = gColl.buffer(0.0); return unionAll; }
private Geometry getPolygonLines(Geometry g) { List lines = new ArrayList(); LinearComponentExtracter lineExtracter = new LinearComponentExtracter(lines); List polys = PolygonExtracter.getPolygons(g); for (Iterator i = polys.iterator(); i.hasNext(); ) { Polygon poly = (Polygon) i.next(); poly.apply(lineExtracter); } return g.getFactory().buildGeometry(lines); }
public LineString getLine() { compute(); return inputGeom.getFactory().createLineString(minClearancePts); }
public UnionInteracting(Geometry g0, Geometry g1) { this.g0 = g0; this.g1 = g1; geomFactory = g0.getFactory(); interacts0 = new boolean[g0.getNumGeometries()]; interacts1 = new boolean[g1.getNumGeometries()]; }
public OverlayOp(Geometry g0, Geometry g1) { super(g0, g1); graph = new PlanarGraph(new OverlayNodeFactory()); /** * Use factory of primary geometry. * Note that this does NOT handle mixed-precision arguments * where the second arg has greater precision than the first. */ geomFact = g0.getFactory(); }
public Geometry reduce(Geometry geom) { GeometryEditor geomEdit; if (changePrecisionModel) { GeometryFactory newFactory = new GeometryFactory(newPrecisionModel, geom.getFactory().getSRID()); geomEdit = new GeometryEditor(newFactory); } else // don't change geometry factory geomEdit = new GeometryEditor(); return geomEdit.edit(geom, new PrecisionReducerCoordinateOperation()); }
private void computeGeometry() { bufferOriginalPrecision(); if (resultGeometry != null) return; PrecisionModel argPM = argGeom.getFactory().getPrecisionModel(); if (argPM.getType() == PrecisionModel.FIXED) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }