Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineSegment


       }
    
     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


        double dist = CGAlgorithms3D.distanceSegmentSegment(coord0[i],
            coord0[i + 1], coord1[j], coord1[j + 1]);
        if (dist < minDistance) {
          minDistance = dist;
          // TODO: compute closest pts in 3D
          LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]);
          LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]);
          Coordinate[] closestPt = seg0.closestPoints(seg1);
          updateDistance(dist,
              new GeometryLocation(line0, i, closestPt[0]),
              new GeometryLocation(line1, j, closestPt[1]),
              flip
View Full Code Here

    // brute force approach!
    for (int i = 0; i < lineCoord.length - 1; i++) {
      double dist = CGAlgorithms3D.distancePointSegment(coord, lineCoord[i],
          lineCoord[i + 1]);
      if (dist < minDistance) {
        LineSegment seg = new LineSegment(lineCoord[i], lineCoord[i + 1]);
        Coordinate segClosestPoint = seg.closestPoint(coord);
        updateDistance(dist,
            new GeometryLocation(line, i, segClosestPoint),
            new GeometryLocation(point, 0, coord),
            flip);
      }
View Full Code Here

      Coordinate seg0, Coordinate seg1)
  {
    if (candidateValue < minClearance) {
      minClearance = candidateValue;
      minClearancePts[0] = new Coordinate(p);
      LineSegment seg = new LineSegment(seg0, seg1);
      minClearancePts[1] = new Coordinate(seg.closestPoint(p));
    }
  }
View Full Code Here

     * @param seg the encroached segment
     * @param encroachPt the encroaching point
     * @return the point at which to split the encroached segment
     */
    public Coordinate findSplitPoint(Segment seg, Coordinate encroachPt) {
        LineSegment lineSeg = seg.getLineSegment();
        double segLen = lineSeg.getLength();
        double midPtLen = segLen / 2;
        SplitSegment splitSeg = new SplitSegment(lineSeg);

        Coordinate projPt = projectedSplitPoint(seg, encroachPt);
        /**
 
View Full Code Here

     * @param seg
     * @param encroachPt
     * @return a split point on the segment
     */
    public static Coordinate projectedSplitPoint(Segment seg, Coordinate encroachPt) {
        LineSegment lineSeg = seg.getLineSegment();
        Coordinate projPt = lineSeg.project(encroachPt);
        return projPt;
    }
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

    qeSorted.putAll(qeDistances);

    // edges creation
    int i = 0;
    for (QuadEdge qe : qeSorted.keySet()) {
      LineSegment s = qe.toLineSegment();
      s.normalize();
     
      Integer idS = this.coordinates.get(s.p0);
      Integer idD = this.coordinates.get(s.p1);
      Vertex oV = this.vertices.get(idS);
      Vertex eV = this.vertices.get(idD);
     
      Edge edge;
      if (qeBorder.contains(qe)) {
        oV.setBorder(true);
        eV.setBorder(true);
        edge = new Edge(i, s, oV, eV, true);
        if (s.getLength() < this.threshold) {
          this.shortLengths.put(i, edge);
        } else {
          this.lengths.put(i, edge);
        }
      } else {
        edge = new Edge(i, s, oV, eV, false);
      }
      this.edges.put(i, edge);
      this.segments.put(s, i);
      i++;
    }

    // hm of linesegment and hm of edges // with id as key
    // hm of triangles using hm of ls and connection with hm of edges
   
    i = 0;
    for (QuadEdgeTriangle qet : qeTriangles) {
      LineSegment sA = qet.getEdge(0).toLineSegment();
      LineSegment sB = qet.getEdge(1).toLineSegment();
      LineSegment sC = qet.getEdge(2).toLineSegment();
      sA.normalize();
      sB.normalize();
      sC.normalize();
     
      Edge edgeA = this.edges.get(this.segments.get(sA));
      Edge edgeB = this.edges.get(this.segments.get(sB));
      Edge edgeC = this.edges.get(this.segments.get(sC));
      if (edgeA == null || edgeB == null || edgeC == null)
View Full Code Here

  public void test_0() {
    final Coordinate base = new Coordinate(0d,0d);
    final int n = 100;
    for (int i = 1; i <= n; i++) {
      Edge e = (Edge)generator().add(
        new LineSegment(
          new Coordinate(base.x + (i-1), base.y + (i-1)),
          new Coordinate(base.x + i, base.y + i)
        )
      )
    }
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.