Package org.geoserver.feature

Examples of org.geoserver.feature.RetypingFeatureCollection$RetypingFeatureReader


        featureStore().setFeatures(retypingFeatureReader);
    }

    public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException {
        List<FeatureId> ids = featureStore().addFeatures(
                new RetypingFeatureCollection(collection, typeMap.getOriginalFeatureType()));
        List<FeatureId> retyped = new ArrayList<FeatureId>();
        for (FeatureId id : ids) {
            retyped.add(RetypingFeatureCollection.reTypeId(id, typeMap.getOriginalFeatureType(), typeMap.getFeatureType()));
        }
        return retyped;
View Full Code Here


        // account
        SimpleFeatureType target = typeMap.getFeatureType();
        if ( query.getPropertyNames() != Query.ALL_NAMES ) {
            target = SimpleFeatureTypeBuilder.retype(target, query.getPropertyNames());
        }
        return new RetypingFeatureCollection(wrapped.getFeatures(store.retypeQuery(query, typeMap)),
                target);
    }
View Full Code Here

          // having dots in the name prevents various programs to recognize the file as a shapefile
          SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
          tb.init(c.getSchema());
          tb.setName(c.getSchema().getTypeName().replace('.', '_'));
          SimpleFeatureType renamed = tb.buildFeatureType();
          c = new RetypingFeatureCollection(c, renamed);
        }

        FeatureStore<SimpleFeatureType, SimpleFeature> fstore = null;
        ShapefileDataStore dstore = null;
        try {
            // create attribute name mappings, to be compatible
            // with shapefile constraints:
            //  - geometry field is always named the_geom
            //  - field names have a max length of 10
            Map<String,String> attributeMappings=createAttributeMappings(c.getSchema());
            // wraps the original collection in a remapping wrapper
            FeatureCollection remapped=new RemappingFeatureCollection(c,attributeMappings);
            SimpleFeatureType remappedSchema=(SimpleFeatureType)remapped.getSchema();
            dstore = buildStore(tempDir, charset,  remappedSchema);
            fstore = (FeatureStore<SimpleFeatureType, SimpleFeature>) dstore.getFeatureSource();
            // we need retyping too, because the shapefile datastore
            // could have sorted fields in a different order
            FeatureCollection<SimpleFeatureType, SimpleFeature> retyped = new RetypingFeatureCollection(remapped, fstore.getSchema());
            fstore.addFeatures(retyped);
         
        } catch (IOException ioe) {
            LOGGER.log(Level.WARNING,
                "Error while writing featuretype '" + schema.getTypeName() + "' to shapefile.", ioe);
View Full Code Here

                    }
                }
            }
            tb.setName(fc.getSchema().getTypeName().replace('.', '_'));
            SimpleFeatureType renamed = tb.buildFeatureType();
            fc = new RetypingFeatureCollection(fc, renamed);
        }
       
        // create attribute name mappings, to be compatible
        // with shapefile constraints:
        //  - geometry field is always named the_geom
View Full Code Here

    public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) throws IOException {
        FeatureStore<SimpleFeatureType, SimpleFeature> store = store();

        //check if the feature collection needs to be retyped
        if (!store.getSchema().equals(fc.getSchema())) {
            fc = new RetypingFeatureCollection(fc, store.getSchema());
        }

        return store().addFeatures(fc);
    }
View Full Code Here

        // account
        SimpleFeatureType target = typeMap.getFeatureType();
        if ( query.getPropertyNames() != Query.ALL_NAMES ) {
            target = SimpleFeatureTypeBuilder.retype(target, query.getPropertyNames());
        }
        return new RetypingFeatureCollection(wrapped.getFeatures(store.retypeQuery(query, typeMap)),
                target);
    }
View Full Code Here

        featureStore().setFeatures(retypingFeatureReader);
    }

    public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> collection) throws IOException {
        List<FeatureId> ids = featureStore().addFeatures(
                new RetypingFeatureCollection(DataUtilities.simple(collection), typeMap.getOriginalFeatureType()));
        List<FeatureId> retyped = new ArrayList<FeatureId>();
        for (FeatureId id : ids) {
            retyped.add(RetypingFeatureCollection.reTypeId(id, typeMap.getOriginalFeatureType(), typeMap.getFeatureType()));
        }
        return retyped;
View Full Code Here

    public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) throws IOException {
        FeatureStore<SimpleFeatureType, SimpleFeature> store = store();

        //check if the feature collection needs to be retyped
        if (!store.getSchema().equals(fc.getSchema())) {
            fc = new RetypingFeatureCollection(DataUtilities.simple(fc), store.getSchema());
        }

        return store().addFeatures(fc);
    }
View Full Code Here

          // rename the schema to have the proper output file name
          SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
          tb.init(c.getSchema());
          tb.setName(fileName);
          SimpleFeatureType renamed = tb.buildFeatureType();
          c = new RetypingFeatureCollection(c, renamed);
        }

        SimpleFeatureStore fstore = null;
        ShapefileDataStore dstore = null;
        try {
            // create attribute name mappings, to be compatible
            // with shapefile constraints:
            //  - geometry field is always named the_geom
            //  - field names have a max length of 10
            Map<String,String> attributeMappings=createAttributeMappings(c.getSchema());
            // wraps the original collection in a remapping wrapper
            SimpleFeatureCollection remapped = new RemappingFeatureCollection(c,attributeMappings);
            SimpleFeatureType remappedSchema=(SimpleFeatureType)remapped.getSchema();
            dstore = buildStore(tempDir, charset,  remappedSchema);
            fstore = (SimpleFeatureStore) dstore.getFeatureSource();
            // we need retyping too, because the shapefile datastore
            // could have sorted fields in a different order
            SimpleFeatureCollection retyped = new RetypingFeatureCollection(remapped, fstore.getSchema());
            fstore.addFeatures(retyped);
           
            changeWKTFormatIfFileFormatIsESRI(tempDir, request, fileName,
          remappedSchema);
         
View Full Code Here

                    }
                }
            }
            tb.setName(fc.getSchema().getName());
            SimpleFeatureType retyped = tb.buildFeatureType();
            fc = new RetypingFeatureCollection(fc, retyped);
        }
       
        // create attribute name mappings, to be compatible
        // with shapefile constraints:
        //  - geometry field is always named the_geom
View Full Code Here

TOP

Related Classes of org.geoserver.feature.RetypingFeatureCollection$RetypingFeatureReader

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.