本文整理匯總了Java中org.opengis.feature.simple.SimpleFeatureType.getAttributeDescriptors方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleFeatureType.getAttributeDescriptors方法的具體用法?Java SimpleFeatureType.getAttributeDescriptors怎麽用?Java SimpleFeatureType.getAttributeDescriptors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.opengis.feature.simple.SimpleFeatureType
的用法示例。
在下文中一共展示了SimpleFeatureType.getAttributeDescriptors方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildTargetSchema
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* When clipping lines and polygons can turn into multilines and multipolygons
*/
private SimpleFeatureType buildTargetSchema(SimpleFeatureType schema) {
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
for (AttributeDescriptor ad : schema.getAttributeDescriptors()) {
if(ad instanceof GeometryDescriptor) {
GeometryDescriptor gd = (GeometryDescriptor) ad;
Class<?> binding = ad.getType().getBinding();
if(Point.class.isAssignableFrom(binding) || GeometryCollection.class.isAssignableFrom(binding)) {
tb.add(ad);
} else {
Class target;
if(LineString.class.isAssignableFrom(binding)) {
target = MultiLineString.class;
} else if(Polygon.class.isAssignableFrom(binding)) {
target = MultiPolygon.class;
} else {
throw new RuntimeException("Don't know how to handle geometries of type "
+ binding.getCanonicalName());
}
tb.minOccurs(ad.getMinOccurs());
tb.maxOccurs(ad.getMaxOccurs());
tb.nillable(ad.isNillable());
tb.add(ad.getLocalName(), target, gd.getCoordinateReferenceSystem());
}
} else {
tb.add(ad);
}
}
tb.setName(schema.getName());
return tb.buildFeatureType();
}
示例2: cloneWithDimensionality
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* Clones the given schema, changing the geometry attribute to match the given dimensionality.
*
* @param schema schema to clone
* @param dimensionality dimensionality for the geometry 1= points, 2= lines, 3= polygons
*
*/
private FeatureType cloneWithDimensionality(FeatureType schema, int dimensionality) {
SimpleFeatureType simpleFt = (SimpleFeatureType) schema;
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName(schema.getName());
builder.setCRS(schema.getCoordinateReferenceSystem());
for (AttributeDescriptor desc : simpleFt.getAttributeDescriptors()) {
if (isMixedGeometry(desc)) {
GeometryDescriptor geomDescriptor = (GeometryDescriptor) desc;
GeometryType geomType = geomDescriptor.getType();
Class<?> geometryClass = getGeometryForDimensionality(dimensionality);
GeometryType gt = new GeometryTypeImpl(geomType.getName(), geometryClass,
geomType.getCoordinateReferenceSystem(), geomType.isIdentified(),
geomType.isAbstract(), geomType.getRestrictions(), geomType.getSuper(),
geomType.getDescription());
builder.add(new GeometryDescriptorImpl(gt, geomDescriptor.getName(),
geomDescriptor.getMinOccurs(), geomDescriptor.getMaxOccurs(),
geomDescriptor.isNillable(), geomDescriptor.getDefaultValue()));
} else {
builder.add(desc);
}
}
schema = builder.buildFeatureType();
return schema;
}
示例3: hasMixedGeometry
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* Checks if the given schema contains a GeometryDescriptor that has a generic Geometry type.
*
* @param schema
*
*/
private boolean hasMixedGeometry(SimpleFeatureType schema) {
for (AttributeDescriptor attDesc : schema.getAttributeDescriptors()) {
if (isMixedGeometry(attDesc)) {
return true;
}
}
return false;
}
示例4: create
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* Creates the sample data from the supplied schema.
*
* @param schema the schema
* @param fieldList the field list
*/
public void create(FeatureType schema, List<DataSourceAttributeData> fieldList) {
if (schema == null) {
return;
}
// Put fields into map for speed
Map<String, DataSourceAttributeData> fieldMap =
new HashMap<String, DataSourceAttributeData>();
if (fieldList != null) {
for (DataSourceAttributeData attributeData : fieldList) {
fieldMap.put(attributeData.getName(), attributeData);
}
}
SimpleFeatureType featureType = (SimpleFeatureType) schema;
memory = new MemoryDataStore();
try {
memory.createSchema(featureType);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
memory = null;
return;
}
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
SimpleFeature feature = DataUtilities.template(featureType);
builder.init((SimpleFeature) feature);
int index = 0;
for (AttributeDescriptor descriptor : featureType.getAttributeDescriptors()) {
AttributeType attributeType = descriptor.getType();
Object value = null;
Class<?> fieldType = attributeType.getBinding();
if (attributeType instanceof GeometryTypeImpl) {
geometryType = GeometryTypeMapping.getGeometryType(fieldType);
switch (geometryType) {
case POLYGON:
ExamplePolygonInterface examplePolygon = DataSourceFactory
.createExamplePolygon(null);
value = examplePolygon.getPolygon();
break;
case LINE:
ExampleLineInterface exampleLine = DataSourceFactory.createExampleLine(null);
value = exampleLine.getLine();
break;
case POINT:
default:
ExamplePointInterface examplePoint = DataSourceFactory.createExamplePoint(null);
value = examplePoint.getPoint();
break;
}
} else {
if ((fieldList != null) && (index < fieldList.size())) {
DataSourceAttributeData attrData = fieldMap.get(descriptor.getLocalName());
if (attrData != null) {
value = attrData.getValue();
}
}
value = getFieldTypeValue(index, attributeType.getName().getLocalPart(), fieldType,
value);
}
builder.add(value);
index++;
}
SimpleFeature newFeature = builder.buildFeature("1234");
memory.addFeature(newFeature);
}
示例5: removeColumn
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* Removes the column.
*
* @param columnName the column name
*/
public void removeColumn(String columnName) {
if (featureCollection != null) {
if (columnList.contains(columnName)) {
columnList.remove(columnName);
// Find field name to remote
SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder();
featureTypeBuilder.init(featureCollection.getSchema());
featureTypeBuilder.remove(columnName);
SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType();
int attributeToRemoveIndex = 0;
for (AttributeDescriptor descriptor : newFeatureType.getAttributeDescriptors()) {
if (descriptor.getLocalName().compareTo(columnName) == 0) {
break;
}
attributeToRemoveIndex++;
}
String typeName = userLayer.getInlineFeatureType().getTypeName();
try {
SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore()
.getFeatureSource(typeName);
SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(newFeatureType);
ArrayList<SimpleFeature> featureList = new ArrayList<SimpleFeature>();
SimpleFeatureIterator it = featureSource.getFeatures().features();
try {
while (it.hasNext()) {
SimpleFeature sf = it.next();
List<Object> attributes = sf.getAttributes();
attributes.remove(attributeToRemoveIndex);
sfb.addAll(attributes);
featureList.add(sfb.buildFeature(null));
}
} finally {
it.close();
}
SimpleFeatureCollection collection = new ListFeatureCollection(newFeatureType,
featureList);
featureCollection = collection;
cachedFeature = null;
lastRow = -1;
DataStore dataStore = DataUtilities.dataStore(collection);
userLayer.setInlineFeatureDatastore(dataStore);
userLayer.setInlineFeatureType(newFeatureType);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
this.fireTableStructureChanged();
this.fireTableDataChanged();
if (parentObj != null) {
parentObj.inlineFeatureUpdated();
}
}
}
}