Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LinearRing


    @Test
    public void testMovePointOnGeometry() throws Exception {
      GeometryFactory fac = new GeometryFactory();
     
      double[] coords = new double[]{10,10, 10,20, 10,30, 30,30, 20,30, 10,10};
    LinearRing ring = fac.createLinearRing(new PackedCoordinateSequenceFactory().create(coords , 2));
      Polygon poly = fac.createPolygon(ring, new LinearRing[0]);
     
      bb.clear();
      geom =  bb.addGeometry(poly, "poly").values().iterator().next();
     
View Full Code Here


    @Test
    public void testDiffOnMultipleGeoms() throws Exception {
        handler.resetEditBlackboard();
        GeometryFactory fac=new GeometryFactory();
        LinearRing ring=fac.createLinearRing(new Coordinate[]{
                new Coordinate(0,50),
                new Coordinate(50,50),
                new Coordinate(50,55),
                new Coordinate(0,55),
                new Coordinate(0,50),
View Full Code Here

   
    @Test
    public void testMultiGeometry() throws Exception {
        handler.resetEditBlackboard();
        GeometryFactory fac=new GeometryFactory();
        LinearRing ring1=fac.createLinearRing(new Coordinate[]{
                new Coordinate(0,0),
                new Coordinate(50,0),
                new Coordinate(50,10),
                new Coordinate(0,10),
                new Coordinate(0,0),
        });
        Polygon polygon1 = fac.createPolygon(ring1, new LinearRing[0]);

        LinearRing ring2=fac.createLinearRing(new Coordinate[]{
                new Coordinate(0,50),
                new Coordinate(50,50),
                new Coordinate(50,60),
                new Coordinate(0,60),
                new Coordinate(0,50),
View Full Code Here

  List<LinearRing> rings = new GeometryList<LinearRing>();
  for (int j = 0; j < polygon.getNumInteriorRing(); j++) {

      // get an interior ring.
      LinearRing interiorRing = (LinearRing) polygon.getInteriorRingN(j);

      // add the rings that intersects with the segment.
      if (interiorRing.intersects(segment)) {
    rings.add(interiorRing);
      }
  }

  return rings;
View Full Code Here

        // add the first coordinate has last coordinate in order to close the ring
        coordList.add(coordList.get(0));
        Coordinate[] linearRingCoords =  coordList.toArray(new Coordinate[ coordList.size() ]);
       
        GeometryFactory factory = adaptedRingSegmentList.get(0).getFactory();
        LinearRing ring = factory.createLinearRing(linearRingCoords);
      
        return ring;
    }
View Full Code Here

       
        duplicated.ringSegmentAdaptedAssociation  = new LinkedHashMap<LinearRing, Map<String,LineString>>();
       
         for( Entry<LinearRing, Map<String,LineString>> ringSegmentEntry : this.ringSegmentAdaptedAssociation.entrySet() ) {
            
             LinearRing ring = ringSegmentEntry.getKey();
            
             Map<String, LineString> newSegmentMap = new LinkedHashMap<String, LineString>();
             Map<String, LineString> sourceSegmentMap = ringSegmentEntry.getValue();
            
             for( Entry<String, LineString> segmentEntry: sourceSegmentMap.entrySet() ) {
View Full Code Here

     * @param splitLine
     */
    private void initSegmentAssociation(final Polygon originalPolygon, final LineString splitLine){

        // Extract exterior and interior rings. The ring is exploded in its segments and added in the association
        LinearRing exteriorRing = (LinearRing)this.originalPolygon.getExteriorRing();
        Map<String, LineString> exteriorSegments = createSegmentAdaptedAssociation(exteriorRing, splitLine);
        this.ringSegmentAdaptedAssociation.put(exteriorRing, exteriorSegments);
       
        for(int i = 0; i < this.originalPolygon.getNumInteriorRing(); i++){

            LinearRing interiorRing = (LinearRing)this.originalPolygon.getInteriorRingN(i);
           
            Map<String, LineString> interiorSegments = createSegmentAdaptedAssociation(interiorRing, splitLine);
            this.ringSegmentAdaptedAssociation.put( interiorRing, interiorSegments);
        }
    }
View Full Code Here

     * @return new instance of polygon adapted polygon
     */
    public Polygon asPolygon() {

        // makes the exterior ring using the modified segments
        LinearRing originalExteriorRing = (LinearRing) this.originalPolygon.getExteriorRing();
       
        LinearRing exteriorRing = buildAdaptedRing(originalExteriorRing);
       
        // makes the interior rings using the modified hole segments
        final Set<Entry<LinearRing, Map<String,LineString>>> entrySet = this.ringSegmentAdaptedAssociation.entrySet();
       
        LinearRing[] holes = new LinearRing[entrySet.size()-1];
        int i = 0;
        for( Entry<LinearRing, Map<String, LineString>> entry : entrySet  ) {
           
            LinearRing currentRing = entry.getKey();
            if( ! currentRing.equals(originalExteriorRing) ){
                // it is an interior ring (hole)
                LinearRing holeRing = buildAdaptedRing(currentRing);

                holes[i++] = holeRing;
            }
        }
        Polygon polygon = this.geomFactory.createPolygon(exteriorRing, holes);
View Full Code Here

        final Map<String, LineString> exteriorAdaptedSegment = lookupRing(this.ringSegmentAdaptedAssociation, ring);
        assert exteriorAdaptedSegment != null;

        // Extracts the coordinates of the adapted segments
        List<LineString> values = new GeometryList<LineString>( exteriorAdaptedSegment.values() );
        LinearRing newRing = RingUtil.segmentListToRing( values );

        return newRing;
    }
View Full Code Here

     * @param originalRing
     * @return the adapted ring
     */
    public LinearRing getAdaptedRingOf( LinearRing originalRing ) {
       
        LinearRing adaptedRing = buildAdaptedRing(originalRing);
       
        return adaptedRing;
    }
View Full Code Here

TOP

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

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.