Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineString


        List<LineString> segmentList = new GeometryList<LineString>();

        Coordinate[] ringCoords = ring.getCoordinates();
        for( int i = 0; i < ringCoords.length - 1; i++ ) {

            LineString segment = this.geomFactory.createLineString(new Coordinate[]{ringCoords[i],
                    ringCoords[i + 1]});
            segmentList.add(segment);
        }

        return segmentList;
View Full Code Here


                    .get(segmentPosition);
            if (!segmentNode.getIntersectionList().isEmpty()) {

                Point point = segmentNode.searchNearestIntersection();
                IntersectionLink link = this.intersectionLinks.get(point);
                LineString ringSegment = link.getRingSegment();

                this.cursor = new IntersectCursor();
                this.cursor.setCurrentIntersection(segmentPosition, point, ringSegment);

                break;
View Full Code Here

        Point intersectionFound = node.searchNearestIntersectionFrom(lastVistedIntersection);
        if (intersectionFound != null) {
            // found a new intersection in the last visited segment

            IntersectionLink link = this.intersectionLinks.get(intersectionFound);
            LineString ringSegment = link.getRingSegment();

            this.cursor.setCurrentIntersection(lastVisitedSegment, intersectionFound, ringSegment);

            return;
        }

        // search an intersection in the rest of segments
        for( int i = lastVisitedSegment + 1; i < this.splitLineSegmentWithIntersectionList.size(); i++ ) {

            node = this.splitLineSegmentWithIntersectionList.get(i);

            for( Point currentIntersection : node.getIntersectionList() ) {

                if ((currentIntersection != null)
                        && (!lastVistedIntersection.equals(currentIntersection))) {
                    // found an intersection in the current segment
                    IntersectionLink link = this.intersectionLinks.get(currentIntersection);
                    LineString ringSegment = link.getRingSegment();
                    this.cursor.setCurrentIntersection(i, currentIntersection, ringSegment);

                    return;
                }
            }
View Full Code Here

            coordinates.add(secondIntersection );
        }

        // build the line string
        Coordinate[] coordsArray = coordinates.toArray(new Coordinate[coordinates.size()]);
        LineString newLine = this.geomFactory.createLineString(coordsArray);

        return newLine;
    }
View Full Code Here

                }
            }
        }
        // build the line string
        Coordinate[] coordinates = coordinatList.toArray(new Coordinate[coordinatList.size()]);
        LineString splitLineFragment = this.geomFactory.createLineString(coordinates);

        return splitLineFragment;
    }
View Full Code Here

            }
        }
       
        // build the line string
        Coordinate[] coordinates = coordinatList.toArray(new Coordinate[coordinatList.size()]);
        LineString splitLineFragment = this.geomFactory.createLineString(coordinates);

        return splitLineFragment;
    }
View Full Code Here

      GeometryFactory gf = input.getFactory();

      int numGeometries = input.getNumGeometries();
      LineString[] lines = new LineString[numGeometries];
      for (int i = 0; i < numGeometries; i++) {
        LineString part = (LineString) input.getGeometryN(i);
        LineString trimmedPart = trimLine(part, trimmingLine);
        lines[i] = trimmedPart;
      }
      trimmed = gf.createMultiLineString(lines);
    } else {
View Full Code Here

          : intersectionPoint;

    // split the line at the intersection point
    Geometry difference = original.difference(trimmingLine);

    LineString splitLine1;
    LineString splitLine2;
    if (difference instanceof MultiLineString) {
      splitLine1 = (LineString) difference.getGeometryN(0);
      splitLine2 = (LineString) difference.getGeometryN(1);
    } else if (difference instanceof LineString) {
      // original touches trimmingLine but does not crosses it
      splitLine1 = (LineString) difference;
      splitLine2 = difference.getFactory().createLineString(new Coordinate[0]);
    } else {
      throw new IllegalStateException(Messages.TrimGeometryStrategy_difference_unknown_type + difference);
    }

    Coordinate firstLinePoint = getCoordinateBeforePoint(splitLine1, intersectionPoint);
    if (firstLinePoint.equals2D(intersectionPoint)) {
      // same case as the comment for line1, or computeOrientation will
      // return COLLINEAR,
      // and we'll have no way to tell wether the line is at the right or
      // the left
      firstLinePoint = splitLine1.getCoordinateN(1);
    }

    final int firstLineOrientation = CGAlgorithms.computeOrientation(lineFrom, lineTo, firstLinePoint);

    LineString lineAtTheRight;

    // return the segment at the left of the intersection point
    if (CGAlgorithms.CLOCKWISE == firstLineOrientation) {
      lineAtTheRight = splitLine2;
    } else {
View Full Code Here

    @Test
    public void testcatalog_01() throws Exception {
  Polygon polygon = (Polygon) SplitTestUtil
    .read("POLYGON ((70 270, 190 270, 190 170, 70 170, 70 270))"); //$NON-NLS-1$

  LineString splitLine = (LineString) SplitTestUtil
    .read("LINESTRING (90 250, 170 250, 170 190, 90 190, 90 250)"); //$NON-NLS-1$

  Geometry partA = SplitTestUtil
    .read("POLYGON ((70 270, 190 270, 190 170, 70 170, 70 270),  (90 250, 170 250, 170 190, 90 190, 90 250, 90 250, 90 250))"); //$NON-NLS-1$
  Geometry partB = SplitTestUtil
View Full Code Here

    @Test
    public void testcatalog_02() throws Exception {
  Polygon polygon = (Polygon) SplitTestUtil
    .read("POLYGON ((70 270, 190 270, 190 170, 70 170, 70 270),  (90 250, 170 250, 170 190, 90 190, 90 250, 90 250, 90 250))"); //$NON-NLS-1$

  LineString splitLine = (LineString) SplitTestUtil
    .read("LINESTRING (120 210, 120 180, 90 180, 90 190)"); //$NON-NLS-1$

  assertFalse(SplitUtil.isClosedLine(splitLine));

  Geometry partA = SplitTestUtil
View Full Code Here

TOP

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

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.