Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LinearRing


     */
    public Polygon polygon( int[] xy, int[] holes[] ) {
        if (holes == null || holes.length == 0) {
            return polygon(xy);
        }
        LinearRing shell = ring(xy);

        LinearRing[] rings = new LinearRing[holes.length];

        for( int i = 0; i < xy.length; i++ ) {
            rings[i] = ring(holes[i]);
View Full Code Here


     * @throws Exception
     */
    @Test
    public void testSetTransformScale() throws Exception {
        GeometryFactory factory = new GeometryFactory();
        LinearRing linearRing = factory.createLinearRing(new Coordinate[]{
                new Coordinate(10, 10),
                new Coordinate(10, 20.5),
                new Coordinate(10, 20),
                new Coordinate(20, 20),
                new Coordinate(10, 10)
View Full Code Here

   
    @Test
    public void testSetGeometries() throws Exception {
        GeometryFactory factory = new GeometryFactory();
        int offset=0;
        LinearRing linearRing = factory.createLinearRing(new Coordinate[]{
                new Coordinate(offset+5, 7),
                new Coordinate(offset+8, 7),
                new Coordinate(offset+8, 8),
                new Coordinate(offset+5, 8),
                new Coordinate(offset+5, 7)
View Full Code Here

        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(2, ((List) editBlackboardEvent.getNewValue()).size());
        assertEquals(map, editBlackboardEvent.getSource());


        LinearRing ring = createShellRing(factory, 10);
       
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        mapping=map.setGeometries(ring, null);
        assertEquals(ShapeType.LINE, mapping.get(ring).getShapeType());
View Full Code Here

    }
   
    @Test
    public void testGetCandidate() throws Exception {
        GeometryFactory factory=new GeometryFactory();
        LinearRing ring1=createShellRing(factory, 10);
        LinearRing ring2=createShellRing(factory, 30);
        LinearRing ring3=createShellRing(factory, 32);
        EditBlackboard map = new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        Map<Geometry, EditGeom> mapping = map.setGeometries(ring1, null);
        mapping.putAll(map.addGeometry(ring2, null));
        mapping.putAll(map.addGeometry(ring3, null));
        assertPixMapState(map,3,5,0,0);
View Full Code Here

        assertEquals(EventType.ADD_POINT, l.getEditBlackboardEvent().getType());
        EditBlackboardEvent editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(10,5), editBlackboardEvent.getNewValue());
       
        LinearRing ring = createShellRing(factory, 10);
       
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        Map<Geometry, EditGeom> mapping = map.setGeometries(ring, null);
        assertPixMapState(map,1,5,0,0);
       
        //add at a particular index.
        map.insertCoord(25,15, 3, mapping.get(ring).getShell());
        assertEquals(Point.valueOf(20,10),mapping.get(ring).getShell().getPoint(0));
        assertEquals(Point.valueOf(30,10),mapping.get(ring).getShell().getPoint(1));
        assertEquals(Point.valueOf(30,15),mapping.get(ring).getShell().getPoint(2));
        assertEquals(Point.valueOf(25,15),mapping.get(ring).getShell().getPoint(3));
        assertEquals(Point.valueOf(20,15),mapping.get(ring).getShell().getPoint(4));
        assertEquals(EventType.ADD_POINT, l.event.getType());
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(25,15), editBlackboardEvent.getNewValue());
        assertEquals(mapping.get(ring).getShell(), editBlackboardEvent.getSource());

        //create a geom one point at a time   test ordering of geometries
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        geomShape = map.getGeoms().get(0);
        map.addPoint(0,0, geomShape.getShell());
        map.addPoint(0,100, geomShape.getShell());
        map.addPoint(50,100, geomShape.getShell());
        map.addPoint(100,100, geomShape.getShell());
        map.addPoint(50,150, geomShape.getShell());
       
        assertEquals(Point.valueOf(0,0), geomShape.getShell().getPoint(0));
        assertEquals(Point.valueOf(0,100), geomShape.getShell().getPoint(1));
        assertEquals(Point.valueOf(50,100), geomShape.getShell().getPoint(2));
        assertEquals(Point.valueOf(100,100), geomShape.getShell().getPoint(3));
        assertEquals(Point.valueOf(50,150), geomShape.getShell().getPoint(4));

        //test the coordinates were created correcly
        assertEquals(new Coordinate(-9.5,-4.5), geomShape.getShell().getCoord(0));
        assertEquals(new Coordinate(-9.5,95.5), geomShape.getShell().getCoord(1));
        assertEquals(new Coordinate(40.5,95.5), geomShape.getShell().getCoord(2));
        assertEquals(new Coordinate(90.5,95.5), geomShape.getShell().getCoord(3));
        assertEquals(new Coordinate(40.5,145.5), geomShape.getShell().getCoord(4));
       
        // now making sure the the CoordMap is correctly updated too.
        assertEquals(1, map.getCoords(0,0).size());
        assertEquals(new Coordinate(-9.5,-4.5), map.getCoords(0,0).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        assertEquals(new Coordinate(-9.5,95.5), map.getCoords(0,100).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        assertEquals(new Coordinate(40.5,95.5), map.getCoords(50,100).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        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);
       
        //add at a particular index.
        PrimitiveShape hole = mapping.get(polygon).getHoles().get(0);
        map.insertCoord(26,13, 3, hole);
        assertEquals(Point.valueOf(25,12),hole.getPoint(0));
        assertEquals(Point.valueOf(28,12),hole.getPoint(1));
        assertEquals(Point.valueOf(28,13),hole.getPoint(2));
        assertEquals(Point.valueOf(26,13),hole.getPoint(3));
        assertEquals(Point.valueOf(25,13),hole.getPoint(4));       
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(26,13), editBlackboardEvent.getNewValue());
        assertEquals(hole, editBlackboardEvent.getSource());


       
        //add on an edge test ordering of geometries
        LinearRing ring2=createShellRing(factory, 30);
        LinearRing ring3=createShellRing(factory, 32);
       
        ring3.getCoordinateN(2).y=20;
       
        mapping=map.setGeometries(ring2, null);
        mapping.putAll(map.addGeometry(ring3, null));
       
        map.addToNearestEdge(54,12, mapping.get(ring2), true);
        assertEquals(1, map.getCoords(54,12).size());
        assertEquals(new Coordinate(44.5,7.5), mapping.get(ring2).getShell().getCoord(2));
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(54,12), editBlackboardEvent.getNewValue());
        assertEquals(mapping.get(ring2).getShell(), editBlackboardEvent.getSource());
       
       
        mapping=map.setGeometries(ring2, null);
        mapping.putAll(map.addGeometry(ring3, null));
       
        List<ClosestEdge> added = map.addToNearestEdge(51,12,true);
        assertEquals(2, added.size());
        assertTrue( added.get(0).getGeom()==mapping.get(ring3) || added.get(1).getGeom()==mapping.get(ring3));
        assertTrue( added.get(0).getGeom()==mapping.get(ring2) || added.get(1).getGeom()==mapping.get(ring2));
        assertEquals(2, map.getCoords(51,12).size());
        assertEquals(new Coordinate(41.5,7.5), mapping.get(ring2).getShell().getCoord(2));
        assertEquals(new Coordinate(41.5,7.5), mapping.get(ring3).getShell().getCoord(2));
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(51,12), editBlackboardEvent.getNewValue());
        assertTrue(((Collection) l.event.getSource()).contains(added.get(0).getPart())  );
        assertTrue(((Collection) l.event.getSource()).contains(added.get(1).getPart())  );
       
        // create hole one point at a time
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        geomShape = map.getGeoms().get(0);
        hole = geomShape.newHole();
        try{
            map.addPoint(0,0, null);
            fail();
        }catch (Exception e) {
            //good
        }
    
        map.addPoint(0,0, hole);
        assertEquals(Point.valueOf(0,0), l.getEditBlackboardEvent().getNewValue());
        map.addPoint(0,100, hole);
        assertEquals(Point.valueOf(0,100), l.getEditBlackboardEvent().getNewValue());
        map.addPoint(50,100, hole);
        assertEquals(Point.valueOf(50,100), l.getEditBlackboardEvent().getNewValue());
        map.addPoint(100,100, hole);
        assertEquals(Point.valueOf(100,100), l.getEditBlackboardEvent().getNewValue());
        map.addPoint(50,150, hole);
        assertEquals(null, l.getEditBlackboardEvent().getOldValue());
        assertEquals(Point.valueOf(50,150), l.getEditBlackboardEvent().getNewValue());
        assertEquals(hole, l.getEditBlackboardEvent().getSource());
       
       
        assertEquals(Point.valueOf(0,0), geomShape.getHoles().get(0).getPoint(0));
        assertEquals(Point.valueOf(0,100), geomShape.getHoles().get(0).getPoint(1));
        assertEquals(Point.valueOf(50,100), geomShape.getHoles().get(0).getPoint(2));
        assertEquals(Point.valueOf(100,100), geomShape.getHoles().get(0).getPoint(3));
        assertEquals(Point.valueOf(50,150), geomShape.getHoles().get(0).getPoint(4));

        //test the coordinates were created correcly
        assertEquals(new Coordinate(-9.5,-4.5), geomShape.getHoles().get(0).getCoord(0));
        assertEquals(new Coordinate(-9.5,95.5), geomShape.getHoles().get(0).getCoord(1));
        assertEquals(new Coordinate(40.5,95.5), geomShape.getHoles().get(0).getCoord(2));
        assertEquals(new Coordinate(90.5,95.5), geomShape.getHoles().get(0).getCoord(3));
        assertEquals(new Coordinate(40.5,145.5), geomShape.getHoles().get(0).getCoord(4));

        // now making sure the the CoordMap is correctly updated too.
        assertEquals(1, map.getCoords(0,0).size());
        assertEquals(new Coordinate(-9.5,-4.5), map.getCoords(0,0).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        assertEquals(new Coordinate(-9.5,95.5), map.getCoords(0,100).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        assertEquals(new Coordinate(40.5,95.5), map.getCoords(50,100).get(0));
        assertEquals(1, map.getCoords(0,100).size());
        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));
       
        // call add to edge so that it is added to a hole
        polygon=createPolygon(factory, 10);
        LinearRing ring1=createShellRing(factory, 10);
        mapping=map.setGeometries(ring1, null);
        mapping.putAll(map.addGeometry(polygon, null));

        added=map.addToNearestEdge(26,12, true);
        assertEquals(1, added.size());
View Full Code Here

     */
    @Test
    public void testMoveCoords() throws Exception, Exception {
        EventListener l=new EventListener();
        GeometryFactory factory=new GeometryFactory();
        LinearRing ring1=createShellRing(factory, 10);
        LinearRing ring2=createShellRing(factory, 10);
        LinearRing ring3=createShellRing(factory, 10);
        LinearRing ring4=createShellRing(factory, 40);
       
        EditBlackboard map = new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        Map<Geometry, EditGeom> mapping = map.setGeometries(ring1, null);
        mapping.putAll(map.addGeometry(ring2, null));
View Full Code Here

     */
    @Test
    public void testDeleteCoords() {
       
        GeometryFactory factory=new GeometryFactory();
        LinearRing ring1=createShellRing(factory, 10);
        LinearRing ring2=createShellRing(factory, 10);
        LinearRing ring3=createShellRing(factory, 10);
        EditBlackboard map = new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        EventListener l=new EventListener();
        map.getListeners().add(l);
        Map<Geometry, EditGeom> mapping = map.setGeometries(ring1, null);
        mapping.putAll(map.addGeometry(ring2, null));
View Full Code Here

     * </p>
     * @param xy Two dimensional ordiantes.
     * @return Polygon
     */
    public Polygon polygon( int[] xy ){
        LinearRing shell = ring( xy );       
        return gf.createPolygon( shell, null );       
    }
View Full Code Here

     */
    public Polygon polygon( int[] xy, int []holes[] ){
        if( holes == null || holes.length == 0){
           return polygon( xy );
        }
        LinearRing shell = ring( xy );       
       
        LinearRing[] rings = new LinearRing[holes.length];

        for (int i = 0; i < xy.length; i++) {
            rings[i] = ring(holes[i]);
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.