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

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

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

origin: opentripplanner/OpenTripPlanner

/**
 * Returns the length of the geometry in meters.
 *
 * @param geometry
 * @return
 */
private double getGeometryLengthMeters(Geometry geometry) {
  Coordinate[] coordinates = geometry.getCoordinates();
  double d = 0;
  for (int i = 1; i < coordinates.length; ++i) {
    d += SphericalDistanceLibrary.distance(coordinates[i - 1], coordinates[i]);
  }
  return d;
}
origin: opentripplanner/OpenTripPlanner

@Override
public void serialize(Geometry arg, JsonGenerator jgen, SerializerProvider provider)
    throws IOException, JsonProcessingException {
  
  if (arg == null) {
    jgen.writeNull();
  }
  Coordinate[] lineCoords = arg.getCoordinates();
  List<Coordinate> coords = Arrays.asList(lineCoords);
  
  jgen.writeObject(PolylineEncoder.createEncodings(coords).getPoints());
}
origin: opentripplanner/OpenTripPlanner

@JsonSerialize(using = EncodedPolylineJSONSerializer.class)
@XmlJavaTypeAdapter(LineStringAdapter.class)
public LineString getGeometry() {
  if (geometry == null) {
    List<Coordinate> coords = new ArrayList<Coordinate>();
    for (RouteSegment segment : exemplarSegments) {
      if (segment.hopOut != null) {
        Geometry segGeometry = segment.getGeometry();
        coords.addAll(Arrays.asList(segGeometry.getCoordinates()));
      }
    }
    Coordinate[] coordArray = new Coordinate[coords.size()];
    geometry = GeometryUtils.getGeometryFactory().createLineString(
        coords.toArray(coordArray));
  }
  return geometry;
}

origin: opentripplanner/OpenTripPlanner

private Geometry removeDuplicatePoints(Geometry routeGeometry) {
  List<Coordinate> coords = new ArrayList<Coordinate>();
  Coordinate last = null;
  for (Coordinate c : routeGeometry.getCoordinates()) {
    if (!c.equals(last)) {
      last = c;
      coords.add(c);
    }
  }
  if (coords.size() < 2) {
    return null;
  }
  Coordinate[] coordArray = new Coordinate[coords.size()];
  return routeGeometry.getFactory().createLineString(coords.toArray(coordArray));
}
origin: opentripplanner/OpenTripPlanner

/**
 * @param index The index of the segment in the list
 * @return The partial geometry between this segment's stop and the next one.
 */
public LineString getGeometrySegment(int index) {
  RouteSegment segment = exemplarSegments.get(index);
  if (segment.hopOut != null) {
    return GeometryUtils.getGeometryFactory().createLineString(
        segment.getGeometry().getCoordinates());
  }
  return null;
}
origin: osmandapp/Osmand

