Examples of FeatureVisitor


Examples of org.opengis.feature.FeatureVisitor

                    features = source.getFeatures( query ); // we just want the FeatureID no attributes needed
                   
                    //features = source.getFeatures( filter );
                   
                    final Set<FeatureId> selection = new HashSet<FeatureId>();
                    features.accepts( new FeatureVisitor(){
                        public void visit( Feature feature) {
                            // we are using FeatureId to allow for a "temporary" FID when inserting content
                            // (a real FID is not assigned until commit)
                            //
                            FeatureId identifier = feature.getIdentifier();
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

        //wrap it in a feature graph generator
        final FeatureGraphGenerator featureGen = new FeatureGraphGenerator( lineStringGen );

        //throw all the features into the graph generator
        try {
            features.accepts( new FeatureVisitor(){
                public void visit( Feature feature ) {
                    Graphable added;
                    added = featureGen.add( feature );
                }          
            }, GeoToolsAdapters.progress( monitor ));
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = layer.getResource(FeatureSource.class, new SubProgressMonitor(monitor, 1));
        FeatureCollection<SimpleFeatureType, SimpleFeature>  features = featureSource.getFeatures(query);
       
        //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;
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

           
            store.setTransaction( transaction );
           
            ProgressListener progessListener = GeoToolsAdapters.progress( SubMonitor.convert(monitor,"processing "+source.getName(), 90));         //$NON-NLS-1$

            output.accepts(new FeatureVisitor(){
                boolean warning = true;
                public void visit( Feature rawFeature ) {
                    SimpleFeature feature = (SimpleFeature) rawFeature;
                    String fid = feature.getID();
                   
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

        ILayer editLayer = parameters.handler.getEditLayer();
        FeatureCollection<SimpleFeatureType, SimpleFeature> features = getFeatureIterator(
            monitor, editLayer, feature.getBounds());
           
        final EditBlackboard blackboard = parameters.handler.getEditBlackboard(editLayer);       
        features.accepts( new FeatureVisitor(){
                    public void visit( Feature feature ) {
                        SimpleFeature next = (SimpleFeature) feature;
                        SelectFeatureCommand selectFeatureCommand = new SelectFeatureCommand(
                                blackboard, next);
                        commands.addCommand(selectFeatureCommand);                       
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

           
            store.setTransaction( transaction );
           
            ProgressListener progessListener = GeoToolsAdapters.progress( SubMonitor.convert(monitor,"processing "+source.getName(), 90));         //$NON-NLS-1$

            output.accepts(new FeatureVisitor(){
                boolean warning = true;
                public void visit( Feature rawFeature ) {
                    SimpleFeature feature = (SimpleFeature) rawFeature;
                    String fid = feature.getID();
                   
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

        // is as expected.
        assertEquals(8, origional.getCount(Query.ALL));
        final SortedSet<String> allFids = new TreeSet<String>();
        SimpleFeatureCollection collection = origional.getFeatures();
        TestProgressListener progress = new TestProgressListener();
        collection.accepts(new FeatureVisitor() {
            public void visit(Feature feature) {
                allFids.add(feature.getIdentifier().getID());
            }
        }, progress);
        assertTrue("visitor completed", progress.completed);
        assertEquals("visitor 100%", 100f, progress.progress);
        assertNull("visitor no problems", progress.exception);

        // we are going to use this transaction to modify and commit
        DefaultTransaction t1 = new DefaultTransaction("Transaction 1");
        SimpleFeatureStore featureStore1 = (SimpleFeatureStore) dataStore
                .getFeatureSource(typeName);
        featureStore1.setTransaction(t1);
        TestFeatureListener listener1 = new TestFeatureListener();
        featureStore1.addFeatureListener(listener1);
        // we are going to use this transaction to modify and rollback
        DefaultTransaction t2 = new DefaultTransaction("Transaction 2");
        SimpleFeatureStore featureStore2 = (SimpleFeatureStore) dataStore
                .getFeatureSource(typeName);
        featureStore2.setTransaction(t2);
        TestFeatureListener listener2 = new TestFeatureListener();
        featureStore2.addFeatureListener(listener2);

        // verify they are all working
        assertEquals(8, origional.getCount(Query.ALL));
        assertEquals(8, featureStore1.getCount(Query.ALL));
        assertEquals(8, featureStore2.getCount(Query.ALL));

        Query queryOneFeature = new Query();
        queryOneFeature.setTypeName(typeName);
        queryOneFeature.setFilter(Filter.INCLUDE);
        queryOneFeature.setMaxFeatures(1);
        queryOneFeature.setPropertyNames(Query.ALL_NAMES);

        collection = featureStore1.getFeatures(queryOneFeature);
        progress.reset();
        final SortedSet<String> fids = new TreeSet<String>();
        collection.accepts(new FeatureVisitor() {
            public void visit(Feature feature) {
                fids.add(feature.getIdentifier().getID());
            }
        }, progress);
        assertTrue("visitor completed", progress.completed);
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

    public void testMultiLine() throws Exception {
        SimpleFeatureSource road = store.getFeatureSource("multiline");
        FeatureId fid1 = ff.featureId("fid1");
        Filter select = ff.id(Collections.singleton(fid1));
        SimpleFeatureCollection featureCollection = road.getFeatures(select);
        featureCollection.accepts(new FeatureVisitor() {
            public void visit(Feature f) {
                SimpleFeature feature = (SimpleFeature) f;
                String name = (String) feature.getAttribute("name");
                assertEquals("jody \ngarnett", name);
            }
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

        SimpleFeatureSource table = store.getFeatureSource("table");
        // GenericEntity.f004=description-f004|name-f004
        FeatureId fid1 = ff.featureId("GenericEntity.f004");
        Filter select = ff.id(Collections.singleton(fid1));
        SimpleFeatureCollection featureCollection = table.getFeatures(select);
        featureCollection.accepts(new FeatureVisitor() {
            public void visit(Feature f) {
                SimpleFeature feature = (SimpleFeature) f;
                String name = (String) feature.getAttribute("name");
                assertEquals("name-f004", name);
            }
        }, null);
        // GenericEntity.f003=description-f003|<null>
        fid1 = ff.featureId("GenericEntity.f003");
        select = ff.id(Collections.singleton(fid1));
        featureCollection = table.getFeatures(select);
        featureCollection.accepts(new FeatureVisitor() {
            public void visit(Feature f) {
                SimpleFeature feature = (SimpleFeature) f;
                String name = (String) feature.getAttribute("name");
                System.out.println(name);
                assertNull("represent null", name);
            }
        }, null);
        // GenericEntity.f007=description-f007|
        fid1 = ff.featureId("GenericEntity.f007");
        select = ff.id(Collections.singleton(fid1));
        featureCollection = table.getFeatures(select);
        featureCollection.accepts(new FeatureVisitor() {
            public void visit(Feature f) {
                SimpleFeature feature = (SimpleFeature) f;
                String name = (String) feature.getAttribute("name");
                assertEquals("represent empty string", "", name);
            }
        }, null);
        // "  GenericEntity.f009=description-f009| "
        fid1 = ff.featureId("GenericEntity.f009");
        select = ff.id(Collections.singleton(fid1));
        featureCollection = table.getFeatures(select);
        featureCollection.accepts(new FeatureVisitor() {
            public void visit(Feature f) {
                SimpleFeature feature = (SimpleFeature) f;
                String name = (String) feature.getAttribute("name");
                assertEquals("represent empty string", " ", name);
            }
View Full Code Here

Examples of org.opengis.feature.FeatureVisitor

         //TEST classifier with everything in a single bin
         final Set<String>[] binValues2 = new Set[1];
         binValues2[0] = new HashSet<String>();
         //assign each of the features to one of the bins
         try {
      fc.accepts(new FeatureVisitor(){
        public void visit(Feature feature) {       
          binValues2[0].add(((SimpleFeature)feature).getAttribute(attribName).toString() );
         
        }}, null);
    } catch (IOException e) {
      fail(e.getMessage());
      e.printStackTrace();
    }
        
     ExplicitClassifier classifier = new ExplicitClassifier(binValues2);
         Color[] colors = brewer.getPalette(paletteName).getColors(binValues2.length);

         // get the fts
         FeatureTypeStyle fts = StyleGenerator.createFeatureTypeStyle(classifier, expr, colors,
                 "myfts", riverFeatures[0].getFeatureType().getGeometryDescriptor(),
                 StyleGenerator.ELSEMODE_IGNORE, 0.5, null);
         assertNotNull(fts);

         // test each filter
         //we would expect two rules here - one for each of the two bins created
         List<Rule> rules = fts.rules();
         assertEquals(1, rules.size());
        
         //do a preliminary test to make sure each rule's filter returns some results    
         assertNotNull(StyleGenerator.toStyleExpression(rules.get(0).getFilter()));
         final Filter filter = rules.get(0).getFilter();
         try {
      fc.accepts(new FeatureVisitor(){

        public void visit(Feature feature) {
          if (!filter.evaluate(feature)){
            fail("Not all features accepted.");
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.