/** * Recursively scans a SimpleFeature for SimpleFeature attributes in order to build a * "flattened" list of attributes * * @param attributeDescriptors A List of attribute descriptors, populated recursively * @param featuretype The feature type to scan * @param attrAlias An alias for adding as a prefix to the simple attribute names */ private static void scanAttributeDescriptors( List<AttributeDescriptor> attributeDescriptors, SimpleFeatureType featureType, String attrAlias) { List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors(); for (int i = 0; i < descriptors.size(); i++) { AttributeDescriptor ad = descriptors.get(i); SimpleFeatureType joinedSchema = (SimpleFeatureType) ad.getUserData().get(ContentDataStore.JOINED_FEATURE_TYPE); String name = (attrAlias != null ? attrAlias + "." : "") + ad.getLocalName(); if (joinedSchema != null) { // go forth and harvest feature attribute types scanAttributeDescriptors(attributeDescriptors, joinedSchema, name); } else { // this is a common (non-feature) attribute type AttributeTypeBuilder build = new AttributeTypeBuilder(); build.init(ad); AttributeDescriptor descriptor = build.buildDescriptor(name); attributeDescriptors.add(descriptor); } } }
/** Constructs the builder specifying the factory used to build attribute types. */ public AttributeTypeBuilder(FeatureTypeFactory factory) { this.factory = factory; init(); }
b.init(old); b.setCRS(getCRS(info.getSRS())); ad = b.buildDescriptor(old.getLocalName());
/** Constructs the builder. */ public AttributeTypeBuilder() { this(CommonFactoryFinder.getFeatureTypeFactory(null)); init(); }
/** Initializes builder state from another attribute descriptor. */ public void init(AttributeDescriptor descriptor) { init(descriptor.getType()); minOccurs = descriptor.getMinOccurs(); maxOccurs = descriptor.getMaxOccurs(); isNillable = descriptor.isNillable(); userData = descriptor.getUserData(); }
/** * Copys a feature type. * * <p>This method does a deep copy in that all individual attributes are copied as well. */ public static SimpleFeatureType copy(SimpleFeatureType original) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); // initialize the builder b.init(original); // clear attributes b.attributes().clear(); // add attributes in order for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { AttributeTypeBuilder ab = new AttributeTypeBuilder(b.factory); ab.init(descriptor); b.add(ab.buildDescriptor(descriptor.getLocalName())); } return b.buildFeatureType(); } }
+ this.defaultGeometry + " was added as a geoemtry"); attributeBuilder.init(att); attributeBuilder.setCRS(defaultCrs); GeometryType type = attributeBuilder.buildGeometryType();
/** * Constructs the builder specifying the factory used to build attribute * types. * */ public AttributeTypeBuilder( FeatureTypeFactory factory ) { this.factory = factory; init(); }
/** * Create a SimpleFeatureType with the same content; just updating the geometry attribute to * match the provided coordinate reference system. * * @param original SimpleFeatureType * @param crs CoordinateReferenceSystem of result * @return SimpleFeatureType updated with the provided CoordinateReferenceSystem */ public static SimpleFeatureType retype( SimpleFeatureType original, CoordinateReferenceSystem crs) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); // initialize the builder b.init(original); // clear the attributes b.attributes().clear(); // add attributes in order for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (descriptor instanceof GeometryDescriptor) { GeometryDescriptor geometryDescriptor = (GeometryDescriptor) descriptor; AttributeTypeBuilder adjust = new AttributeTypeBuilder(b.factory); adjust.init(geometryDescriptor); adjust.setCRS(crs); b.add(adjust.buildDescriptor(geometryDescriptor.getLocalName())); continue; } b.add(descriptor); } return b.buildFeatureType(); }
ab.init(types[i]); ab.setCRS(override); types[i] = ab.buildDescriptor(types[i].getLocalName(), ab.buildGeometryType());
"Original feature type does not have a property named " + name); } else { ab.init(descriptor); ab.setName(name); return ab.buildDescriptor(name);
/** * Constructs the builder. * */ public AttributeTypeBuilder() { this( new FeatureTypeFactoryImpl() ); init(); }
/** * Initializes builder state from another attribute descriptor. */ public void init( AttributeDescriptor descriptor ) { init( descriptor.getType() ); minOccurs = descriptor.getMinOccurs(); maxOccurs = descriptor.getMaxOccurs(); isNillable = descriptor.isNillable(); }
/** * Copys a feature type. * <p> * This method does a deep copy in that all individual attributes are copied as well. * </p> */ public static SimpleFeatureType copy( SimpleFeatureType original ) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); //initialize the builder b.init( original ); //clear attributes b.attributes().clear(); //add attributes in order for( AttributeDescriptor descriptor : original.getAttributeDescriptors() ){ AttributeTypeBuilder ab = new AttributeTypeBuilder( b.factory ); ab.init( descriptor ); b.add( ab.buildDescriptor( descriptor.getLocalName() )); } return b.buildFeatureType(); } }
public SimpleFeatureType apply(ImportTask task, DataStore dataStore, SimpleFeatureType featureType) throws Exception { //remap the type SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(featureType); int index = featureType.indexOf(field); if (index < 0) { throw new Exception("FeatureType " + featureType.getName() + " does not have attribute named '" + field + "'"); } //remap the attribute to type date and ensure schema ordering is the same //@todo improve FeatureTypeBuilder to support this directly AttributeDescriptor existing = builder.remove(field); AttributeTypeBuilder attBuilder = new AttributeTypeBuilder(); attBuilder.init(existing); attBuilder.setBinding(type); builder.add(index, attBuilder.buildDescriptor(field)); return builder.buildFeatureType(); }
@Override protected SimpleFeatureType buildFeatureType() { SimpleFeatureTypeBuilder featureBuilder = createBuilder(csvFileState); // For WKT strategy, we need to make sure the wktField is recognized as a Geometry AttributeDescriptor descriptor = featureBuilder.get(wktField); if (descriptor != null) { AttributeTypeBuilder attributeBuilder = new AttributeTypeBuilder(); attributeBuilder.init(descriptor); attributeBuilder.setCRS(DefaultGeographicCRS.WGS84); attributeBuilder.binding(Geometry.class); AttributeDescriptor modified = attributeBuilder.buildDescriptor(wktField); featureBuilder.set(modified); } return featureBuilder.buildFeatureType(); } // docs end buildFeatureType
public SimpleFeatureType convertType(SimpleFeatureType featureType, VectorFormat format, ImportData data, ImportTask task) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName(convertTypeName(featureType.getTypeName())); AttributeTypeBuilder attBuilder = new AttributeTypeBuilder(); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { attBuilder.init(att); typeBuilder.add(attBuilder.buildDescriptor(convertAttributeName(att.getLocalName()))); } return typeBuilder.buildFeatureType(); }
public SimpleFeatureType convertType(SimpleFeatureType featureType, VectorFormat format, ImportData data, ImportTask task) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); AttributeTypeBuilder attributeBuilder = new AttributeTypeBuilder(); typeBuilder.setName(ensureOracleSafe(featureType.getTypeName())); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { attributeBuilder.init(att); final String name = (ensureOracleSafe(att.getName().getLocalPart())); typeBuilder.add(attributeBuilder.buildDescriptor(name)); } return typeBuilder.buildFeatureType(); }
public SimpleFeatureType convertType( SimpleFeatureType featureType, VectorFormat format, ImportData data, ImportTask task) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); AttributeTypeBuilder attributeBuilder = new AttributeTypeBuilder(); typeBuilder.setName(ensureOracleSafe(featureType.getTypeName())); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { attributeBuilder.init(att); final String name = (ensureOracleSafe(att.getName().getLocalPart())); typeBuilder.add(attributeBuilder.buildDescriptor(name)); } return typeBuilder.buildFeatureType(); }
public SimpleFeatureType convertType( SimpleFeatureType featureType, VectorFormat format, ImportData data, ImportTask task) { SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName( convertTypeName( task != null && task.getLayer().getName() != null ? task.getLayer().getName() : featureType.getTypeName())); AttributeTypeBuilder attBuilder = new AttributeTypeBuilder(); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { attBuilder.init(att); typeBuilder.add(attBuilder.buildDescriptor(convertAttributeName(att.getLocalName()))); } return typeBuilder.buildFeatureType(); }