Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Coordinate


    return intPt;
  }

  private static Coordinate average(Coordinate[] pts)
  {
    Coordinate avg = new Coordinate();
    int n = pts.length;
    for (int i = 0; i < pts.length; i++) {
      avg.x += pts[i].x;
      avg.y += pts[i].y;
    }
View Full Code Here


   * @return the point closest to the input point p
   */
  private Coordinate findNearestPoint(Coordinate p, Coordinate[] pts)
  {
    double minDist = Double.MAX_VALUE;
    Coordinate result = null;
    for (int i = 0; i < pts.length; i++) {
      double dist = p.distance(pts[i]);
      if (dist < minDist) {
        minDist = dist;
        result = pts[i];
View Full Code Here

   * or lies in the interior of a line segment in the linestring
   */
  public static boolean isOnLine(Coordinate p, Coordinate[] pt) {
    LineIntersector lineIntersector = new RobustLineIntersector();
    for (int i = 1; i < pt.length; i++) {
      Coordinate p0 = pt[i - 1];
      Coordinate p1 = pt[i];
      lineIntersector.computeIntersection(p, p0, p1);
      if (lineIntersector.hasIntersection()) {
        return true;
      }
    }
View Full Code Here

    // sanity check
    if (nPts < 3)
      throw new IllegalArgumentException("Ring has fewer than 3 points, so orientation cannot be determined");
   
    // find highest point
    Coordinate hiPt = ring[0];
    int hiIndex = 0;
    for (int i = 1; i <= nPts; i++) {
      Coordinate p = ring[i];
      if (p.y > hiPt.y) {
        hiPt = p;
        hiIndex = i;
      }
    }

    // find distinct point before highest point
    int iPrev = hiIndex;
    do {
      iPrev = iPrev - 1;
      if (iPrev < 0) iPrev = nPts;
    } while (ring[iPrev].equals2D(hiPt) && iPrev != hiIndex);

    // find distinct point after highest point
    int iNext = hiIndex;
    do {
      iNext = (iNext + 1) % nPts;
    } while (ring[iNext].equals2D(hiPt) && iNext != hiIndex);

    Coordinate prev = ring[iPrev];
    Coordinate next = ring[iNext];

    /**
     * This check catches cases where the ring contains an A-B-A configuration of points.
     * This can happen if the ring does not contain 3 distinct points
     * (including the case where the input array has fewer than 4 elements),
     * or it contains coincident line segments.
     */
    if (prev.equals2D(hiPt) || next.equals2D(hiPt) || prev.equals2D(next))
      return false;

    int disc = computeOrientation(prev, hiPt, next);

    /**
 
View Full Code Here

  public static double signedArea(CoordinateSequence ring)
  {
    int n = ring.size();
    if (n < 3) return 0.0;
         double sum = 0.0;
    Coordinate p = new Coordinate();
    ring.getCoordinate(0, p);
    double bx = p.x;
    double by = p.y;
         for (int i = 1; i < n; i++) {
      ring.getCoordinate(i, p);
View Full Code Here

    int n = pts.size();
    if (n <= 1) return 0.0;
   
    double len = 0.0;
   
    Coordinate p = new Coordinate();
    pts.getCoordinate(0, p);
    double x0 = p.x;
    double y0 = p.y;
   
    for (int i = 1; i < n; i++) {
View Full Code Here

   * of the SegmentString is normalized
   * to use the higher of the two possible segmentIndexes
   */
  public void addIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex)
  {
    Coordinate intPt = new Coordinate(li.getIntersection(intIndex));
    addIntersection(intPt, segmentIndex);
  }
View Full Code Here

    int normalizedSegmentIndex = segmentIndex;
    //Debug.println("edge intpt: " + intPt + " dist: " + dist);
    // normalize the intersection point location
    int nextSegIndex = normalizedSegmentIndex + 1;
    if (nextSegIndex < pts.length) {
      Coordinate nextPt = pts[nextSegIndex];
      //Debug.println("next pt: " + nextPt);

      // Normalize segment index if intPt falls on vertex
      // The check for point equality is 2D only - Z values are ignored
      if (intPt.equals2D(nextPt)) {
View Full Code Here

     * @param p1
     * @param p2
     * @return
     */
    public static Coordinate normalToTriangle(Coordinate p0, Coordinate p1, Coordinate p2) {
        Coordinate v1 = new Coordinate(p1.x - p0.x, p1.y - p0.y, p1.z - p0.z);
        Coordinate v2 = new Coordinate(p2.x - p0.x, p2.y - p0.y, p2.z - p0.z);
        Coordinate cp = crossProduct(v1, v2);
        normalize(cp);
        return cp;
    }
View Full Code Here

    public static Coordinate crossProduct(Coordinate v1, Coordinate v2) {
        double x = det(v1.y, v1.z, v2.y, v2.z);
        double y = -det(v1.x, v1.z, v2.x, v2.z);
        double z = det(v1.x, v1.y, v2.x, v2.y);
        return new Coordinate(x, y, z);
    }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.Coordinate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.