Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LineString


    public static boolean canSplitPolygon(Geometry geometryToSplit, UsefulSplitLineBuilder splitLineBuilder){


        assert geometryToSplit instanceof Polygon || geometryToSplit instanceof MultiPolygon;
       
        LineString originalSplitLine = splitLineBuilder.getOriginalSplitLine();
        // Get the boundary
        Geometry boundary = geometryToSplit.getBoundary();
        // check if the line is contained inside the geometry to be split.
        if (geometryToSplit.contains(originalSplitLine) && !boundary.intersects(originalSplitLine)) {
View Full Code Here


        List<LineString> segmentList = new GeometryList<LineString>();
       
        Coordinate[] ringCoords = ring.getCoordinates();
        for( int i = 0; i < ringCoords.length - 1; i++ ) {
           
            LineString segment = gf.createLineString(new Coordinate[]{ringCoords[i], ringCoords[i+1]});
            segmentList.add(segment);
        }
        return segmentList;
    }
View Full Code Here

  }

  @Override
  public String toString() {
    GeometryFactory fact = new GeometryFactory();
    LineString line = fact.createLineString(getCoordinates());
    return line.toString();
  }
View Full Code Here

        for( LineString segment : segmentList ) {
           
            // adapt the segment ring with the intersection points
            if(splitLine != null){
                Geometry intersection = splitLine.intersection(segment);
                LineString adaptedSegment = segment;
                if(intersection instanceof Point || intersection instanceof MultiPoint){
                    for( int i = 0; i < intersection.getNumGeometries(); i++ ) {
                        Point vertex = (Point) intersection.getGeometryN(i);
                        adaptedSegment = SplitUtil.insertVertexInLine(adaptedSegment, vertex.getCoordinate());
                    }
                }
                segmentMap.put(adaptedSegment.toText(), adaptedSegment );
            } else { // add the original segment
                segmentMap.put(segment.toText(), segment );
            }
        }
        return segmentMap;
View Full Code Here

        Map<String,LineString> segmentMap =  lookupRing(this.ringSegmentAdaptedAssociation, orignalRing);
        assert segmentMap != null: "inexistent ring"; //$NON-NLS-1$
       
        // search the segment to modify
        String wktSegment = originalRingSegment.toText();
        LineString adaptedSegment = segmentMap.get(wktSegment);
        assert adaptedSegment != null: "inexistent segment"; //$NON-NLS-1$

        LineString newAdaptedSegment = SplitUtil.insertVertexInLine(adaptedSegment, intersection);
       
        segmentMap.put(wktSegment, newAdaptedSegment);
    }
View Full Code Here

    LineSegment value = item.getValue();

    SpecificLineBuilder lineBuilder = new SpecificLineBuilder();

    // mount the line that will intersect with the preBuild geometry.
    LineString subjectLine = lineBuilder.mountTheLine(key, value, gf);

    relationSegmIntersect = getIntersectSegmentsData(subjectLine, preBuild, index, relationSegmIntersect);

    return relationSegmIntersect;
  }
View Full Code Here

        continue;

      Coordinate[] part = new Coordinate[2];
      part[0] = coords[i];
      part[1] = coords[i + 1];
      LineString segment = gf.createLineString(part);

      if (subjectLine.intersects(segment)) {

        // get the intersection coordinate
        Coordinate intersectionCoord = subjectLine.intersection(segment).getCoordinate();
View Full Code Here

    // check if the first segment and the last segment intersects.
    Coordinate[] firstSeg = new Coordinate[2];
    firstSeg[0] = arrayList.get(0);
    firstSeg[1] = arrayList.get(1);
    LineString first = gf.createLineString(firstSeg);

    Coordinate[] lastSeg = new Coordinate[2];
    lastSeg[0] = arrayList.get(arrayList.size() - 2);
    lastSeg[1] = arrayList.get(arrayList.size() - 1);
    LineString last = gf.createLineString(lastSeg);
    Coordinate intersectionCoord;
    if (first.intersects(last)) {

      intersectionCoord = first.intersection(last).getGeometryN(0).getCoordinate();
      if (!lastSeg[0].equals2D(intersectionCoord) && !lastSeg[1].equals2D(intersectionCoord)) {
View Full Code Here

     *            the {@link LineString} to be split.
     * @return the resultant geometry.
     */
    public List<Geometry> split(Geometry geomToSplit) {

      LineString lineString = (LineString) geomToSplit;
      LineString splitLine = getSplitLine().getOriginalSplitLine();
      Geometry result = lineString.difference(splitLine);

      List<Geometry> listLines = new ArrayList<Geometry>();
      // for each geometry, add to the list.
      for (int i = 0; i < result.getNumGeometries(); i++) {
View Full Code Here

    public boolean canSplit(Geometry lineString) {
       
        if (!(lineString instanceof LineString)){
      throw new IllegalArgumentException("LineString is spected"); //$NON-NLS-1$
            }
        LineString splitLine = getSplitLine().getOriginalSplitLine();
            return splitLine.intersects(lineString) ;
    }
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.