public double getLength() { return lineString.getLength(); }
public double getLength() { // todo: maybe compute the actual circular length? return linearize().getLength(); }
public double getLength() { // todo: maybe compute the actual circular length? return linearize().getLength(); }
@Test public void testMaxAngle() throws Exception { LineString ls = (LineString) new WKTReader().read("LINESTRING(20 0, 10 1, 0 0)"); LineStringCursor cursor = new LineStringCursor(ls); double maxAngle = cursor.getMaxAngleChange(0, ls.getLength()); assertTrue(maxAngle < 11.5); } }
public static double minimumDiameterLength(Geometry g) { return (new MinimumDiameter(g)).getDiameter().getLength(); }
public void findClosestPoint(String wktA, String wktB) { System.out.println("-------------------------------------"); try { Geometry A = wktRdr.read(wktA); Geometry B = wktRdr.read(wktB); System.out.println("Geometry A: " + A); System.out.println("Geometry B: " + B); DistanceOp distOp = new DistanceOp(A, B); double distance = distOp.distance(); System.out.println("Distance = " + distance); Coordinate[] closestPt = distOp.nearestPoints(); LineString closestPtLine = fact.createLineString(closestPt); System.out.println("Closest points: " + closestPtLine + " (distance = " + closestPtLine.getLength() + ")"); } catch (Exception ex) { ex.printStackTrace(); } }
widths[widths.length - 1] = end; double totalLen = line.getLength(); Coordinate[] pts = line.getCoordinates(); double currLen = 0;
/** * Compute the perimeter * @param geometry * @return */ private static double computePerimeter(Geometry geometry) { double sum = 0; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry subGeom = geometry.getGeometryN(i); if (subGeom instanceof Polygon) { sum += ((Polygon) subGeom).getExteriorRing().getLength(); } } return sum; } }
/** * Interpolate a linestring according the start and the end coordinates z * value. If the start or the end z is NaN return the input linestring * * @param lineString * @return */ private static LineString linearZInterpolation(LineString lineString) { double startz = lineString.getStartPoint().getCoordinate().z; double endz = lineString.getEndPoint().getCoordinate().z; if (Double.isNaN(startz) || Double.isNaN(endz)) { return lineString; } else { double length = lineString.getLength(); lineString.apply(new LinearZInterpolationFilter(startz, endz, length)); return lineString; } }
final double bigD = lineString.getLength(); final double z = endZ - startZ; final Coordinate coordEnd = lineString.getCoordinates()[lineString.getCoordinates().length - 1];
assertEquals(10 * Math.PI / 2, cs.linearize(1e-6).getLength(), 1e-6);
/** * Interpolate each linestring of the multilinestring. * * @param multiLineString * @return */ private static MultiLineString linearZInterpolation(MultiLineString multiLineString) { int nbGeom = multiLineString.getNumGeometries(); LineString[] lines = new LineString[nbGeom]; for (int i = 0; i < nbGeom; i++) { LineString subGeom = (LineString) multiLineString.getGeometryN(i); double startz = subGeom.getStartPoint().getCoordinates()[0].z; double endz = subGeom.getEndPoint().getCoordinates()[0].z; double length = subGeom.getLength(); subGeom.apply(new LinearZInterpolationFilter(startz, endz, length)); lines[i] = subGeom; } return FACTORY.createMultiLineString(lines); }
/** * Finds an interior point of a Polygon. * @param geometry the geometry to analyze */ private void addPolygon(Geometry geometry) { if (geometry.isEmpty()) return; Coordinate intPt; double width; LineString bisector = horizontalBisector(geometry); if (bisector.getLength() == 0.0) { width = 0; intPt = bisector.getCoordinate(); } else { Geometry intersections = bisector.intersection(geometry); Geometry widestIntersection = widestGeometry(intersections); width = widestIntersection.getEnvelopeInternal().getWidth(); intPt = centre(widestIntersection.getEnvelopeInternal()); } if (interiorPoint == null || width > maxWidth) { interiorPoint = intPt; maxWidth = width; } }
LineString lineString = geometryFactory.createLineString(new Coordinate[]{getCircumcenter(idgeom, triangleCircumcenter), getCircumcenter(neighIndex, triangleCircumcenter)}); if(lineString.getLength() > epsilon) { lineStrings.add(lineString);
assertEquals(10 * Math.PI, cs.linearize(1e-6).getLength(), 1e-6);