congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
com.vividsolutions.jts.geom
Code IndexAdd Tabnine to your IDE (free)

How to use com.vividsolutions.jts.geom

Best Java code snippets using com.vividsolutions.jts.geom (Showing top 20 results out of 2,313)

origin: opentripplanner/OpenTripPlanner

/** project this linestring to an equirectangular projection */
private static LineString equirectangularProject(LineString geometry, double xscale) {
  Coordinate[] coords = new Coordinate[geometry.getNumPoints()];
  for (int i = 0; i < coords.length; i++) {
    Coordinate c = geometry.getCoordinateN(i);
    c = (Coordinate) c.clone();
    c.x *= xscale;
    coords[i] = c;
  }
  return geometryFactory.createLineString(coords);
}
origin: opentripplanner/OpenTripPlanner

@Override
public boolean filter(Individual individual) {
  Coordinate coord = new Coordinate(individual.lon, individual.lat);
  Point pt = gf.createPoint(coord);
  boolean accept = hull.contains(pt);
  //LOG.debug("label {} accept {}", individual.label, accept);
  return accept;
}
origin: opentripplanner/OpenTripPlanner

public boolean matchesBackward(CoordinateSequence cs0, CoordinateSequence cs1) {
  if (cs0.size() != cs1.size())
    return false;
  int maxIdx = cs0.size() - 1;
  for (int i = 0; i <= maxIdx; i++)
    if (!cs0.getCoordinate(i).equals(cs1.getCoordinate(maxIdx - i)))
      return false;
  return true;
}
origin: opentripplanner/OpenTripPlanner

/**
 * Creates a circle shape, using the JTS buffer algorithm. The method is used when there is no street found within the given traveltime, e.g. when
 * the pointer is placed on a field or in the woods.<br>
 * TODO: Note it is actually not correct to do buffer calculation in Euclidian 2D, since the resulting shape will be elliptical when projected.
 * 
 * @param dropPoint the location given by the user
 * @param pathToStreet the path from the dropPoint to the street, used to retrieve the buffer distance
 * @return a Circle
 */
private Geometry createCirle(Coordinate dropPoint, LineString pathToStreet) {
  double length = pathToStreet.getLength();
  GeometryFactory gf = new GeometryFactory();
  Point dp = gf.createPoint(dropPoint);
  Geometry buffer = dp.buffer(length);
  return buffer;
}
origin: opentripplanner/OpenTripPlanner

/**
 * Returns this as a Coordinate object.
 * @return
 */
public Coordinate getCoordinate() {
  if (this.lat == null || this.lng == null) {
    return null;
  }
  return new Coordinate(this.lng, this.lat);
}

origin: osmandapp/Osmand

  private static int checkRepeatedPoints2d(LineString lineString) {
    int repeatedPoints = 0;

    final CoordinateSequence coordSeq = lineString.getCoordinateSequence();
    Coordinate nextCoord = null, prevCoord;
    for(int i = 0; i < coordSeq.size(); ++i) {
      prevCoord = nextCoord;
      nextCoord = coordSeq.getCoordinate(i);
      if(nextCoord.equals(prevCoord)) {
        ++repeatedPoints;
      }
    }

    return repeatedPoints;
  }
}
origin: opentripplanner/OpenTripPlanner

private Geometry crudeProjectedBuffer(Point pt, double distanceMeters) {
  final double mPerDegreeLat = 111111.111111;
  double lat = pt.getY();
  double lonScale = Math.cos(Math.PI * lat / 180);
  double latExpand = distanceMeters / mPerDegreeLat;
  double lonExpand = latExpand / lonScale;
  Envelope env = pt.getEnvelopeInternal();
  env.expandBy(lonExpand, latExpand);
  return gf.toGeometry(env);
}

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: opentripplanner/OpenTripPlanner

