Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


        handler.getBehaviours().add(mode);
        handler.setEditBlackboard(new EditBlackboard(500,500, map.getViewportModel().worldToScreenTransform(),
                map.getLayersInternal().get(0).layerToMapTransform()));
       
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
        GeometryFactory factory=new GeometryFactory();
        LineString line1=factory.createLineString(new Coordinate[]{
                map.getViewportModel().pixelToWorld(10,10), map.getViewportModel().pixelToWorld(10,20)
        });
        LineString line2=factory.createLineString(new Coordinate[]{
                map.getViewportModel().pixelToWorld(20,10), map.getViewportModel().pixelToWorld(20,20)
        });
       
        MultiLineString multiline = factory.createMultiLineString(new LineString[]{line1, line2});
       
        SimpleFeature feature = SimpleFeatureBuilder.build(resource.getSchema(),
            new Object[]{multiline, "multiline"}, "testGeom"); //$NON-NLS-1$
        Set<Identifier> ids = new HashSet<Identifier>();
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
View Full Code Here


  @Override
  protected Geometry toCollection(Geometry geometry) {
    if (geometry instanceof Polygon) {
      Polygon polygon = (Polygon) geometry;
      GeometryFactory factory = polygon.getFactory();
      return factory.createMultiPolygon(new Polygon[] { polygon });
    }
    return geometry;
  }
View Full Code Here

                new Coordinate(-128.6833, 59.0548), new Coordinate(-128.682, 59.0565),
                new Coordinate(-128.6811, 59.0559), new Coordinate(-128.6817, 59.0538),
                new Coordinate(-128.683, 59.0526), new Coordinate(-128.6837, 59.052),
                new Coordinate(-128.685, 59.0512), new Coordinate(-128.6863, 59.0512),
                new Coordinate(-128.6889, 59.0493), new Coordinate(-128.6898, 59.0493)};
        GeometryFactory fac=new GeometryFactory();
        Polygon lake = fac.createPolygon(fac.createLinearRing(coords), new LinearRing[0]);
        Envelope env = lake.getEnvelopeInternal();
       
        ViewportModel model = ((ViewportModel) handler.getContext().getMap().getViewportModel());
        model.setBounds(env);
        model.setWidth(env.getWidth()*200);
 
View Full Code Here

     * both should be selected in this case.
     * @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

        assertTrue(blackboard.getSelection().contains(Point.valueOf(10,41)));
    }
   
    @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

    public void setUp() throws Exception {
        handler=new TestHandler(3);
       
        FeatureStore<SimpleFeatureType, SimpleFeature> source = ((ILayer) handler.getContext().getMapLayers().get(0)).getResource(FeatureStore.class, null);
        FilterFactory filterFac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        GeometryFactory geomFac=new GeometryFactory();
        int i=0;
        for( FeatureIterator<SimpleFeature> iter = source.getFeatures().features(); iter.hasNext(); ){
            SimpleFeature feature = iter.next();
            source.modifyFeatures(feature.getFeatureType().getDescriptor("name"), "feature"+i, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())))//$NON-NLS-1$//$NON-NLS-2$
            Geometry geom;
            if( i==0 ){
                geom=geomFac.createPoint(new Coordinate(0,10));
            }else if( i==1 ){
                geom=geomFac.createLineString(new Coordinate[]{
                        new Coordinate( 10,10), new Coordinate(10,20)
                });
            }else{
                geom=geomFac.createLinearRing(
                        new Coordinate[]{
                                new Coordinate( 20,10), new Coordinate(40,10),
                                new Coordinate( 40,40), new Coordinate(20,40),
                                new Coordinate( 20,10)
                        }
                );
                geom=geomFac.createPolygon((LinearRing) geom, new LinearRing[0]);
            }
            source.modifyFeatures(feature.getFeatureType().getGeometryDescriptor(), geom, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())));
            i++;
        }
        ((EditManager) handler.getContext().getEditManager()).commitTransaction();
