private static void WriteNodesInSubGraph(Subgraph subgraph, PrintWriter islandLog, boolean hadRemoved){ Geometry convexHullGeom = subgraph.getConvexHull(); if (convexHullGeom != null && !(convexHullGeom instanceof Polygon)) { convexHullGeom = convexHullGeom.buffer(0.0001,5); } islandLog.printf("%d\t%d\t%d\t%s\t%b\n", islandCounter, subgraph.stopSize(), subgraph.streetSize(), convexHullGeom, hadRemoved); islandCounter++; } }
Geometry point = geomf.createPoint(vertexSeconds.getKey().getCoordinate()); point = JTS.transform(point, toMeters); Geometry buffer = point.buffer(remainingMeters); bufferLists.put(thresholdSeconds, buffer);
/** * The function is run periodically by the update manager. * The extending class should provide the getNote method. It is not implemented here * as the requirements for different updaters can be vastly different dependent on the data source. */ @Override protected void runPolling() throws IOException{ LOG.info("Run WFS polling updater with hashcode: {}", this.hashCode()); notesForEdge = HashMultimap.create(); uniqueMatchers = new HashMap<>(); FeatureIterator<SimpleFeature> features = featureSource.getFeatures(query).features(); while ( features.hasNext()){ SimpleFeature feature = features.next(); if (feature.getDefaultGeometry() == null) continue; Alert alert = getNote(feature); if (alert == null) continue; Geometry geom = (Geometry) feature.getDefaultGeometry(); Geometry searchArea = geom.buffer(SEARCH_RADIUS_DEG); Collection<Edge> edges = graph.streetIndex.getEdgesForEnvelope(searchArea.getEnvelopeInternal()); for(Edge edge: edges){ if (edge instanceof StreetEdge && !searchArea.disjoint(edge.getGeometry())) { addNote(edge, alert, NOTE_MATCHER); } } } updaterManager.execute(new WFSGraphWriter()); }
/** * Creates a valid area geometry from one that possibly has bad topology * (i.e. self-intersections). Since buffer can handle invalid topology, but * always returns valid geometry, constructing a 0-width buffer "corrects" * the topology. Note this only works for area geometries, since buffer * always returns areas. This also may return empty geometries, if the input * has no actual area. * * @param roughAreaGeom * an area geometry possibly containing self-intersections * @return a valid area geometry */ private Geometry createValidArea(Geometry roughAreaGeom) { return roughAreaGeom.buffer(0.0); } }
/** * Creates a valid area geometry from one that possibly has * bad topology (i.e. self-intersections). * Since buffer can handle invalid topology, but always returns * valid geometry, constructing a 0-width buffer "corrects" the * topology. * Note this only works for area geometries, since buffer always returns * areas. This also may return empty geometries, if the input * has no actual area. * * @param rawAreaGeom an area geometry possibly containing self-intersections * @return a valid area geometry */ private Geometry createValidArea(Geometry rawAreaGeom) { if ( isEnsureValidTopology) return rawAreaGeom.buffer(0.0); return rawAreaGeom; } }
static Geometry createCircle(Coordinate centre, double radius) { Geometry centrePt = geomFact.createPoint(centre); return centrePt.buffer(radius, POLYGON_SIZE); }
static Geometry createCircle() { Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5)); return centrePt.buffer(0.5, 20); }
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 void unionUsingBuffer(Geometry[] geom) { GeometryFactory fact = geom[0].getFactory(); Geometry geomColl = fact.createGeometryCollection(geom); Geometry union = geomColl.buffer(0.0); System.out.println(union); }
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; }
/** * Computes the buffer a geometry, * using enhanced precision. * @param geom0 the Geometry to buffer * @param distance the buffer distance * @return the Geometry representing the buffer of the input Geometry. */ public Geometry buffer(Geometry geom0, double distance) { Geometry geom = removeCommonBits(geom0); return computeResultPrecision(geom.buffer(distance)); }
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 fixPolygonalTopology(Geometry geom) { /** * If precision model was *not* changed, need to flip * geometry to targetPM, buffer in that model, then flip back */ Geometry geomToBuffer = geom; if (! changePrecisionModel) { geomToBuffer = changePM(geom, targetPM); } Geometry bufGeom = geomToBuffer.buffer(0); Geometry finalGeom = bufGeom; if (! changePrecisionModel) { // a slick way to copy the geometry with the original precision factory finalGeom = geom.getFactory().createGeometry(bufGeom); } return finalGeom; }
/** * Snaps the vertices in the component {@link LineString}s * of the source geometry * to the vertices of the given snap geometry. * *@param snapTolerance the snapping tolerance *@param cleanResult whether the result should be made valid * @return a new snapped Geometry */ public Geometry snapToSelf(double snapTolerance, boolean cleanResult) { Coordinate[] snapPts = extractTargetCoordinates(srcGeom); SnapTransformer snapTrans = new SnapTransformer(snapTolerance, snapPts, true); Geometry snappedGeom = snapTrans.transform(srcGeom); Geometry result = snappedGeom; if (cleanResult && result instanceof Polygonal) { // TODO: use better cleaning approach result = snappedGeom.buffer(0); } return result; }
Geometry result = geom.buffer(distance); return result;
static public Geometry buffer(Geometry arg0,double arg1) { Geometry _this = arg0; return _this.buffer(arg1); }
static public Geometry bufferWithSegments(Geometry arg0, Double arg1, Integer arg2) { if (arg0 == null || arg1 == null || arg2 == null) return null; Geometry _this = arg0; return _this.buffer(arg1,arg2); }
static Geometry createCircle(Coordinate centre, double radius) { Geometry centrePt = geomFact.createPoint(centre); return centrePt.buffer(radius, POLYGON_SIZE); }
static Geometry createCircle() { Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5)); return centrePt.buffer(0.5, 20); }