@Override public boolean accept(Geometry geometry) { boolean accept = true; if((geometry instanceof Polygon || geometry instanceof MultiPolygon) && geometry.getArea() < minArea) { accept = false; } else if((geometry instanceof LineString || geometry instanceof MultiLineString) && geometry.getLength() < minLength) { accept = false; } return accept; } }
private boolean isValid(Geometry geometry, Stop s0, Stop s1) { Coordinate[] coordinates = geometry.getCoordinates(); if (coordinates.length < 2) { return false; } if (geometry.getLength() == 0) { return false; } for (Coordinate coordinate : coordinates) { if (Double.isNaN(coordinate.x) || Double.isNaN(coordinate.y)) { return false; } } Coordinate geometryStartCoord = coordinates[0]; Coordinate geometryEndCoord = coordinates[coordinates.length - 1]; Coordinate startCoord = new Coordinate(s0.getLon(), s0.getLat()); Coordinate endCoord = new Coordinate(s1.getLon(), s1.getLat()); if (SphericalDistanceLibrary.fastDistance(startCoord, geometryStartCoord) > maxStopToShapeSnapDistance) { return false; } else if (SphericalDistanceLibrary.fastDistance(endCoord, geometryEndCoord) > maxStopToShapeSnapDistance) { return false; } return true; }
/** * Returns the index of the end of the line * @return the end index */ public double getEndIndex() { return linearGeom.getLength(); }
private double positiveIndex(double index) { if (index >= 0.0) return index; return linearGeom.getLength() + index; } }
public double getLength() { double sum = 0.0; for (int i = 0; i < geometries.length; i++) { sum += (geometries[i]).getLength(); } return sum; }
/** * Compute the {@link LinearLocation} corresponding to a length. * Negative lengths are measured in reverse from end of the linear geometry. * Out-of-range values are clamped. * Ambiguous indexes are resolved to the lowest or highest possible location value, * depending on the value of <tt>resolveLower</tt> * * @param length the length index * @return the corresponding LinearLocation */ public LinearLocation getLocation(double length, boolean resolveLower) { double forwardLength = length; // negative values are measured from end of geometry if (length < 0.0) { double lineLen = linearGeom.getLength(); forwardLength = lineLen + length; } LinearLocation loc = getLocationForward(forwardLength); if (resolveLower) { return loc; } return resolveHigher(loc); }
/** * Finds the nearest index along the linear {@link Geometry} * to a given {@link Coordinate} * after the specified minimum index. * If possible the location returned will be strictly greater than the * <code>minLocation</code>. * If this is not possible, the * value returned will equal <code>minLocation</code>. * (An example where this is not possible is when * minLocation = [end of line] ). * * @param inputPt the coordinate to locate * @param minIndex the minimum location for the point location * @return the location of the nearest point */ public double indexOfAfter(Coordinate inputPt, double minIndex) { if (minIndex < 0.0) return indexOf(inputPt); // sanity check for minIndex at or past end of line double endIndex = linearGeom.getLength(); if (endIndex < minIndex) return endIndex; double closestAfter = indexOfFromStart(inputPt, minIndex); /** * Return the minDistanceLocation found. */ Assert.isTrue(closestAfter >= minIndex, "computed index is before specified minimum index"); return closestAfter; }
private LinearLocation resolveHigher(LinearLocation loc) { if (! loc.isEndpoint(linearGeom)) return loc; int compIndex = loc.getComponentIndex(); // if last component can't resolve any higher if (compIndex >= linearGeom.getNumGeometries() - 1) return loc; do { compIndex++; } while (compIndex < linearGeom.getNumGeometries() - 1 && linearGeom.getGeometryN(compIndex).getLength() == 0); // resolve to next higher location return new LinearLocation(compIndex, 0, 0.0); }
static public double geomLength(Geometry arg0) { if (arg0 == null) return 0d; Geometry _this = arg0; return _this.getLength(); }
public double getLength() { double sum = 0.0; for (int i = 0; i < geometries.length; i++) { sum += (geometries[i]).getLength(); } return sum; }
/** * Returns the index of the end of the line * @return the end index */ public double getEndIndex() { return linearGeom.getLength(); }
static public double geomLength(Geometry arg0) { Geometry _this = arg0; return _this.getLength(); }
public LinearLocation[] indicesOf(Geometry subLine) { Coordinate startPt = ((LineString) subLine.getGeometryN(0)).getCoordinateN(0); LineString lastLine = (LineString) subLine.getGeometryN(subLine.getNumGeometries() - 1); Coordinate endPt = lastLine.getCoordinateN(lastLine.getNumPoints() - 1); LocationIndexOfPoint locPt = new LocationIndexOfPoint(linearGeom); LinearLocation[] subLineLoc = new LinearLocation[2]; subLineLoc[0] = locPt.indexOf(startPt); // check for case where subline is zero length if (subLine.getLength() == 0.0) { subLineLoc[1] = (LinearLocation) subLineLoc[0].clone(); } else { subLineLoc[1] = locPt.indexOfAfter(endPt, subLineLoc[0]); } return subLineLoc; } }
public static Double length(GeometryType geom) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (g instanceof LineString || g instanceof MultiLineString) { return g.getLength(); } return 0.0; }
public static Double perimeter(GeometryType geom) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (g instanceof Polygon || g instanceof MultiPolygon) { return g.getLength(); } return 0.0; }
public static Double length(GeometryType geom) throws FunctionExecutionException { Geometry g = getGeometry(geom); if (g instanceof LineString || g instanceof MultiLineString) { return g.getLength(); } return 0.0; }
@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { return Dbl.get(checkGeo(0, qc).getLength()); } }
/** * @return * @see com.polexis.lite.spatialschema.geometry.geometry.GenericSurfaceImpl#getPerimeter() */ public final double getPerimeter() { com.vividsolutions.jts.geom.Geometry jtsGeom = getJTSGeometry(); return jtsGeom.getBoundary().getLength(); }