View Full Code Here

   * This test case is based on the experience of
   * @throws Exception
   */
    @Test
  public void testDiffOnDonut() throws Exception {
        GeometryFactory geometryFactory = new GeometryFactory();
        WKTReader reader = new WKTReader( geometryFactory );
       
       
        //create feature collection with 2 geometries:
        //1. donut minus hole
View Full Code Here

        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(null, editBlackboardEvent.getOldValue());
        assertEquals(Point.valueOf(10,10), editBlackboardEvent.getNewValue());
        assertEquals(map.getGeoms().get(0).getShell(), editBlackboardEvent.getSource());

        GeometryFactory factory=new GeometryFactory();
        Geometry geom=factory.createPoint(new Coordinate(10,5));
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        Map<Geometry, EditGeom> mapping = map.setGeometries(geom, null);
        assertNotNull(mapping.get(geom));
        assertEquals(ShapeType.POINT, mapping.get(geom).getShapeType());
        assertPixMapState(map,1,1,0,0);
        assertEquals(20, map.getGeoms().get(0).getShell().getPoint(0).getX() );
        assertEquals(10, map.getGeoms().get(0).getShell().getPoint(0).getY() );
        assertEquals(EventType.SET_GEOMS, l.event.getType());
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(1, ((List)editBlackboardEvent.getOldValue()).size());
        assertEquals(1, ((List)editBlackboardEvent.getNewValue()).size());
        assertEquals(map, editBlackboardEvent.getSource());
      
        geom=factory.createMultiPoint(new Coordinate[]{new Coordinate(10,5), new Coordinate(20,10)});
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        String string = "featureID"; //$NON-NLS-1$
        mapping=map.setGeometries(geom, string);
        EditGeom next = mapping.values().iterator().next();
        assertEquals(ShapeType.POINT, next.getShapeType());
        assertEquals(string, next.getFeatureIDRef().get());
        assertNotNull(mapping.get(geom.getGeometryN(0)));
        assertNotNull(mapping.get(geom.getGeometryN(1)));
        assertPixMapState(map,2,1,0,0);
        assertEquals(20, map.getGeoms().get(0).getShell().getPoint(0).getX() );
        assertEquals(10, map.getGeoms().get(0).getShell().getPoint(0).getY() );
        assertEquals(30, map.getGeoms().get(1).getShell().getPoint(0).getX() );
        assertEquals(15, map.getGeoms().get(1).getShell().getPoint(0).getY() );
        assertEquals(new Coordinate(10,5), map.getGeoms().get(0).getShell().getCoord(0));
        assertEquals(new Coordinate(20,10), map.getGeoms().get(1).getShell().getCoord(0));
        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());
        assertNotNull(mapping.get(ring));
        assertPixMapState(map,1,5,0,0);
        assertEquals(20, map.getGeoms().get(0).getShell().getPoint(0).getX() );
        assertEquals(10, map.getGeoms().get(0).getShell().getPoint(0).getY() );
        assertEquals(30, map.getGeoms().get(0).getShell().getPoint(1).getX() );
        assertEquals(10, map.getGeoms().get(0).getShell().getPoint(1).getY() );
        assertEquals(30, map.getGeoms().get(0).getShell().getPoint(2).getX() );
        assertEquals(15, map.getGeoms().get(0).getShell().getPoint(2).getY() );
        assertEquals(20, map.getGeoms().get(0).getShell().getPoint(3).getX() );
        assertEquals(15, map.getGeoms().get(0).getShell().getPoint(3).getY() );
        assertEquals(20, map.getGeoms().get(0).getShell().getPoint(4).getX() );
        assertEquals(10, map.getGeoms().get(0).getShell().getPoint(4).getY() );
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(1, ((List) editBlackboardEvent.getNewValue()).size());
        assertEquals(map, editBlackboardEvent.getSource());
       
        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
        Polygon polygon = createPolygon(factory, 10);
        mapping=map.setGeometries(polygon, null);
        assertEquals(ShapeType.POLYGON, mapping.get(polygon).getShapeType());
        assertNotNull(mapping.get(polygon));
        assertPixMapState(map,1,5,1,5);
        assertEquals(Point.valueOf(20,10), map.getGeoms().get(0).getShell().getPoint(0) );
        assertEquals(Point.valueOf(25,12), map.getGeoms().get(0).getHoles().get(0).getPoint(0) );
        assertEquals(Point.valueOf(30,10), map.getGeoms().get(0).getShell().getPoint(1) );
        assertEquals(Point.valueOf(28,12), map.getGeoms().get(0).getHoles().get(0).getPoint(1) );
        assertEquals(new Coordinate(15,7), map.getGeoms().get(0).getHoles().get(0).getCoord(0));
        assertEquals(new Coordinate(18,7), map.getGeoms().get(0).getHoles().get(0).getCoord(1));
        editBlackboardEvent = l.getEditBlackboardEvent();
        assertEquals(1, ((List) editBlackboardEvent.getNewValue()).size());
        assertEquals(map, editBlackboardEvent.getSource());

        geom=factory.createMultiPolygon(new Polygon[]{
           createPolygon(factory, 0), createPolygon(factory, 20)     
        });

        map=new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);
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);
View Full Code Here

     */
    @Test
    public void testAddCoord() {
        EventListener l=new EventListener();
       
        GeometryFactory factory=new GeometryFactory();
        Geometry geom=factory.createPoint(new Coordinate(10,5));
        EditBlackboard map = new EditBlackboard(SCREEN.x,SCREEN.y, transform, layerToWorld);
        map.getListeners().add(l);

        map.setGeometries(geom, null);
        assertPixMapState(map,1,1,0,0);
View Full Code Here

TOP

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

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.