本文整理汇总了Java中org.opengis.feature.type.AttributeDescriptor.getLocalName方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeDescriptor.getLocalName方法的具体用法?Java AttributeDescriptor.getLocalName怎么用?Java AttributeDescriptor.getLocalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opengis.feature.type.AttributeDescriptor
的用法示例。
在下文中一共展示了AttributeDescriptor.getLocalName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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(",");
}
}
示例3: initializePositionMaps
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
private void initializePositionMaps() {
try {
for (int i = 0; i < reprojectedFeatureType.getAttributeCount(); i++) {
final AttributeDescriptor ad = reprojectedFeatureType.getDescriptor(i);
final ByteArrayId currFieldId = new ByteArrayId(
ad.getLocalName());
fieldToPositionMap.forcePut(
currFieldId,
i);
}
positionToFieldMap = fieldToPositionMap.inverse();
}
catch (final Exception e) {
LOGGER.error(
"Unable to initialize position map, continuing anyways",
e);
}
}
示例4: configureFromType
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* {@inheritDoc} Configure this VisibilityConfiguration object based on the
* passed in SimpleFeatureType. This includes setting the 'attributeName' to
* the attribute that has a key of 'visiblity'.
*
* @param persistType
* - object used to configure this VisibilityConfiguration object
*
*/
@Override
public void configureFromType(
final SimpleFeatureType persistType ) {
// Search the list of attributes for one that has user data
// with a key of 'visibility' and that the value of
// it is Boolean.TRUE. If found, set this object's attributeName to
// the found attribute.
for (final AttributeDescriptor attrDesc : persistType.getAttributeDescriptors()) {
if (attrDesc.getUserData().containsKey(
"visibility") && Boolean.TRUE.equals(attrDesc.getUserData().get(
"visibility"))) {
attributeName = attrDesc.getLocalName();
}
}
configureManager(persistType);
}
示例5: openInputShapefile
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Open the input shape file and load it into memory.
*/
public void openInputShapefile(String inputShapefile) throws IOException {
File file = new File(inputShapefile);
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
Map<String, Serializable> params = new HashMap<>();
params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL());
params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.ENABLE_SPATIAL_INDEX.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, Boolean.TRUE);
params.put(ShapefileDataStoreFactory.CACHE_MEMORY_MAPS.key, Boolean.TRUE);
ShapefileDataStore store = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
featureSource = store.getFeatureSource();
// determine the correct case of the tz attribute because its case has been
// changed from efele to evansiroky
SimpleFeatureType schema = featureSource.getSchema();
List<AttributeDescriptor> attributeDescriptorList = schema.getAttributeDescriptors();
for (AttributeDescriptor attributeDescriptor : attributeDescriptorList) {
if ("tzid".equalsIgnoreCase(attributeDescriptor.getLocalName())) {
tzidAttr = attributeDescriptor.getLocalName();
}
}
filterFactory = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
geometryFactory = JTSFactoryFinder.getGeometryFactory();
}
示例6: resolveName
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
private String resolveName(String name) {
for (AttributeDescriptor descriptor : this.featureType
.getAttributeDescriptors()) {
if (descriptor.getLocalName().equalsIgnoreCase(name))
return descriptor.getLocalName();
}
return name;
}
示例7: visit
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Writes the FilterBuilder for the attribute Expression.
*
* @param expression the attribute.
*
*/
@Override
public Object visit(PropertyName expression, Object extraData) {
LOGGER.finest("exporting PropertyName");
SimpleFeatureType featureType = this.featureType;
Class target = null;
if(extraData instanceof Class) {
target = (Class) extraData;
}
//first evaluate expression against feature type get the attribute,
AttributeDescriptor attType = (AttributeDescriptor) expression.evaluate(featureType);
String encodedField;
if ( attType != null ) {
encodedField = attType.getLocalName();
if(target != null && target.isAssignableFrom(attType.getType().getBinding())) {
// no need for casting, it's already the right type
target = null;
}
} else {
// fall back to just encoding the property name
encodedField = expression.getPropertyName();
}
if (target != null) {
LOGGER.fine("PropertyName type casting not implemented");
}
field = encodedField;
return extraData;
}
示例8: findAttributeName
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Find the name of an attribute, case insensitive.
*
* @param featureType the feature type to check.
* @param field the case insensitive field name.
* @return the real name of the field, or <code>null</code>, if none found.
*/
public static String findAttributeName( SimpleFeatureType featureType, String field ) {
List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
String name = attributeDescriptor.getLocalName();
if (name.toLowerCase().equals(field.toLowerCase())) {
return name;
}
}
return null;
}
示例9: getAttributesNames
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Getter for the list of attribute names.
*
* @return the list of attribute names.
*/
public List<String> getAttributesNames() {
SimpleFeatureType featureType = feature.getFeatureType();
List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
List<String> attributeNames = new ArrayList<String>();
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
String name = attributeDescriptor.getLocalName();
attributeNames.add(name);
}
return attributeNames;
}
示例10: getAttributeIndex
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
private int getAttributeIndex(VectorDataNode pointDataSource, AttributeDescriptor dataField) {
final String fieldName = dataField.getLocalName();
if (fieldName.equals(CorrelativeFieldSelector.NULL_NAME)) {
return -1;
}
return pointDataSource.getFeatureType().indexOf(fieldName);
}
示例11: buildFeatureDefinition
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Add the attributes, types and classifications for the SimpleFeatureType
* to the provided FeatureDefinition
*
* @param fd
* - existing Feature Definition (or new one if null)
* @param sft
* - SimpleFeatureType of the simpleFeature being serialized
* @param defaultClassifications
* - map of attribute names to classification
* @param defaultClassification
* - default classification if one could not be found in the map
* @return
* @throws IOException
*/
public static FeatureDefinition buildFeatureDefinition(
FeatureDefinition fd,
final SimpleFeatureType sft,
final Map<String, String> defaultClassifications,
final String defaultClassification )
throws IOException {
if (fd == null) {
fd = new FeatureDefinition();
}
fd.setFeatureTypeName(sft.getTypeName());
final List<String> attributes = new ArrayList<>(
sft.getAttributeCount());
final List<String> types = new ArrayList<>(
sft.getAttributeCount());
final List<String> classifications = new ArrayList<>(
sft.getAttributeCount());
for (final AttributeDescriptor attr : sft.getAttributeDescriptors()) {
final String localName = attr.getLocalName();
attributes.add(localName);
types.add(attr.getType().getBinding().getCanonicalName());
classifications.add(getClassification(
localName,
defaultClassifications,
defaultClassification));
}
fd.setAttributeNames(attributes);
fd.setAttributeTypes(types);
fd.setAttributeDefaultClassifications(classifications);
return fd;
}
示例12: getTimeField
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
public static String getTimeField(
final DataStorePluginOptions dataStore,
final ByteArrayId adapterId ) {
final AdapterStore adapterStore = dataStore.createAdapterStore();
final DataAdapter adapter = adapterStore.getAdapter(adapterId);
if ((adapter != null) && (adapter instanceof GeotoolsFeatureDataAdapter)) {
final GeotoolsFeatureDataAdapter gtAdapter = (GeotoolsFeatureDataAdapter) adapter;
final SimpleFeatureType featureType = gtAdapter.getFeatureType();
final TimeDescriptors timeDescriptors = gtAdapter.getTimeDescriptors();
// If not indexed, try to find a time field
if ((timeDescriptors == null) || !timeDescriptors.hasTime()) {
for (final AttributeDescriptor attrDesc : featureType.getAttributeDescriptors()) {
final Class<?> bindingClass = attrDesc.getType().getBinding();
if (TimeUtils.isTemporal(bindingClass)) {
return attrDesc.getLocalName();
}
}
}
else {
if (timeDescriptors.getTime() != null) {
return timeDescriptors.getTime().getLocalName();
}
else if (timeDescriptors.getStartRange() != null) {
// give back start|stop string
return timeDescriptors.getStartRange().getLocalName() + "|"
+ timeDescriptors.getEndRange().getLocalName();
}
}
}
return null;
}
示例13: writeScene
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
public static void writeScene(
final SimpleFeatureType sceneType,
final SimpleFeature firstBandOfScene,
final IndexWriter sceneWriter ) {
final SimpleFeatureBuilder bldr = new SimpleFeatureBuilder(
sceneType);
String fid = null;
for (int i = 0; i < sceneType.getAttributeCount(); i++) {
final AttributeDescriptor attr = sceneType.getDescriptor(i);
final String attrName = attr.getLocalName();
final Object attrValue = firstBandOfScene.getAttribute(attrName);
if (attrValue != null) {
bldr.set(
i,
attrValue);
if (attrName.equals(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME)) {
fid = attrValue.toString();
}
}
}
if (fid != null) {
try {
sceneWriter.write(bldr.buildFeature(fid));
}
catch (IOException e) {
LOGGER.error(
"Unable to write scene",
e);
}
}
}
示例14: createDescriptor
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
private org.geomajas.gwt2.client.map.attribute.AttributeDescriptor createDescriptor(
AttributeDescriptor attributeDescriptor) {
Class<?> binding = attributeDescriptor.getType().getBinding();
String name = attributeDescriptor.getLocalName();
AttributeDescriptorImpl attributeInfo;
if (Integer.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.INTEGER), name);
} else if (Float.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.FLOAT), name);
} else if (Double.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.DOUBLE), name);
} else if (BigDecimal.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.DOUBLE), name);
} else if (Boolean.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.BOOLEAN), name);
} else if (Date.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.DATE), name);
} else if (Point.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.POINT), name);
} else if (LineString.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.LINESTRING), name);
} else if (LinearRing.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.LINEARRING), name);
} else if (Polygon.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.POLYGON), name);
} else if (MultiPoint.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.MULTIPOINT), name);
} else if (MultiLineString.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.MULTILINESTRING),
name);
} else if (MultiPolygon.class.equals(binding)) {
attributeInfo = new AttributeDescriptorImpl(new GeometryAttributeTypeImpl(GeometryType.MULTIPOLYGON), name);
} else {
attributeInfo = new AttributeDescriptorImpl(new PrimitiveAttributeTypeImpl(PrimitiveType.STRING), name);
}
return attributeInfo;
}
示例15: getAttributeName
import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
* Returns the attribute name of the database attribute which corresponds to the shapefile attribute
*
* @param descriptor
* @return
*/
public String getAttributeName(AttributeDescriptor descriptor)
{
String key = descriptor.getLocalName();
if (this.attributeMapping.containsKey(key))
{
return this.attributeMapping.get(key);
}
return null;
}