final Coordinate[] geomCoords = geom.getCoordinates();
if(geomCoords.length <= 0) {
  Collections.emptyList();
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: opentripplanner/OpenTripPlanner

Coordinate[] coords = g.getCoordinates();
origin: osmandapp/Osmand

  final int minLineToLen) {
final Coordinate[] geomCoords = geom.getCoordinates();
origin: opentripplanner/OpenTripPlanner

  continue;
for (Coordinate c : g.getCoordinates()) {
  if (Double.isNaN(c.x) || Double.isNaN(c.y)) {
    LOG.warn(graph.addBuilderAnnotation(new BogusEdgeGeometry(e)));
  Coordinate edgeStartCoord = e.getFromVertex().getCoordinate();
  Coordinate edgeEndCoord = e.getToVertex().getCoordinate();
  Coordinate[] geometryCoordinates = g.getCoordinates();
  if (geometryCoordinates.length < 2) {
    LOG.warn(graph.addBuilderAnnotation(new BogusEdgeGeometry(e)));
origin: opentripplanner/OpenTripPlanner

Geometry geometry = s1.getBackEdge().getGeometry();
if (geometry != null) {
  List<Coordinate> coordinates = new ArrayList<Coordinate>(Arrays.asList(geometry.getCoordinates()));
  for (int i = 0; i < coordinates.size(); ++i) {
    Coordinate coordinate = new Coordinate(coordinates.get(i));
origin: opentripplanner/OpenTripPlanner

OffsetCurveBuilder offsetBuilder = new OffsetCurveBuilder(new PrecisionModel(),
    bufParams);
Coordinate[] coords = offsetBuilder.getOffsetCurve(midLineGeom.getCoordinates(),
    lineWidth * 0.4);
if (coords.length < 2)
origin: opentripplanner/OpenTripPlanner

coords = circleShape.getCoordinates();
origin: com.vividsolutions/jts

public Coordinate[] extractTargetCoordinates(Geometry g)
{
 // TODO: should do this more efficiently.  Use CoordSeq filter to get points, KDTree for uniqueness & queries
 Set ptSet = new TreeSet();
 Coordinate[] pts = g.getCoordinates();
 for (int i = 0; i < pts.length; i++) {
  ptSet.add(pts[i]);
 }
 return (Coordinate[]) ptSet.toArray(new Coordinate[0]);
}
 
origin: opentripplanner/OpenTripPlanner

/**
 * Splits the input geometry into two LineStrings at a fraction of the distance covered.
 */
public static P2<LineString> splitGeometryAtFraction(Geometry geometry, double fraction) {
  LineString empty = new LineString(null, gf);
  Coordinate[] coordinates = geometry.getCoordinates();
  CoordinateSequence sequence = gf.getCoordinateSequenceFactory().create(coordinates);
  LineString total = new LineString(sequence, gf);
  if (coordinates.length < 2) return new P2<LineString>(empty, empty);
  if (fraction <= 0) return new P2<LineString>(empty, total);
  if (fraction >= 1) return new P2<LineString>(total, empty);
  double totalDistance = total.getLength();
  double requestedDistance = totalDistance * fraction;
  // An index in JTS can actually refer to any point along the line. It is NOT an array index.
  LocationIndexedLine line = new LocationIndexedLine(geometry);
  LinearLocation l = LengthLocationMap.getLocation(geometry, requestedDistance);
  LineString beginning = (LineString) line.extractLine(line.getStartIndex(), l);
  LineString ending = (LineString) line.extractLine(l, line.getEndIndex());
  return new P2<LineString>(beginning, ending);
}
origin: com.vividsolutions/jts

private void createVertices(Geometry geom)
{
  Coordinate[] coords = geom.getCoordinates();
  for (int i = 0; i < coords.length; i++) {
    Vertex v = new ConstraintVertex(coords[i]);
    constraintVertexMap.put(coords[i], v);
  }
}
 
origin: com.vividsolutions/jts

public void loadSourceGeometries(Collection geoms)
{
  for (Iterator i = geoms.iterator(); i.hasNext(); ) {
    Geometry geom = (Geometry) i.next();
    loadVertices(geom.getCoordinates(), geom.getUserData());
  }
}
 
origin: com.vividsolutions/jts

/**
 * Extracts the unique {@link Coordinate}s from the given {@link Geometry}.
 * @param geom the geometry to extract from
 * @return a List of the unique Coordinates
 */
public static CoordinateList extractUniqueCoordinates(Geometry geom)
{
  if (geom == null)
    return new CoordinateList();
  
  Coordinate[] coords = geom.getCoordinates();
  return unique(coords);
}
 
origin: com.vividsolutions/jts

public final Geometry edit(Geometry geometry, GeometryFactory factory) {
 if (geometry instanceof LinearRing) {
  return factory.createLinearRing(edit(geometry.getCoordinates(),
    geometry));
 }
 if (geometry instanceof LineString) {
  return factory.createLineString(edit(geometry.getCoordinates(),
    geometry));
 }
 if (geometry instanceof Point) {
  Coordinate[] newCoordinates = edit(geometry.getCoordinates(),
    geometry);
  return factory.createPoint((newCoordinates.length > 0)
                ? newCoordinates[0] : null);
 }
 return geometry;
}
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.geomGeometrygetCoordinates

Javadoc

Returns an array containing the values of all the vertices for this geometry. If the geometry is a composite, the array will contain all the vertices for the components, in the order in which the components occur in the geometry.

In general, the array cannot be assumed to be the actual internal storage for the vertices. Thus modifying the array may not modify the geometry itself. Use the CoordinateSequence#setOrdinate method (possibly on the components) to modify the underlying data. If the coordinates are modified, #geometryChanged must be called afterwards.

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • 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
  • 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

  • Finding current android device location
  • startActivity (Activity)
  • getApplicationContext (Context)
  • getSystemService (Context)
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JTable (javax.swing)
  • JTextField (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • From CI to AI: The AI layer in your organization
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