Package org.opengis.feature.simple

Examples of org.opengis.feature.simple.SimpleFeature


    @Test
    public void testPersistence() throws Exception {
        IMap map=MapTests.createDefaultMap("name", 1, true, new Dimension(10,10)); //$NON-NLS-1$
        ILayer layer=map.getMapLayers().get(0);
        FeatureCollection<SimpleFeatureType, SimpleFeature> collection = layer.getResource(FeatureSource.class, null).getFeatures();
        SimpleFeature feature=collection.features().next();
       
        IIssue original=new FeatureIssue(Priority.WARNING, "test description", layer, feature, "groupID"); //$NON-NLS-1$ //$NON-NLS-2$
        XMLMemento memento=XMLMemento.createWriteRoot("memento"); //$NON-NLS-1$
        XMLMemento viewMemento=XMLMemento.createWriteRoot("viewMemento"); //$NON-NLS-1$
        original.save(memento);
View Full Code Here


        try{
            SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 98);
            monitor2.beginTask("this is ignored", features.size());
            while(featureIterator.hasNext() ){
                monitor2.worked(1);
                SimpleFeature feature=featureIterator.next();
               
                // do something.
                // the features here will have no attributes or geometry but you can call getID().
                // warning you can't call getBounds() because no geometry was requested in the query.
                // Replace the parameter Query.ALL_NAMES with an array of attribute names
View Full Code Here

                try{
                    boolean featuresWereAdded=false;
                    while( iter.hasNext() ){
                        if( monitor.isCanceled() )
                            break;
                        SimpleFeature newValue = iter.next();
                        SimpleFeature oldValue = findFeature(newValue.getID());
                        if( oldValue==null ){
                            featuresWereAdded=true;
                            features.add(newValue);
                            lookup.put(newValue.getID(), newValue);
                        }else{
                            for( int i = 0; i < schema.getAttributeCount(); i++ ) {
                                oldValue.setAttribute(i, newValue.getAttribute(i));
                            }
                        }
                        loaded++;
                        updateMonitor(loaded+Messages.FeatureTableContentProvider_updatingFeatures);
                    }
View Full Code Here

    public boolean hasNext() {
      return iter.hasNext();
    }

    public SimpleFeature next() {
      SimpleFeature oldF=iter.next();
      Object[] newAttributes=new Object[]{
          oldF.getAttribute("geom"),
          oldF.getAttribute("name"),
          index++
      };
      try {
        SimpleFeature newF=SimpleFeatureBuilder.build(type, newAttributes, null);
        return newF;
      } catch (IllegalAttributeException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

            }
            else {
                values[index] = fac.createPoint( new Coordinate(lon, lat) );
            }
            try{
                SimpleFeature f = SimpleFeatureBuilder.build(ADDRESS, values, fid( count++, table ) );
                places.add( f );
            } catch(Exception e){
                e.printStackTrace();
            }
        }
View Full Code Here

        try {
            int selectedCount = 0;
            int allCount = 0;
            long lastUpdate = System.currentTimeMillis();
            while( allFeatures.hasNext() ) {
                SimpleFeature next = allFeatures.next();
                allCount++;
                if(layer.getFilter().evaluate(next)) {
                  selectedCount++;
                }
              if(System.currentTimeMillis() - lastUpdate > 1000) {
View Full Code Here

        int a=0;
    }
    @Override
    public String getText( Object element ) {
        if( element instanceof SimpleFeature){
            SimpleFeature feature = (SimpleFeature) element;
            return (String) feature.getAttribute("CNTRY_NAME");
        }
        return null;
    }
View Full Code Here

        features=resource.getFeatures();
        GeometryFactory fac=new GeometryFactory();
        int i=0;
        for( FeatureIterator<SimpleFeature> iter=features.features(); iter.hasNext(); ){
            i++;
            SimpleFeature feature=iter.next();
            Coordinate c=map.getViewportModel().pixelToWorld(i*10,0);
            FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
      Set<Identifier> ids = new HashSet<Identifier>();
      ids.add(filterFactory.featureId(feature.getID()));
      GeometryDescriptor defaultGeometry = feature.getFeatureType().getGeometryDescriptor();
      resource.modifyFeatures(defaultGeometry, fac.createPoint(c),
                    filterFactory.id(ids));
        }
        ((EditManager)map.getEditManager()).commitTransaction();

View Full Code Here

                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());
        ids.add(filterFactory.featureId(features.features().next().getID()));
    resource.modifyFeatures(feature.getFeatureType().getGeometryDescriptor(), multiline,
                filterFactory.id(ids));
   
       
        handler.handleEvent(new MapMouseEvent(null, 20, 15, none, none, button1), EventType.RELEASED);
       
View Full Code Here

         * @return the string representation of the feature attribute, except for attributes of type
         *         Geometry in which a string representing the type of Geometry is returned.
         * @throws ClassCastException when element not SimpleFeature
         */
        public String getColumnText( Object element, int columnIndex ) throws ClassCastException {
            SimpleFeature f = (SimpleFeature) element;
            if (f == null) {
                ProjectUIPlugin.trace(getClass(), "SimpleFeature was null in FeatureTableControl", (Exception)null); //$NON-NLS-1$
                return null;
            }
            if (columnIndex == 0)
                return f.getID();

            if (columnIndex >= fType.getAttributeCount()) {
                return null;
            }
            AttributeDescriptor at = fType.getDescriptor(columnIndex - 1);
            if (at == null)
                return null;
            if ( at instanceof GeometryDescriptor ) {
                String s = f.getAttribute(columnIndex - 1).getClass().getName();
                return s.substring(s.lastIndexOf('.') + 1);
            }
            if (f.getAttribute(columnIndex - 1) == null)
                return null;
            return f.getAttribute(columnIndex - 1).toString();

        }
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.