@Override
public int hashCode() {
  CoordinateSequence cs = ls.getCoordinateSequence();
  int maxIdx = cs.size() - 1;
  int x = (int) (cs.getX(0) * 1000000) + (int) (cs.getX(maxIdx) * 1000000);
  int y = (int) (cs.getY(0) * 1000000) + (int) (cs.getY(maxIdx) * 1000000);
  return x + y * 101149 + maxIdx * 7883;
}
origin: opentripplanner/OpenTripPlanner

  public Envelope expandEnvelope(Envelope env) {
    for (int i = 0; i < coords.length; i += dimension) {
      env.expandToInclude(coords[i], coords[i + 1]);
    }
    return env;
  }
}
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 void loadCurrentLine() {
  if (componentIndex >= numLines) {
    currentLine = null;
    return;
  }
  currentLine = (LineString) linearGeom.getGeometryN(componentIndex);
}
origin: opentripplanner/OpenTripPlanner

public boolean isValidIndex() {
  if (componentIndex >= numLines)
    return false;
  if (componentIndex == numLines - 1 && vertexIndex >= currentLine.getNumPoints())
    return false;
  return true;
}
origin: opentripplanner/OpenTripPlanner

/**
 * Gets the first {@link Coordinate} of the current segment. (the coordinate of the current
 * vertex).
 * 
 * @return a {@link Coordinate}
 */
public Coordinate getSegmentStart() {
  return currentLine.getCoordinateN(vertexIndex);
}
origin: opentripplanner/OpenTripPlanner

  @Override
  public int compare(Polygon o1, Polygon o2) {
    return o2.getNumPoints() - o1.getNumPoints();
  }
});
origin: osmandapp/Osmand

/**
 * Return true if the values of the two {@link Coordinate} are equal when their
 * first and second ordinates are cast as ints. Ignores 3rd ordinate.
 *
 * @param a first coordinate to compare
 * @param b second coordinate to compare
 * @return true if the values of the two {@link Coordinate} are equal when their
 * first and second ordinates are cast as ints
 */
private static boolean equalAsInts2d(Coordinate a, Coordinate b) {
  return ((int)a.getOrdinate(0)) == ((int)b.getOrdinate(0))
      && ((int)a.getOrdinate(1)) == ((int)b.getOrdinate(1));
}
origin: opentripplanner/OpenTripPlanner

/**
 * @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int)
 */
public Coordinate getCoordinateInternal(int i) {
  double x = coords[i * dimension];
  double y = coords[i * dimension + 1];
  double z = dimension == 2 ? 0.0 : coords[i * dimension + 2];
  return new Coordinate(x, y, z);
}
origin: opentripplanner/OpenTripPlanner

public Envelope expandEnvelope(Envelope env) {
  for (int i = 0; i < coords.length; i += dimension) {
    env.expandToInclude(coords[i], coords[i + 1]);
  }
  return env;
}
origin: opentripplanner/OpenTripPlanner

/**
 * @see com.vividsolutions.jts.geom.CoordinateSequence#getCoordinate(int)
 */
public Coordinate getCoordinateInternal(int i) {
  double x = coords[i * dimension];
  double y = coords[i * dimension + 1];
  double z = dimension == 2 ? 0.0 : coords[i * dimension + 2];
  return new Coordinate(x, y, z);
}
origin: opentripplanner/OpenTripPlanner

@Override
public Envelope expandEnvelope(Envelope env) {
  for (Coordinate c : coordinates) {
    env.expandToInclude(c);
  }
  return env;
}
com.vividsolutions.jts.geom

Most used classes

  • Geometry
    A representation of a planar, linear vector geometry. BINARY PREDICATES Because it is not clear at
  • GeometryFactory
    Supplies a set of utility methods for building Geometry objects from lists of Coordinates. Note that
  • Coordinate
    A lightweight class used to store coordinates on the 2-dimensional Cartesian plane. It is distinct f
  • Envelope
    Defines a rectangular region of the 2D coordinate plane. It is often used to represent the bounding
  • Point
    Represents a single point. A Point is topologically valid if and only if: * the coordinate which
  • LineString,
  • GeometryCollection,
  • MultiPolygon,
  • MultiLineString,
  • CoordinateSequence,
  • LinearRing,
  • MultiPoint,
  • PrecisionModel,
  • CoordinateSequenceFactory,
  • CoordinateArraySequence,
  • PreparedGeometryFactory,
  • LineSegment,
  • PreparedGeometry,
  • IntersectionMatrix
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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