Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineSegment


        double x2 = midPoint.x + dx;
        double y2 = midPoint.y + dy;
        Coordinate p1 = new Coordinate(x1, y1);
        Coordinate p2 = new Coordinate(x2, y2);

        LineSegment normalSegment = new LineSegment(p1, p2);
        return normalSegment;
    }
View Full Code Here


   *
   * @return the distance
   */
  private double calculateDistanceAndCurrentPostion() {

    LineSegment seg = new LineSegment();
    LineSegment closestSeg = new LineSegment();
    double distance, closestDistance = Double.MAX_VALUE;

    // get the closest segment.
    for (int i = 0; i < inputCoordinates.length - 1; i++) {
      seg.setCoordinates(inputCoordinates[i], inputCoordinates[i + 1]);
      distance = CGAlgorithms.distancePointLine(initialCoordinate, inputCoordinates[i], inputCoordinates[i + 1]);
      if (distance < closestDistance) {
        closestDistance = distance;
        closestSeg = new LineSegment(inputCoordinates[i], inputCoordinates[i + 1]);
      }
    }
    startPosition = Position.LEFT;
    int segmentOrientation = CGAlgorithms.computeOrientation(closestSeg.p0, closestSeg.p1, initialCoordinate);
    // offset position respect the first segment and the initial point.
View Full Code Here

  /**
   * Add an end cap around point p1, terminating a line segment coming from p0
   */
  public void addLineEndCap(Coordinate p0, Coordinate p1)
  {
    LineSegment seg = new LineSegment(p0, p1);

    LineSegment offsetL = new LineSegment();
    computeOffsetSegment(seg, Position.LEFT, distance, offsetL);
    LineSegment offsetR = new LineSegment();
    computeOffsetSegment(seg, Position.RIGHT, distance, offsetR);

    double dx = p1.x - p0.x;
    double dy = p1.y - p0.y;
    double angle = Math.atan2(dy, dx);
View Full Code Here

    double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
    double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
    Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
   
    // compute the mitre midline segment from the corner point to the bevel segment midpoint
    LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
   
    // finally the bevel segment endpoints are computed as offsets from
    // the mitre midline
    Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
    Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
   
    if (side == Position.LEFT) {
      segList.addPt(bevelEndLeft);
      segList.addPt(bevelEndRight);
    }
View Full Code Here

                // walk along the linestring until we get to a point where we
                // have two coordinates that straddle the midpoint
                double len = 0d;
                for (int i = 1; i < coords.length; i++) {
                    LineSegment line = new LineSegment(coords[i - 1], coords[i]);
                    len += line.getLength();

                    if (Math.abs(len - mid) < tol) {
                        // close enough
                        return line.getCoordinate(1);
                    }

                    if (len > mid) {
                        // we have gone past midpoint
                        return line.pointAlong(1 - ((len - mid) / line
                                .getLength()));
                    }
                }

                // should never get there
View Full Code Here

            // walk along the linestring until we get to a point where we
            // have two coordinates that straddle the midpoint
            double len = 0d;
            for (int i = 1; i < coords.length; i++) {
                LineSegment line = new LineSegment(coords[i - 1], coords[i]);
                len += line.getLength();

                if (Math.abs(len - mid) < tol) {
                    // close enough
                    return line.getCoordinate(1);
                }

                if (len > mid) {
                    // we have gone past midpoint
                    return line.pointAlong(1 - ((len - mid) / line
                                .getLength()));
                }
            }

            // should never get there
View Full Code Here

       }
    
     private void updatePts(Coordinate p, Coordinate seg0, Coordinate seg1)
     {
       minPts[0] = p;
       LineSegment seg = new LineSegment(seg0, seg1);
       minPts[1] = new Coordinate(seg.closestPoint(p));      
     }
View Full Code Here

  /**
   * Add an end cap around point p1, terminating a line segment coming from p0
   */
  public void addLineEndCap(Coordinate p0, Coordinate p1)
  {
    LineSegment seg = new LineSegment(p0, p1);

    LineSegment offsetL = new LineSegment();
    computeOffsetSegment(seg, Position.LEFT, distance, offsetL);
    LineSegment offsetR = new LineSegment();
    computeOffsetSegment(seg, Position.RIGHT, distance, offsetR);

    double dx = p1.x - p0.x;
    double dy = p1.y - p0.y;
    double angle = Math.atan2(dy, dx);
View Full Code Here

    double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
    double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
    Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
   
    // compute the mitre midline segment from the corner point to the bevel segment midpoint
    LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
   
    // finally the bevel segment endpoints are computed as offsets from
    // the mitre midline
    Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
    Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
   
    if (side == Position.LEFT) {
      segList.addPt(bevelEndLeft);
      segList.addPt(bevelEndRight);
    }
View Full Code Here

    } catch (TransformException e) {
      throw new RuntimeException(e.getMessage());
    }
    Coordinate p0 = new Coordinate(dst[0], dst[1]);
    Coordinate p1 = new Coordinate(dst[2], dst[3]);
    LineSegment lineSegment = new LineSegment(p0, p1);
    return lineSegment;
  }
View Full Code Here

TOP

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

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.