Package org.opengis.feature.simple

Examples of org.opengis.feature.simple.SimpleFeature


       
        //combine them into one large polygon
        final Geometry union[] = new Geometry[1];
        features.accepts( new FeatureVisitor(){
            public void visit( Feature feature ) {
                SimpleFeature simple = (SimpleFeature) feature;
                Geometry geometry = (Geometry ) simple.getDefaultGeometry();
                if( union[0] == null ){
                    union[0] = geometry;
                }
                else {
                    union[0] = union[0].union( geometry );
View Full Code Here


                events=layer.getFeatureChanges().size();
            }
        fs.removeFeatures(filter);
       
        IEditManager editManager = getMap().getEditManager();
        SimpleFeature editFeature = editManager.getEditFeature();
        if (editFeature!=null && editManager.getEditLayer()==ilayer && filter.evaluate(editFeature))
            getMap().getEditManagerInternal().setEditFeature(null, null);
        }finally{
            fireFeatureChangeEvent(layer, events);
        }
View Full Code Here

     * @throws IOException
     */
    public SimpleFeature getFeature( final int i ) throws IOException {
        FeatureSource<SimpleFeatureType, SimpleFeature> source =map.getLayersInternal().get(0).getResource(FeatureSource.class, new NullProgressMonitor());
        FeatureCollection<SimpleFeatureType, SimpleFeature>  features=source.getFeatures();
        SimpleFeature feature=null;
        FeatureIterator<SimpleFeature> iter=features.features();
        for( int j=0; j<i+1; j++){
            feature=iter.next();
        }
        return feature;
View Full Code Here

        Expression expr2 = factory.literal(issue.getId());
    Expression expr1 = factory.property(IssuesListTestHelper.ISSUE_ID_ATTR);
    Filter filter = factory.equals(expr1, expr2);

        SimpleFeature next = store.getFeatureSource(featureType.getName().getLocalPart()).getFeatures(filter).features().next();
        assertEquals(newDescription, next.getAttribute(IssuesListTestHelper.DESCRIPTION_ATTR));
    }
View Full Code Here

    public void testNullID() throws Exception {
        list.clear();
        list.add(IssuesListTestHelper.createFeatureIssue(null));
        assertNotNull(list.get(0).getId());
       
        SimpleFeature next = this.store.getFeatureSource(this.featureType.getName().getLocalPart()).getFeatures().features().next();
        Object id = next.getAttribute("id"); //$NON-NLS-1$
        assertNotNull(id);
    }
View Full Code Here

        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();
        ((RenderManager)handler.getContext().getRenderManager()).setMapDisplay(new TestViewportPane(new Dimension(500,500)));
       
View Full Code Here

            System.err.println("class "+editLayer.getClass().getName()+" is returning null")//$NON-NLS-1$//$NON-NLS-2$
            return;
        }
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureStore.class, null);
        //SimpleFeatureStore resource = layer.getResource(SimpleFeatureStore.class, null );
        SimpleFeature feature2 = editFeature.get(monitor);

        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    Id fidFilter = filterFactory.id(
                FeatureUtils.stringToId(filterFactory,feature2.getID()));

        this.oldValue = feature2.getAttribute(xpath);
        feature2.setAttribute(xpath, value);

        AttributeDescriptor attributeType = layer.getSchema().getDescriptor(xpath);
        resource.modifyFeatures(attributeType, value, fidFilter);
    }
View Full Code Here

    /**
     * @see org.locationtech.udig.project.internal.command.UndoableCommand#rollback()
     */
    public void rollback( IProgressMonitor monitor ) throws Exception {
        SimpleFeature feature = editFeature.get(monitor);
        feature.setAttribute(xpath, oldValue);
        ILayer layer = editLayer.get(monitor);
        FeatureStore<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureStore.class, null);
        AttributeDescriptor attributeType = layer.getSchema().getDescriptor(xpath);
        FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    Id id = filterFactory.id(
                FeatureUtils.stringToId(filterFactory, feature.getID()));
        resource.modifyFeatures(attributeType, oldValue, id);
    }
View Full Code Here

        command2.run(new NullProgressMonitor());
        command.run(new NullProgressMonitor());
        assertEquals(EditState.CREATING, handler.getCurrentState());
        assertEquals(1, handler.getEditBlackboard().getGeoms().size());
        assertEquals(Point.valueOf(10,10), handler.getEditBlackboard().getGeoms().get(0).getShell().getPoint(0));
        SimpleFeature editFeature = handler.getContext().getEditManager().getEditFeature();
    assertNull( editFeature );
       
        command.rollback(new NullProgressMonitor());
        command2.rollback(new NullProgressMonitor());
       
        assertEquals(editGeom2.getShell().getPoint(0), handler.getCurrentGeom().getShell().getPoint(0));
        assertEquals(editGeom2.getShell().getPoint(1), handler.getCurrentGeom().getShell().getPoint(1));
        assertEquals(hole.getPoint(0), handler.getCurrentShape().getPoint(0));
        assertEquals(hole.getPoint(1), handler.getCurrentShape().getPoint(1));
        assertTrue(handler.getCurrentGeom().getHoles().contains(handler.getCurrentShape()));
        assertEquals(EditState.CREATING, handler.getCurrentState());
        assertEquals(2, bb.getGeoms().size());

        editFeature = handler.getContext().getEditManager().getEditFeature();
       
        assertEquals("feature id", feature.getID(), editFeature.getID());
        assertFeatureEqual("edit feature",feature, editFeature);
        assertEquals(layer, handler.getContext().getEditManager().getEditLayer());
       
    }
View Full Code Here

     */
    @Ignore
    @Test
    public void testRunDeselectAll() throws Exception {

        SimpleFeature editFeature = handler.getContext().getEditManager().getEditFeature();
        assertEquals(feature.getID(), editFeature.getID());
       
        assertFeatureEqual("edit feature test", feature, editFeature);
       
        assertEquals(layer, handler.getContext().getEditManager().getEditLayer());
       
View Full Code Here

TOP

Related Classes of org.opengis.feature.simple.SimpleFeature

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.