本文整理汇总了Java中org.opengis.feature.type.AttributeDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java AttributeDescriptor类的具体用法?Java AttributeDescriptor怎么用?Java AttributeDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttributeDescriptor类属于org.opengis.feature.type包,在下文中一共展示了AttributeDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGeometryField
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* Adds the geometry field.
*
* @param b the b
* @param fieldName the field name
* @return the attribute descriptor
*/
private AttributeDescriptor addGeometryField(ExtendedSimpleFeatureTypeBuilder b,
String fieldName) {
geometryField.setGeometryFieldName(fieldName);
Class<?> fieldType;
switch (dsInfo.getGeometryType()) {
case POLYGON:
fieldType = MultiPolygon.class;
break;
case LINE:
fieldType = LineString.class;
break;
case POINT:
default:
fieldType = Point.class;
break;
}
b.setDefaultGeometry(fieldName);
AttributeDescriptor attributeDescriptor = b.createAttributeDescriptor(fieldName, fieldType);
return attributeDescriptor;
}
示例2: getUniqueAttributeName
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* Gets the unique attribute name.
*
* @return the unique attribute name
*/
private String getUniqueAttributeName() {
String newColumnName = "";
List<String> columnNameList = new ArrayList<String>();
List<AttributeDescriptor> descriptorList = featureCollection.getSchema()
.getAttributeDescriptors();
for (AttributeDescriptor attribute : descriptorList) {
columnNameList.add(attribute.getLocalName());
}
int colIndex = descriptorList.size() + 1;
boolean found = false;
while (!found) {
newColumnName = String.format("attr%02d", colIndex);
if (columnNameList.contains(newColumnName)) {
colIndex++;
} else {
return newColumnName;
}
}
return newColumnName;
}
示例3: getAttributes
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
@Override
public IList<String> getAttributes(final IScope scope) {
final Map<String, String> attributes = new LinkedHashMap<>();
final SimpleFeatureCollection store = getFeatureCollection(scope);
final java.util.List<AttributeDescriptor> att_list = store.getSchema().getAttributeDescriptors();
for (final AttributeDescriptor desc : att_list) {
String type;
if (desc.getType() instanceof GeometryType) {
type = "geometry";
} else {
type = Types.get(desc.getType().getBinding()).toString();
}
attributes.put(desc.getName().getLocalPart(), type);
}
return GamaListFactory.createWithoutCasting(Types.STRING, attributes.keySet());
}
示例4: findDescription
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
public static ShapeFileDesc findDescription(File file) throws IOException {
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureType schema = store.getSchema();
GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
GeometryType type = geometryDescriptor.getType();
CoordinateReferenceSystem coordinateReferenceSystem = geometryDescriptor.getCoordinateReferenceSystem();
List<AttributeDescriptor> attributeDescriptors = schema.getAttributeDescriptors();
List<String> labels = new ArrayList();
for (AttributeDescriptor a : attributeDescriptors) {
labels.add(a.getLocalName());
//labels
System.out.println(a.getLocalName());
}
//projection system
// System.out.println(coordinateReferenceSystem.getCoordinateSystem().getName().toString());
//type
System.out.println(parseGeometry(type));
double w = store.getFeatureSource().getBounds().getWidth();
double h = store.getFeatureSource().getBounds().getHeight();
return new ShapeFileDesc(coordinateReferenceSystem == null ? null : coordinateReferenceSystem.getCoordinateSystem().getName().toString(),
parseGeometry(type), labels, Math.sqrt(w * w + h * h));
}
示例5: FeatureGeometrySubstitutor
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* @param oldFeatureType the {@link FeatureType} of the existing features.
* @throws FactoryRegistryException
* @throws SchemaException
*/
public FeatureGeometrySubstitutor( SimpleFeatureType oldFeatureType, Class< ? > newGeometryType ) throws Exception {
List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType.getAttributeDescriptors();
// create the feature type
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(oldFeatureType.getName());
b.setCRS(oldFeatureType.getCoordinateReferenceSystem());
if (newGeometryType == null) {
b.addAll(oldAttributeDescriptors);
} else {
for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) {
if (attributeDescriptor instanceof GeometryDescriptor) {
b.add("the_geom", newGeometryType);
} else {
b.add(attributeDescriptor);
}
}
}
newFeatureType = b.buildFeatureType();
}
示例6: feature2AlphanumericToHashmap
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
public static LinkedHashMap<String, String> feature2AlphanumericToHashmap( SimpleFeature feature ) {
LinkedHashMap<String, String> attributes = new LinkedHashMap<>();
List<AttributeDescriptor> attributeDescriptors = feature.getFeatureType().getAttributeDescriptors();
int index = 0;
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
if (!(attributeDescriptor instanceof GeometryDescriptor)) {
String fieldName = attributeDescriptor.getLocalName();
Object attribute = feature.getAttribute(index);
if (attribute == null) {
attribute = "";
}
String value = attribute.toString();
attributes.put(fieldName, value);
}
index++;
}
return attributes;
}
示例7: buildOutputFeatureType
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* build the new featuretype for the output geometries
*
* @param inputSchema
* @param attributesSet
* @return
*/
protected SimpleFeatureType buildOutputFeatureType(final SimpleFeatureType inputSchema, final HashSet<String> attributesSet, final String aggregateAttributeName) {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("aggregate");
typeBuilder.setCRS(inputSchema.getCoordinateReferenceSystem());
final GeometryDescriptor geomDescriptor = inputSchema.getGeometryDescriptor();
typeBuilder.add(geomDescriptor.getName().toString(),
geomDescriptor.getType().getClass(),
inputSchema.getCoordinateReferenceSystem());
Iterator<String> attributesSetIt = attributesSet.iterator();
while(attributesSetIt.hasNext()) {
final String attributeName = attributesSetIt.next();
AttributeDescriptor descriptor = inputSchema.getDescriptor(attributeName);
LOGGER.finer("Adding attribute "+attributeName+" to new SimpleFeatureType");
typeBuilder.add(attributeName, descriptor.getType().getClass());
}
// column to store the counts
LOGGER.finer("Adding attribute "+aggregateAttributeName+" to new SimpleFeatureType");
typeBuilder.add(aggregateAttributeName, Integer.class);
return typeBuilder.buildFeatureType();
}
示例8: buildPolygonFeatureType
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* return a FeatureType like the inputFeatureType just with Polygon as geometrytype
*
* @param inputFeatureType
* @return
*/
private SimpleFeatureType buildPolygonFeatureType(final SimpleFeatureType inputFeatureType) {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("polyonAggregate");
typeBuilder.setCRS(inputFeatureType.getCoordinateReferenceSystem());
final GeometryDescriptor geomDescriptor = inputFeatureType.getGeometryDescriptor();
typeBuilder.add(geomDescriptor.getName().toString(), Polygon.class,
inputFeatureType.getCoordinateReferenceSystem());
for (final AttributeDescriptor descriptor: inputFeatureType.getAttributeDescriptors()) {
if (!(descriptor instanceof GeometryDescriptor)) {
LOGGER.fine("Adding attribute "+descriptor.getName().toString()+" to new SimpleFeatureType");
typeBuilder.add(descriptor);
}
}
typeBuilder.add(POLYGON_WIDTH_ATTRIBUTE_NAME, Double.class);
return typeBuilder.buildFeatureType();
}
开发者ID:geops,项目名称:trafimage-geoserver-transformations,代码行数:26,代码来源:AggregateSimilarLinesAsPolygonsProcess.java
示例9: selectColumns
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
void selectColumns(SimpleFeatureType featureType, String prefix, Query query, StringBuilder sql)
throws IOException {
//other columns
for (AttributeDescriptor att : featureType.getAttributeDescriptors()) {
String columnName = att.getLocalName();
if (att instanceof GeometryDescriptor) {
sql.append(columnName + "_x,");
sql.append(columnName + "_y");
} else {
sql.append(columnName);
}
sql.append(",");
}
}
示例10: changeGeometryType
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) {
SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder();
sftb.setCRS(original.getCoordinateReferenceSystem());
sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName());
boolean defaultGeometryAdded = false;
for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) {
if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) {
sftb.add(descriptor.getLocalName(), geometryType);
defaultGeometryAdded = true;
}else {
sftb.add(descriptor);
}
}
if(!defaultGeometryAdded) {
sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType);
}
sftb.setName("FT_" + geometryType.getSimpleName());
return sftb.buildFeatureType();
}
示例11: updateDataField
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
public void updateDataField() {
if (pointDataSourceProperty.getValue() != null) {
final List<AttributeDescriptor> attributeDescriptors = ((VectorDataNode) pointDataSourceProperty.getValue()).getFeatureType().getAttributeDescriptors();
final List<AttributeDescriptor> result = new ArrayList<AttributeDescriptor>();
result.add(new NullAttributeDescriptor());
for (AttributeDescriptor attributeDescriptor : attributeDescriptors) {
if (Number.class.isAssignableFrom(attributeDescriptor.getType().getBinding())) {
result.add(attributeDescriptor);
}
}
dataFieldProperty.getDescriptor().setValueSet(new ValueSet(result.toArray()));
} else {
dataFieldProperty.getDescriptor().setValueSet(null);
try {
dataFieldProperty.setValue(null);
} catch (ValidationException ignore) {
}
}
}
示例12: testUpdatePointDataSource
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
@Test
public void testUpdatePointDataSource() throws Exception {
final BindingContext bindingContext = new BindingContext();
bindingContext.getPropertySet().addProperties(Property.create("pointDataSource", VectorDataNode.class));
bindingContext.getPropertySet().addProperties(Property.create("dataField", AttributeDescriptor.class));
final CorrelativeFieldSelector correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext);
final Product product = new Product("name", "type", 10, 10);
product.getVectorDataGroup().add(new VectorDataNode("a", createFeatureType(Geometry.class)));
product.getVectorDataGroup().add(new VectorDataNode("b", createFeatureType(Point.class)));
assertEquals(0, correlativeFieldSelector.pointDataSourceList.getItemCount());
assertEquals(0, correlativeFieldSelector.dataFieldList.getItemCount());
correlativeFieldSelector.updatePointDataSource(product);
assertEquals(3, correlativeFieldSelector.pointDataSourceList.getItemCount());
assertEquals(0, correlativeFieldSelector.dataFieldList.getItemCount());
correlativeFieldSelector.pointDataSourceProperty.setValue(product.getVectorDataGroup().get("b"));
assertEquals(3, correlativeFieldSelector.dataFieldList.getItemCount());
}
示例13: example2
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
private static void example2() throws IOException {
System.out.println("example2 start\n");
// example2 start
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put("directory", directory);
DataStore store = DataStoreFinder.getDataStore(params);
SimpleFeatureType type = store.getSchema("example");
System.out.println(" typeName: " + type.getTypeName());
System.out.println(" name: " + type.getName());
System.out.println("attribute count: " + type.getAttributeCount());
AttributeDescriptor id = type.getDescriptor(0);
System.out.println("attribute 'id' name:" + id.getName());
System.out.println("attribute 'id' type:" + id.getType().toString());
System.out.println("attribute 'id' binding:"
+ id.getType().getDescription());
AttributeDescriptor name = type.getDescriptor("name");
System.out.println("attribute 'name' name:" + name.getName());
System.out.println("attribute 'name' binding:"
+ name.getType().getBinding());
// example2 end
System.out.println("\nexample2 end\n");
}
示例14: getReader
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @return Field Reader for the given Field ID
*/
@Override
public FieldReader<Object> getReader(
final ByteArrayId fieldId ) {
// Go to the map to get a reader for given fieldId
FieldReader<Object> reader = mapOfFieldIdToReaders.get(fieldId);
// Check the map to see if a reader has already been found.
if (reader == null) {
// Reader not in Map, go to the reprojected feature type and get the
// default reader
final AttributeDescriptor descriptor = reprojectedFeatureType.getDescriptor(fieldId.getString());
final Class<?> bindingClass = descriptor.getType().getBinding();
reader = (FieldReader<Object>) FieldUtils.getDefaultReaderForClass(bindingClass);
// Add it to map for the next time
mapOfFieldIdToReaders.put(
fieldId,
reader);
}
return reader;
}
示例15: getLocalVisibilityHandler
import org.opengis.feature.type.AttributeDescriptor; //导入依赖的package包/类
private FieldVisibilityHandler<SimpleFeature, Object> getLocalVisibilityHandler(
final ByteArrayId fieldId ) {
final VisibilityConfiguration visConfig = new VisibilityConfiguration(
reprojectedFeatureType);
// See if there is a visibility config stored in the reprojected feature
// type
if (reprojectedFeatureType.getDescriptor(visConfig.getAttributeName()) == null) {
// No, so return the default field visibility handler
return fieldVisiblityHandler;
}
// Yes, then get the descriptor for the given field ID
final AttributeDescriptor descriptor = reprojectedFeatureType.getDescriptor(fieldId.getString());
return visConfig.getManager().createVisibilityHandler(
descriptor.getLocalName(),
fieldVisiblityHandler,
visConfig.getAttributeName());
}