Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Polygon


        assertEquals(new Coordinate(90.5,95.5), map.getCoords(100,100).get(0));
        assertEquals(1, map.getCoords(50,150).size());
        assertEquals(new Coordinate(40.5,145.5), map.getCoords(50,150).get(0));

        //insert a vertex in a hole
        Polygon polygon=createPolygon(factory, 10);
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        mapping = map.setGeometries(polygon, null);
        assertPixMapState(map,1,5,1,5);
       
View Full Code Here


        // delete nothing
        modified=map.removeCoordsAtPoint(0,0);
        assertEquals(0, modified.size());
       
        // make sure this works on holes
        Polygon poly = createPolygon(factory, 10);
        mapping=map.setGeometries(poly, null);
        modified=map.removeCoordsAtPoint(25,12);
        assertEquals(2, modified.size());
        assertEquals(3,mapping.get(poly).getHoles().get(0).getNumCoords());
        assertEquals(new Coordinate(15,7), modified.get(0));
View Full Code Here

                bounds.getMaxY()+(bounds.getHeight()/4), DefaultGeographicCRS.WGS84 );
        EditBlackboard map=new EditBlackboard(SCREEN.x, SCREEN.y, ScaleUtils.worldToScreenTransform(bounds, new Dimension(100,100)), layerToWorld);
       
        map.setGeometries((Geometry) feature.getDefaultGeometry(), null);
       
        Polygon poly=(Polygon) ((MultiPolygon) feature.getDefaultGeometry()).getGeometryN(0);
       
        PrimitiveShape shell = map.getGeoms().get(0).getShell();
        assertEquals(poly.getExteriorRing().getCoordinates().length, shell.getNumCoords());
        for (int i=0; i<shell.getNumCoords(); i++){
            assertEquals("i="+i, poly.getExteriorRing().getCoordinateN(i), shell.getCoord(i)); //$NON-NLS-1$
        }
        assertEquals(shell.getCoord(0), shell.getCoord(shell.getNumCoords()-1));
        assertEquals(shell.getPoint(0), shell.getPoint(shell.getNumPoints()-1));
       
        List<PrimitiveShape> holes = map.getGeoms().get(0).getHoles();
       
        for( int j=0; j<holes.size(); j++ ) {
            PrimitiveShape hole = holes.get(j);
            for (int i=0; i<hole.getNumCoords(); i++){
                assertEquals("hole="+j+"i="+i, poly.getInteriorRingN(j).getCoordinateN(i), hole.getCoord(i)); //$NON-NLS-1$ //$NON-NLS-2$
            }           
            assertEquals(hole.getCoord(0), hole.getCoord(hole.getNumCoords()-1));
            assertEquals(hole.getPoint(0), hole.getPoint(hole.getNumPoints()-1));
        }
    }
View Full Code Here

    }
   
    @Test
    public void testSetTransform() throws Exception {
        GeometryFactory factory=new GeometryFactory();
        Polygon poly = createPolygon(factory, 10);
        EditBlackboard map = new EditBlackboard(SCREEN.x, SCREEN.y, transform, layerToWorld);
        Map<Geometry, EditGeom> mapping = map.setGeometries(poly, null);
        EventListener l=new EventListener();
        map.getListeners().add(l);
       
View Full Code Here

    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();
     
      bb.moveCoords(10, 10, 0, 10);
View Full Code Here

    public void setUp() throws Exception {
        GeometryFactory fac=new GeometryFactory();
        LineString line = fac.createLineString(new Coordinate[]{
           new Coordinate(0,10),new Coordinate(10,10), new Coordinate(20,10)
        });
        Polygon poly = fac.createPolygon(fac.createLinearRing(new Coordinate[]{
                new Coordinate(20,20),new Coordinate(40,20), new Coordinate(40,40),
                new Coordinate(20,40), new Coordinate(20,20)
             }), new LinearRing[0]);
   
        handler=new TestHandler();
View Full Code Here

                new Coordinate(50,50),
                new Coordinate(50,55),
                new Coordinate(0,55),
                new Coordinate(0,50),
        });
        Polygon polygon = fac.createPolygon(ring, new LinearRing[0]);
        FeatureStore<SimpleFeatureType, SimpleFeature> store = map.getMapLayers().get(0).getResource(FeatureStore.class, new NullProgressMonitor());       
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    store.modifyFeatures(features[0].getFeatureType().getGeometryDescriptor(), polygon,
                filterFactory.id(FeatureUtils.stringToId(filterFactory, features[0].getID())));
   
View Full Code Here

                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),
        });
        Polygon polygon2 = fac.createPolygon(ring2, new LinearRing[0]);

        Geometry geom=fac.createMultiPolygon(new Polygon[]{polygon1, polygon2});
       
        FeatureStore<SimpleFeatureType, SimpleFeature> store = map.getMapLayers().get(0).getResource(FeatureStore.class, new NullProgressMonitor());
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
View Full Code Here

 
            if (intersectionPonts.getNumGeometries() >=2 ) {
              // checks if it is possible to build an useful split line
                for (int j = 0; j < geometryToSplit.getNumGeometries(); j++) {
 
                Polygon currentPolygon = (Polygon) geometryToSplit.getGeometryN(j);
   
                AdaptedPolygon adaptedPolygon = new AdaptedPolygon(currentPolygon);
                Geometry usefulSplitLines = splitLineBuilder.createUsefulSplitLine(originalSplitLine, adaptedPolygon);
   
                if (usefulSplitLines != null) {
View Full Code Here

                LinearRing holeRing = buildAdaptedRing(currentRing);

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

        return polygon;
    }
View Full Code Here

TOP

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

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.