/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling <code> * newFeatureType(types,name,ns,false,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling <code> * newFeatureType(types,name,null,false,null)</code>. Useful for test cases or datasources which * may not allow a namespace. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, DEFAULT_NAMESPACE, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling <code> * newFeatureType(types,name,ns,isAbstract,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, isAbstract, null); }
/** * The most specific way to create a new FeatureType. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @param superTypes A Collection of types the FeatureType will inherit from. Currently, all * types inherit from feature in the opengis namespace. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, isAbstract, superTypes, null); }
/** * The most specific way to create a new FeatureType. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @param superTypes A Collection of types the FeatureType will inherit from. Currently, all * types inherit from feature in the opengis namespace. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, GeometryDescriptor defaultGeometry) throws FactoryRegistryException, SchemaException { return newFeatureType( types, name, ns, isAbstract, superTypes, (AttributeDescriptor) defaultGeometry); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,ns,false,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns ) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,null,false,null)</code>. Useful for test cases or * datasources which may not allow a namespace. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @return A new FeatureType created from the given arguments. * @throws FactoryConfigurationError If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static FeatureType newFeatureType( AttributeType[] types, String name ) throws FactoryConfigurationError, SchemaException { return newFeatureType(types, name, DEFAULT_NAMESPACE, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,ns,isAbstract,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract ) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, isAbstract, null); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,ns,isAbstract,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @return A new FeatureType created from the given arguments. * @throws FactoryConfigurationError If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static FeatureType newFeatureType( AttributeType[] types, String name, URI ns, boolean isAbstract ) throws FactoryConfigurationError, SchemaException { return newFeatureType(types, name, ns, isAbstract, null); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,null,false,null)</code>. Useful for test cases or * datasources which may not allow a namespace. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name ) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, DEFAULT_NAMESPACE, false); }
/** * Create a new FeatureType with the given AttributeTypes. A short cut for calling * <code>newFeatureType(types,name,ns,false,null)</code>. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @return A new FeatureType created from the given arguments. * @throws FactoryConfigurationError If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static FeatureType newFeatureType( AttributeType[] types, String name, URI ns ) throws FactoryConfigurationError, SchemaException { return newFeatureType(types, name, ns, false); }
/** * The most specific way to create a new FeatureType. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @param superTypes A Collection of types the FeatureType will inherit from. Currently, all * types inherit from feature in the opengis namespace. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, GeometryDescriptor defaultGeometry ) throws FactoryRegistryException, SchemaException { return newFeatureType(types,name,ns,isAbstract,superTypes,(AttributeDescriptor)defaultGeometry); }
/** * The most specific way to create a new FeatureType. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @param superTypes A Collection of types the FeatureType will inherit from. Currently, all * types inherit from feature in the opengis namespace. * @return A new FeatureType created from the given arguments. * @throws FactoryConfigurationError If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static FeatureType newFeatureType( AttributeType[] types, String name, URI ns, boolean isAbstract, FeatureType[] superTypes ) throws FactoryConfigurationError, SchemaException { return newFeatureType(types, name, ns, isAbstract, superTypes, null); }
/** * The most specific way to create a new FeatureType. * * @param types The AttributeTypes to create the FeatureType with. * @param name The typeName of the FeatureType. Required, may not be null. * @param ns The namespace of the FeatureType. Optional, may be null. * @param isAbstract True if this created type should be abstract. * @param superTypes A Collection of types the FeatureType will inherit from. Currently, all * types inherit from feature in the opengis namespace. * @return A new FeatureType created from the given arguments. * @throws FactoryRegistryException If there are problems creating a factory. * @throws SchemaException If the AttributeTypes provided are invalid in some way. */ public static SimpleFeatureType newFeatureType( AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes ) throws FactoryRegistryException, SchemaException { return newFeatureType(types, name, ns, isAbstract, superTypes, null); }
public FeatureType createFeatureType(final GISZoneCollection _zone, final AttributeType[] _atts) throws SchemaException { String name = _zone.getTitle(); if (name == null) { name = "zone"; } final FeatureType featureType = FeatureTypes.newFeatureType(_atts, name); return featureType; }
protected final Set getBuiltinTypes() { if ((builtInTypes == null) && !initialized) { builtInTypes = new HashSet(); try { builtInTypes.add(FeatureTypes.newFeatureType(null, "Feature", new URI("http://www.opengis.net/gml"), true)); initialized = true; } catch (Exception e) { throw new RuntimeException(e); } addBaseTypes(builtInTypes); } return builtInTypes; }
/** * Converts this GMLInputTemplate to a feature schema. */ public FeatureType toFeatureSchema() throws ParseException, SchemaException { if (featureType_ != null) { return featureType_; } if (!(loaded_)) { throw new ParseException("requested toFeatureSchema w/o loading the template"); } final int size = columnDefinitions_.size(); final AttributeType[] att = new AttributeType[1 + size]; att[0] = AttributeTypeFactory.newAttributeType(BasicFeatureTypes.GEOMETRY_ATTRIBUTE_NAME, Geometry.class); for (int i = 0; i < size; i++) { att[1 + i] = AttributeTypeFactory.newAttributeType(((ColumnDescription) columnDefinitions_.get(i)).columnName_, ((ColumnDescription) columnDefinitions_.get(i)).getType().getType()); } featureType_ = FeatureTypes.newFeatureType(att, "GML"); return featureType_; }
public FeatureType getSchema() throws IOException { if (schema_ == null) { try { final AttributeType[] types = readAttributes(); FeatureType parent = null; final Class geomType = types[0].getType(); if ((geomType == Point.class) || (geomType == MultiPoint.class)) { parent = BasicFeatureTypes.POINT; } else if ((geomType == Polygon.class) || (geomType == MultiPolygon.class)) { parent = BasicFeatureTypes.POLYGON; } else if ((geomType == LineString.class) || (geomType == MultiLineString.class)) { parent = BasicFeatureTypes.LINE; } if (parent != null) { schema_ = FeatureTypes.newFeatureType(readAttributes(), createFeatureTypeName(), namespace_, false, new FeatureType[] { parent }); } else { if (namespace_ != null) { schema_ = FeatureTypes.newFeatureType(readAttributes(), createFeatureTypeName(), namespace_, false); } else { schema_ = FeatureTypes .newFeatureType(readAttributes(), createFeatureTypeName(), GMLSchema.NAMESPACE, false); } } } catch (final SchemaException se) { throw new DataSourceException("Error creating FeatureType", se); } } return schema_; }
private SimpleFeatureCollection forceNonNullNamespace(SimpleFeatureCollection features) throws IOException { SimpleFeatureType sourceSchema = features.getSchema(); if (sourceSchema.getName().getNamespaceURI() == null) { try { String targetNs = "http://www.geoserver.org/rest/granules"; AttributeDescriptor[] attributes = sourceSchema .getAttributeDescriptors() .toArray( new AttributeDescriptor [sourceSchema.getAttributeDescriptors().size()]); SimpleFeatureType targetSchema = FeatureTypes.newFeatureType( attributes, sourceSchema.getName().getLocalPart(), new URI(targetNs)); return new RetypingFeatureCollection(features, targetSchema); } catch (Exception e) { throw new IOException( "Failed to retype the granules feature schema, in order to force " + "it having a non null namespace", e); } } else { return features; } }
public FeatureCollection getVersionedFeatures(Query query) throws IOException { final FeatureType ft = getSchema(); // check the feature type is the right one final String typeName = ft.getTypeName(); if(query.getTypeName() != null && !query.getTypeName().equals(typeName)) throw new IOException("Incompatible type, this class can access only " + typeName); // make sure the view is around if(!Arrays.asList(store.wrapped.getTypeNames()).contains(store.getVFCViewName(typeName))) store.createVersionedFeatureCollectionView(typeName); // we have to hit the view DefaultQuery vq = new DefaultQuery(query); vq.setTypeName(VersionedPostgisDataStore.getVFCViewName(typeName)); vq = store.buildVersionedQuery(vq); FeatureCollection fc = store.wrapped.getFeatureSource(VersionedPostgisDataStore.getVFCViewName(typeName)).getFeatures(vq); try { final FeatureType fcSchema = fc.getSchema(); FeatureType renamedFt = FeatureTypes.newFeatureType(fcSchema.getAttributeTypes(), ft.getTypeName(), ft.getNamespace(), ft.isAbstract(), ft.getAncestors(), fcSchema.getDefaultGeometry()); return new ReTypingFeatureCollection(fc, renamedFt); } catch(SchemaException e) { throw new DataSourceException("Error ranming feature type", e); } }