Examples of RetypingFeatureCollection


Examples of org.geoserver.feature.RetypingFeatureCollection

          // 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

Examples of org.geoserver.feature.RetypingFeatureCollection

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

Examples of org.geoserver.feature.RetypingFeatureCollection

        }
       
        if(names.size() < original.getDescriptors().size()) {
            String[] namesArray = (String[]) names.toArray(new String[names.size()]);
            SimpleFeatureType target = SimpleFeatureTypeBuilder.retype(original, namesArray);
            return new RetypingFeatureCollection(fc, target);
        }
        return fc;
    }
View Full Code Here

Examples of org.geoserver.feature.RetypingFeatureCollection

        // 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

Examples of org.geoserver.feature.RetypingFeatureCollection

        if(sourceSchema.getName().getNamespaceURI() == null) {
            try {
                String targetNs = "http://www.geoserver.org/rest/granules";
                AttributeDescriptor[] attributes = (AttributeDescriptor[]) sourceSchema.getAttributeDescriptors().toArray(new AttributeDescriptor[sourceSchema.getAttributeDescriptors().size()]);
                SimpleFeatureType targetSchema = FeatureTypes.newFeatureType(attributes, sourceSchema.getName().getLocalPart(), new URI(targetNs));
                RetypingFeatureCollection retyped = new RetypingFeatureCollection(features, targetSchema);
                return retyped;
            } catch(Exception e) {
                throw new IOException("Failed to retype the granules feature schema, in order to force " +
                        "it having a non null namespace", e);
            }
View Full Code Here

Examples of org.geoserver.feature.RetypingFeatureCollection

    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

Examples of org.geoserver.feature.RetypingFeatureCollection

        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

Examples of org.geoserver.feature.RetypingFeatureCollection

        }
       
        if(names.size() < original.getDescriptors().size()) {
            String[] namesArray = (String[]) names.toArray(new String[names.size()]);
            SimpleFeatureType target = SimpleFeatureTypeBuilder.retype(original, namesArray);
            return new RetypingFeatureCollection(fc, target);
        }
        return fc;
    }
View Full Code Here

Examples of org.geotools.data.store.ReTypingFeatureCollection

            // rebuild the type and wrap the reader
            SimpleFeatureType schema = collection.getSchema();
            SimpleFeatureType target = SimpleFeatureTypeBuilder.retype(schema, query
                    .getPropertyNames());
            if (!target.equals(schema)) {
                collection = new ReTypingFeatureCollection(collection, target);
            }
        }
        return collection;
    }
View Full Code Here

Examples of org.geotools.data.store.ReTypingFeatureCollection

        // apply retyping if necessary
        if (attributes != null && attributes.size() > 0) {
            final String[] names = (String[]) attributes.toArray(new String[attributes.size()]);
            SimpleFeatureType ft = SimpleFeatureTypeBuilder.retype(features.getSchema(), names);
            if (!(ft.equals(features.getSchema()))) {
                features = new ReTypingFeatureCollection(features, ft);
            }
        }

        return features;
    }
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.