public GeometryDescriptor createGeometryDescriptor(GeometryType type, Name name, int minOccurs, int maxOccurs, boolean isNillable, Object defaultValue) { return new GeometricAttributeType(type,name,minOccurs,maxOccurs,isNillable,defaultValue); } }
protected AttributeType createAttributeType( String name, Class clazz, boolean isNillable, int fieldLength, Object defaultValue, Object metaData ){ if( Geometry.class.isAssignableFrom( clazz) && metaData instanceof CoordinateReferenceSystem ){ Filter f = length(fieldLength,name); return new GeometricAttributeType(name,clazz,isNillable,minOccurs(isNillable),1, defaultValue, (CoordinateReferenceSystem) metaData,f); } return createAttributeType( name, clazz, isNillable, fieldLength, defaultValue ); }
protected AttributeType createAttributeType(String name, Class clazz, boolean isNillable, Filter filter, Object defaultValue, Object metadata, int min, int max) { if (Number.class.isAssignableFrom(clazz)) { return new NumericAttributeType( name, clazz, isNillable,min,max,defaultValue, filter); } else if (CharSequence.class.isAssignableFrom(clazz)) { return new TextualAttributeType(name,isNillable,min,max,defaultValue,filter); } else if (java.util.Date.class.isAssignableFrom(clazz)) { //return new TemporalAttributeType(name,isNillable,min,max,defaultValue,filter); return new TemporalAttributeType(name,clazz,isNillable,min,max,defaultValue,filter); } else if (Geometry.class.isAssignableFrom( clazz )){ if( metadata instanceof CoordinateReferenceSystem ) return new GeometricAttributeType(name,clazz,isNillable,min,max, defaultValue,(CoordinateReferenceSystem) metadata,filter); else return new GeometricAttributeType(name,clazz,isNillable,min,max, defaultValue,null,filter); } return new DefaultAttributeType(name, clazz, isNillable,min,max,defaultValue,filter); }
protected AttributeType createAttributeType(String name, Class clazz, boolean isNillable, Filter filter, Object defaultValue, Object metadata, int min, int max) { if (Number.class.isAssignableFrom(clazz)) { return new NumericAttributeType( name, clazz, isNillable,min,max,defaultValue, filter); } else if (CharSequence.class.isAssignableFrom(clazz)) { return new TextualAttributeType(name,isNillable,min,max,defaultValue,filter); } else if (java.util.Date.class.isAssignableFrom(clazz)) { //return new TemporalAttributeType(name,isNillable,min,max,defaultValue,filter); return new TemporalAttributeType(name,clazz,isNillable,min,max,defaultValue,filter); } else if (Geometry.class.isAssignableFrom( clazz )){ if( metadata instanceof CoordinateReferenceSystem ) return new GeometricAttributeType(name,clazz,isNillable,min,max, defaultValue,(CoordinateReferenceSystem) metadata,filter); else return new GeometricAttributeType(name,clazz,isNillable,min,max, defaultValue,null,filter); } return new DefaultAttributeType(name, clazz, isNillable,min,max,defaultValue,filter); }
/** * Implementation of AttributeType creation. */ protected AttributeType createAttributeType(String name, Class clazz, boolean isNillable, int fieldLength, Object defaultValue) { Filter f = length( fieldLength, name ); int minOccurs = minOccurs(isNillable); int maxOccurs = 1; if (Number.class.isAssignableFrom(clazz)) { return new NumericAttributeType( name, clazz, isNillable, minOccurs,maxOccurs,defaultValue,f); } else if (CharSequence.class.isAssignableFrom(clazz)) { return new TextualAttributeType(name,isNillable,minOccurs,maxOccurs,defaultValue,f); } else if (java.util.Date.class.isAssignableFrom(clazz)) { return new TemporalAttributeType(name,clazz,isNillable,minOccurs,maxOccurs,defaultValue,f); } else if (Geometry.class.isAssignableFrom( clazz )){ return new GeometricAttributeType(name,clazz,isNillable,minOccurs,maxOccurs, defaultValue,null,f); } return new DefaultAttributeType(name, clazz, isNillable,minOccurs, maxOccurs,defaultValue, f); }
/** * Implementation of AttributeType creation. */ protected AttributeType createAttributeType(String name, Class clazz, boolean isNillable, int fieldLength, Object defaultValue) { Filter f = length( fieldLength, name ); int minOccurs = minOccurs(isNillable); int maxOccurs = 1; if (Number.class.isAssignableFrom(clazz)) { return new NumericAttributeType( name, clazz, isNillable, minOccurs,maxOccurs,defaultValue,f); } else if (CharSequence.class.isAssignableFrom(clazz)) { return new TextualAttributeType(name,isNillable,minOccurs,maxOccurs,defaultValue,f); } else if (java.util.Date.class.isAssignableFrom(clazz)) { return new TemporalAttributeType(name,clazz,isNillable,minOccurs,maxOccurs,defaultValue,f); } else if (Geometry.class.isAssignableFrom( clazz )){ return new GeometricAttributeType(name,clazz,isNillable,minOccurs,maxOccurs, defaultValue,null,f); } return new DefaultAttributeType(name, clazz, isNillable,minOccurs, maxOccurs,defaultValue, f); }
final GeometricAttributeType geom = new GeometricAttributeType("geom", Polygon.class, true, 1, 1, null, sourceCrs, null); final AttributeType grid = AttributeTypeFactory.newAttributeType(
final GeometricAttributeType geom = new GeometricAttributeType("geom", Polygon.class, true, 1, 1, null, sourceCrs, null); final AttributeType grid = AttributeTypeFactory.newAttributeType(
protected AttributeType createAttributeType( String name, Class clazz, boolean isNillable, int fieldLength, Object defaultValue, Object metaData ){ if( Geometry.class.isAssignableFrom( clazz) && metaData instanceof CoordinateReferenceSystem ){ LengthFunction length = (LengthFunction) ff.function("LengthFunction", new Expression[] { ff.property(name) }); Filter cf = null; try { cf = ff.equals(length, ff.literal(fieldLength)); } catch (IllegalFilterException e) { // TODO something } Filter f = cf == null ? Filter.EXCLUDE : cf; return new GeometricAttributeType(name,clazz,isNillable,minOccurs(isNillable),1, defaultValue, (CoordinateReferenceSystem) metaData,f); } return createAttributeType( name, clazz, isNillable, fieldLength, defaultValue ); }
types[i] = new GeometricAttributeType((GeometricAttributeType) types[i], override);
/** * Wraps a grid coverage into a Feature. Code lifted from ArcGridDataSource * (temporary). * * @param coverage the grid coverage. * @return a feature with the grid coverage envelope as the geometry and the * grid coverage itself in the "grid" attribute. */ public static FeatureCollection wrapGridCoverage(final GridCoverage2D coverage) throws TransformException, SchemaException, IllegalAttributeException { final Polygon bounds = getPolygon(coverage.getEnvelope2D()); final CoordinateReferenceSystem sourceCRS = CRSUtilities.getCRS2D(coverage.getCoordinateReferenceSystem()); // create the feature type final GeometricAttributeType geom = new GeometricAttributeType("geom", Polygon.class, true, 1, 1, null, sourceCRS, null); final AttributeType grid = AttributeTypeFactory.newAttributeType( "grid", GridCoverage.class); final AttributeType[] attTypes = { geom, grid }; // Fix the schema name final String typeName = "GridCoverage"; final DefaultFeatureType schema = (DefaultFeatureType) FeatureTypeBuilder .newFeatureType(attTypes, typeName); // create the feature Feature feature = schema.create(new Object[] { bounds, coverage }); final FeatureCollection collection = FeatureCollections.newCollection(); collection.add(feature); return collection; }