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

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

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

Refine searchRefine arrow

  • Geometry.getNumGeometries
origin: opentripplanner/OpenTripPlanner

  public static LinearLocation getEndLocation(Geometry linear) {
    //the version in LinearLocation is broken
    
    int lastComponentIndex = linear.getNumGeometries() - 1;
    LineString lastLine = (LineString) linear.getGeometryN(lastComponentIndex);
    int lastSegmentIndex = lastLine.getNumPoints() - 1;
    return new LinearLocation(lastComponentIndex, lastSegmentIndex, 0.0);
  }
}
origin: osmandapp/Osmand

private static FeatureStats pointStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();
  final HashSet<Point> pointSet = new HashSet<>(geom.getNumPoints());
  featureStats.totalPts = geom.getNumPoints();
  for(int i = 0; i < geom.getNumGeometries(); ++i) {
    final Point p = (Point) geom.getGeometryN(i);
    featureStats.repeatedPts += pointSet.add(p) ? 0 : 1;
  }
  return featureStats;
}
origin: osmandapp/Osmand

nextGeomCount = nextGeom.getNumGeometries();
for(int i = 0; i < nextGeomCount; ++i) {
  geomStack.push(nextGeom.getGeometryN(i));
origin: osmandapp/Osmand

private static FeatureStats lineStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();
  for(int i = 0; i < geom.getNumGeometries(); ++i) {
    final LineString lineString = (LineString) geom.getGeometryN(i);
    featureStats.totalPts += lineString.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(lineString);
  }
  return featureStats;
}
origin: opentripplanner/OpenTripPlanner

public void setGeom(Geometry geom) throws EmptyPolygonException, UnsupportedGeometryException {
  if (geom instanceof MultiPolygon) {
    if (geom.isEmpty()) {
      throw new EmptyPolygonException();
    }
    if (geom.getNumGeometries() > 1) {
      // LOG.warn("Multiple polygons in MultiPolygon, using only the first.");
      // TODO percolate this warning up somehow
    }
    this.geom = geom.getGeometryN(0);
  } else if( geom instanceof Point || geom instanceof Polygon){
    this.geom = geom;
  } else {
    throw new UnsupportedGeometryException( "Non-point, non-polygon Geometry, not supported." );
  }
  // cache a representative point
  Point point = geom.getCentroid();
  this.lat = point.getY();
  this.lon = point.getX();
}
origin: opentripplanner/OpenTripPlanner

/**
 * Computes the angle of the last segment of a LineString or MultiLineString in radians clockwise from North
 * in the range (-PI, PI).
 * @param geometry a LineString or a MultiLineString
 */
public static synchronized double getLastAngle(Geometry geometry) {
  LineString line;
  if (geometry instanceof MultiLineString) {
    line = (LineString) geometry.getGeometryN(geometry.getNumGeometries() - 1);
  } else {
    assert geometry instanceof LineString;
    line = (LineString) geometry;
  }
  int numPoints = line.getNumPoints();
  Coordinate coord0 = line.getCoordinateN(numPoints - 2);
  Coordinate coord1 = line.getCoordinateN(numPoints - 1);
  int i = numPoints - 3;
  int minDistance = 10;  // Meters        
  while (SphericalDistanceLibrary.fastDistance(coord0, coord1) < minDistance && i >= 0) {
    coord0 = line.getCoordinateN(i--);
  }
  double az = getAzimuth(coord0, coord1);
  return az * Math.PI / 180;
}
origin: osmandapp/Osmand

private static FeatureStats polyStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();
  for(int i = 0; i < geom.getNumGeometries(); ++i) {
    final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
    // Stats: exterior ring
    final LineString exteriorRing = nextPoly.getExteriorRing();
    featureStats.totalPts += exteriorRing.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(exteriorRing);
    // Stats: interior rings
    for(int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {
      final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);
      featureStats.totalPts += nextInteriorRing.getNumPoints();
      featureStats.repeatedPts += checkRepeatedPoints2d(nextInteriorRing);
    }
  }
  return featureStats;
}
origin: osmandapp/Osmand

