Tabnine Logo
Geometry.getLength
Code IndexAdd Tabnine to your IDE (free)

How to use
getLength
method
in
com.vividsolutions.jts.geom.Geometry

Best Java code snippets using com.vividsolutions.jts.geom.Geometry.getLength (Showing top 20 results out of 315)

origin: osmandapp/Osmand

  @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;
  }
}
origin: opentripplanner/OpenTripPlanner

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;
}
origin: com.vividsolutions/jts

/**
 * Returns the index of the end of the line
 * @return the end index
 */
public double getEndIndex()
{
 return linearGeom.getLength();
}
origin: com.vividsolutions/jts

 private double positiveIndex(double index)
 {
  if (index >= 0.0) return index;
  return linearGeom.getLength() + index;
 }
}
origin: com.vividsolutions/jts

public double getLength()
{
 double sum = 0.0;
 for (int i = 0; i < geometries.length; i++) {
  sum += (geometries[i]).getLength();
 }
 return sum;
}
origin: opentripplanner/OpenTripPlanner

Geometry polygon = area.getPolygon();
Geometry intersection = polygon.intersection(line);
if (intersection.getLength() > 0.000001) {
  intersects.add(area);
    continue;
  Geometry lineParts = line.intersection(polygon);
  if (lineParts.getLength() > 0.000001) {
    Coordinate edgeCoordinate = null;
origin: opentripplanner/OpenTripPlanner

MultiPolygon polygon = area.toJTSMultiPolygon();
Geometry intersection = polygon.intersection(line);
if (intersection.getLength() > 0.000001) {
  intersects.add(area);
    continue;
  Geometry lineParts = line.intersection(polygon);
  if (lineParts.getLength() > 0.000001) {
    Coordinate edgeCoordinate = null;
origin: com.vividsolutions/jts

/**
 * 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);
}
origin: com.vividsolutions/jts

/**
 * 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;
}
origin: com.vividsolutions/jts

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); 
}
 
origin: org.geotools/gt-main

static public double geomLength(Geometry arg0)
{
   if (arg0 == null) return 0d;
   Geometry _this = arg0;
   return _this.getLength();
}
origin: com.vividsolutions/jts-core

public double getLength()
{
 double sum = 0.0;
 for (int i = 0; i < geometries.length; i++) {
  sum += (geometries[i]).getLength();
 }
 return sum;
}
origin: com.vividsolutions/jts-core

/**
 * Returns the index of the end of the line
 * @return the end index
 */
public double getEndIndex()
{
 return linearGeom.getLength();
}
origin: org.geotools/gt2-main

static public double geomLength(Geometry arg0)
{
   Geometry _this = arg0;
   return _this.getLength();
}
origin: com.vividsolutions/jts

 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;
 }
}
origin: org.teiid/teiid-engine

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;
}

origin: org.teiid/teiid-engine

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;
}
origin: teiid/teiid

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;
}

origin: BaseXdb/basex

 @Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
  return Dbl.get(checkGeo(0, qc).getLength());
 }
}
origin: org.geotools/gt2-jts-wrapper

/**
 * @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();
}
com.vividsolutions.jts.geomGeometrygetLength

Javadoc

Returns the length of this Geometry. Linear geometries return their length. Areal geometries return their perimeter. They override this function to compute the area. Others return 0.0

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • getCoordinates
    Returns an array containing the values of all the vertices for this geometry. If the geometry is a c
  • isEmpty
    Tests whether the set of points covered by this Geometry is empty.
  • getCentroid
    Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
  • getGeometryN
    Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
  • toText
    Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text
  • getNumGeometries
    Returns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
  • getFactory
    Gets the factory which contains the context in which this geometry was created.
  • getGeometryType
    Returns the name of this Geometry's actual class.
  • getSRID
    Returns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
  • getCoordinate
    Returns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
  • intersection
    Computes a Geometry representing the point-set which is common to both this Geometry and the other
  • getCoordinate,
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply

Popular in Java

  • Running tasks concurrently on multiple threads
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • JComboBox (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now