@Override public boolean equals(Object other) { if (!(other instanceof ReversibleLineStringWrapper)) return false; ReversibleLineStringWrapper that = (ReversibleLineStringWrapper) other; CoordinateSequence cs0 = this.ls.getCoordinateSequence(); CoordinateSequence cs1 = that.ls.getCoordinateSequence(); if (cs0.equals(cs1)) return true; return matchesBackward(cs0, cs1); }
private static int checkRepeatedPoints2d(LineString lineString) { int repeatedPoints = 0; final CoordinateSequence coordSeq = lineString.getCoordinateSequence(); Coordinate nextCoord = null, prevCoord; for(int i = 0; i < coordSeq.size(); ++i) { prevCoord = nextCoord; nextCoord = coordSeq.getCoordinate(i); if(nextCoord.equals(prevCoord)) { ++repeatedPoints; } } return repeatedPoints; } }
@Override public int hashCode() { CoordinateSequence cs = ls.getCoordinateSequence(); int maxIdx = cs.size() - 1; int x = (int) (cs.getX(0) * 1000000) + (int) (cs.getX(maxIdx) * 1000000); int y = (int) (cs.getY(0) * 1000000) + (int) (cs.getY(maxIdx) * 1000000); return x + y * 101149 + maxIdx * 7883; }
public double distanceAlong() { CoordinateSequence cs = ( (LineString)(edge.getGeometry()) ).getCoordinateSequence(); double dist = 0; double x0 = cs.getX(0); double y0 = cs.getY(0); for (int s = 1; s < seg; s++) { double x1 = cs.getX(s); double y1 = cs.getY(s); dist += SphericalDistanceLibrary.fastDistance(y0, x0, y1, x1); x0 = x1; y0 = y1; } dist += SphericalDistanceLibrary.fastDistance(y0, x0, y, x); // dist along partial segment return dist; }
public double distanceToEnd() { CoordinateSequence cs = ( (LineString)(edge.getGeometry()) ).getCoordinateSequence(); int s = seg + 1; double x0 = cs.getX(s); double y0 = cs.getY(s); double dist = SphericalDistanceLibrary.fastDistance(y0, x0, y, x); // dist along partial segment int nc = cs.size(); for (; s < nc; s++) { double x1 = cs.getX(s); double y1 = cs.getY(s); dist += SphericalDistanceLibrary.fastDistance(y0, x0, y1, x1); x0 = x1; y0 = y1; } return dist; } }
LinearRing lr = new LinearRing(merge.getCoordinateSequence(), this.geomFactory); Polygon concaveHull = new Polygon(lr, null, this.geomFactory); return concaveHull;
public void filter(Geometry geom) { CoordinateSequence seq = null; if (geom instanceof LineString) { seq = ((LineString) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } else if (geom instanceof Point) { seq = ((Point) geom).getCoordinateSequence(); addFacetSequences(seq, sections); } } });
continue; CoordinateSequence coordSeq = ls.getCoordinateSequence(); int numCoords = coordSeq.size(); for (int seg = 0; seg < numCoords - 1; seg++) {
public GeometryContainsPointVisitor(Polygon rectangle) { this.rectSeq = rectangle.getExteriorRing().getCoordinateSequence(); rectEnv = rectangle.getEnvelopeInternal(); }
/** * Transforms a {@link LineString} geometry. * * @param geom * @param parent * @return */ protected Geometry transformLineString(LineString geom, Geometry parent) { // should check for 1-point sequences and downgrade them to points return factory.createLineString( transformCoordinates(geom.getCoordinateSequence(), geom)); }
public void filter(Geometry geom) { if (geom instanceof LineString) { expandToInclude( ((LineString) geom).getCoordinateSequence()); } else if (geom instanceof Point) { expandToInclude( ((Point) geom).getCoordinateSequence()); } } }
private void writeLineString(LineString line, OutStream os) throws IOException { writeByteOrder(os); writeGeometryType(WKBConstants.wkbLineString, line, os); writeCoordinateSequence(line.getCoordinateSequence(), true, os); }
public boolean intersects(Coordinate pt, LineString ring) { CoordinateSequence seq = ring.getCoordinateSequence(); CoordinateSequence seqProj = project(seq, facingPlane); Coordinate ptProj = project(pt, facingPlane); return Location.EXTERIOR != RayCrossingCounter.locatePointInRing(ptProj, seqProj); }
private int locate(Coordinate pt, LineString ring) { CoordinateSequence seq = ring.getCoordinateSequence(); CoordinateSequence seqProj = project(seq, facingPlane); Coordinate ptProj = project(pt, facingPlane); return RayCrossingCounter.locatePointInRing(ptProj, seqProj); }
/** * Tests if a linestring is completely contained in the boundary of the target rectangle. * @param line the linestring to test * @return true if the linestring is contained in the boundary */ private boolean isLineStringContainedInBoundary(LineString line) { CoordinateSequence seq = line.getCoordinateSequence(); Coordinate p0 = new Coordinate(); Coordinate p1 = new Coordinate(); for (int i = 0; i < seq.size() - 1; i++) { seq.getCoordinate(i, p0); seq.getCoordinate(i + 1, p1); if (! isLineSegmentContainedInBoundary(p0, p1)) return false; } return true; }
private void checkIntersectionWithSegments(LineString testLine) { CoordinateSequence seq1 = testLine.getCoordinateSequence(); for (int j = 1; j < seq1.size(); j++) { seq1.getCoordinate(j - 1, p0); seq1.getCoordinate(j, p1); if (rectIntersector.intersects(p0, p1)) { hasIntersection = true; return; } } }
private void writePolygon(Polygon poly, OutStream os) throws IOException { writeByteOrder(os); writeGeometryType(WKBConstants.wkbPolygon, poly, os); writeInt(poly.getNumInteriorRing() + 1, os); writeCoordinateSequence(poly.getExteriorRing().getCoordinateSequence(), true, os); for (int i = 0; i < poly.getNumInteriorRing(); i++) { writeCoordinateSequence(poly.getInteriorRingN(i).getCoordinateSequence(), true, os); } }
.get((Trip) environment.getSource()).geometry.getCoordinateSequence()) .build()) .build();
public final Geometry edit(Geometry geometry, GeometryFactory factory) { if (geometry instanceof LinearRing) { return factory.createLinearRing(edit( ((LinearRing)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof LineString) { return factory.createLineString(edit( ((LineString)geometry).getCoordinateSequence(), geometry)); } if (geometry instanceof Point) { return factory.createPoint(edit( ((Point)geometry).getCoordinateSequence(), geometry)); } return geometry; }
private boolean isWithinToleranceOfBoundary(Coordinate pt) { for (int i = 0; i < linework.getNumGeometries(); i++) { LineString line = (LineString) linework.getGeometryN(i); CoordinateSequence seq = line.getCoordinateSequence(); for (int j = 0; j < seq.size() - 1; j++) { seq.getCoordinate(j, seg.p0); seq.getCoordinate(j + 1, seg.p1); double dist = seg.distance(pt); if (dist <= boundaryDistanceTolerance) return true; } } return false; } }