for (int i = 0; i < geom.getNumGeometries(); ++i) {
  mvtGeom.addAll(linesToGeomCmds(geom.getGeometryN(i), mvtClosePath, cursor, 1));
for(int i = 0; i < geom.getNumGeometries(); ++i) {
  final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
  final List<Integer> nextPolyGeom = new ArrayList<>();
  boolean valid = true;
origin: opentripplanner/OpenTripPlanner

  /**
   * Computes the angle from the first point to the last point of a LineString or MultiLineString. TODO: put this method into
   * org.opentripplanner.common.geometry.DirectionUtils
   * 
   * @param geometry a LineString or a MultiLineString
   * 
   * @return
   */
  public synchronized double getFirstToLastSegmentAngle(Geometry geometry) {
    LineString line;
    if (geometry instanceof MultiLineString) {
      line = (LineString) geometry.getGeometryN(geometry.getNumGeometries() - 1);
    } else {
      assert geometry instanceof LineString;
      line = (LineString) geometry;
    }
    int numPoints = line.getNumPoints();
    Coordinate coord0 = line.getCoordinateN(0);
    Coordinate coord1 = line.getCoordinateN(numPoints - 1);
    int i = numPoints - 3;
    while (SphericalDistanceLibrary.fastDistance(coord0, coord1) < 10 && i >= 0) {
      coord1 = line.getCoordinateN(i--);
    }

    geodeticCalculator.setStartingGeographicPoint(coord0.x, coord0.y);
    geodeticCalculator.setDestinationGeographicPoint(coord1.x, coord1.y);
    return geodeticCalculator.getAzimuth() * Math.PI / 180;
  }
}
origin: com.vividsolutions/jts

private void computeInteracting()
{
  for (int i = 0; i < g0.getNumGeometries(); i++) {
    Geometry elem = g0.getGeometryN(i);
    interacts0[i] = computeInteracting(elem);
  }
}
 
origin: com.vividsolutions/jts

private Geometry extractElements(Geometry geom, 
    boolean[] interacts, boolean isInteracting)
{
  List extractedGeoms = new ArrayList();
  for (int i = 0; i < geom.getNumGeometries(); i++) { 
    Geometry elem = geom.getGeometryN(i);
    if (interacts[i] == isInteracting)
      extractedGeoms.add(elem);
  }
  return geomFactory.buildGeometry(extractedGeoms);
}
origin: com.vividsolutions/jts

private void extractElements(Geometry geom, List elems)
{
 if (geom == null)
  return;
 
 for (int i = 0; i < geom.getNumGeometries(); i++) {
  Geometry elemGeom = geom.getGeometryN(i);
  if (skipEmpty && elemGeom.isEmpty())
   continue;
  elems.add(elemGeom);
 }
}
origin: com.vividsolutions/jts

/**
 * Sets the value of this location to
 * refer to the end of a linear geometry.
 *
 * @param linear the linear geometry to use to set the end
 */
public void setToEnd(Geometry linear)
{
 componentIndex = linear.getNumGeometries() - 1;
 LineString lastLine = (LineString) linear.getGeometryN(componentIndex);
 segmentIndex = lastLine.getNumPoints() - 1;
 segmentFraction = 1.0;
}
origin: com.vividsolutions/jts

/**
 * Tests whether a geometry consists of a single polygon with no holes.
 *  
 * @return true if the geometry is a single polygon with no holes
 */
 private boolean isSingleShell(Geometry geom)
 {
 // handles single-element MultiPolygons, as well as Polygons
   if (geom.getNumGeometries() != 1) return false;
   
   Polygon poly = (Polygon) geom.getGeometryN(0);
   int numHoles = poly.getNumInteriorRing();
   if (numHoles == 0) return true;
   return false;
 }
  
origin: com.vividsolutions/jts

/**
 * Semantics for GeometryCollection is 
 * simple iff all components are simple.
 * 
 * @param geom
 * @return true if the geometry is simple
 */
private boolean isSimpleGeometryCollection(Geometry geom)
{
 for (int i = 0; i < geom.getNumGeometries(); i++ ) {
  Geometry comp = geom.getGeometryN(i);
  if (! computeSimple(comp))
   return false;
 }
 return true;
}
 
origin: com.vividsolutions/jts

private void computeMinDistanceOneMulti(Geometry g0, Geometry g1, boolean flip) {
  if (g1 instanceof GeometryCollection) {
    int n = g1.getNumGeometries();
    for (int i = 0; i < n; i++) {
      Geometry g = g1.getGeometryN(i);
      computeMinDistanceOneMulti(g0, g, flip);
      if (isDone)	return;
    }
  }
  else {
    computeMinDistance(g0, g1, flip);
  }
}
origin: com.vividsolutions/jts

private Geometry extractByEnvelope(Envelope env, Geometry geom, 
    List disjointGeoms)
{
  List intersectingGeoms = new ArrayList();
  for (int i = 0; i < geom.getNumGeometries(); i++) { 
    Geometry elem = geom.getGeometryN(i);
    if (elem.getEnvelopeInternal().intersects(env))
      intersectingGeoms.add(elem);
    else
      disjointGeoms.add(elem);
  }
  return geomFactory.buildGeometry(intersectingGeoms);
}
 
origin: com.vividsolutions/jts

  /**
   * Input is assumed to be a multiGeometry
   * in which every component has its userData
   * set to be a Coordinate which is the key to the output data.
   * The Coordinate is used to determine
   * the output data object to be written back into the component. 
   * 
   * @param targetGeom
   */
  public void transferData(Geometry targetGeom)
  {
    for (int i = 0; i < targetGeom.getNumGeometries(); i++) {
      Geometry geom = targetGeom.getGeometryN(i);
      Coordinate vertexKey = (Coordinate) geom.getUserData();
      if (vertexKey == null) continue;
      geom.setUserData(coordDataMap.get(vertexKey));
    }
  }
}
origin: com.vividsolutions/jts

private boolean computeInteracting(Geometry elem0)
{
  boolean interactsWithAny = false;
  for (int i = 0; i < g1.getNumGeometries(); i++) {
    Geometry elem1 = g1.getGeometryN(i);
    boolean interacts = elem1.getEnvelopeInternal().intersects(elem0.getEnvelopeInternal());
    if (interacts) interacts1[i] = true;
    if (interacts) 
      interactsWithAny = true;
  }
  return interactsWithAny;
}
 
origin: com.vividsolutions/jts

public void loadSourceGeometries(Geometry geomColl)
{
  for (int i = 0; i < geomColl.getNumGeometries(); i++) {
    Geometry geom = geomColl.getGeometryN(i);
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}
 
com.vividsolutions.jts.geomGeometrygetGeometryN

Javadoc

Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).

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
  • 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
  • buffer
    Computes a buffer area around this geometry having the given width and with a specified accuracy of
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • getSupportFragmentManager (FragmentActivity)
  • findViewById (Activity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JFrame (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • CodeWhisperer alternatives
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