本文整理匯總了Java中org.opengis.feature.simple.SimpleFeatureType.getDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleFeatureType.getDescriptor方法的具體用法?Java SimpleFeatureType.getDescriptor怎麽用?Java SimpleFeatureType.getDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.opengis.feature.simple.SimpleFeatureType
的用法示例。
在下文中一共展示了SimpleFeatureType.getDescriptor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extractAllowedAttributes
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* List of allowed attributes.
*
* <p>
* Creates a list of FeatureTypeInfo's attribute names based on the
* attributes requested by <code>query</code> and making sure they not
* contain any non exposed attribute.
* </p>
*
* <p>
* Exposed attributes are those configured in the "attributes" element of
* the FeatureTypeInfo's configuration
* </p>
*
* @param query User's origional query
* @param schema TODO
*
* @return List of allowed attribute types
*/
private String[] extractAllowedAttributes(Query query, SimpleFeatureType schema) {
String[] propNames = null;
if (query.retrieveAllProperties()) {
List<String> props = new ArrayList();
for (int i = 0; i < schema.getAttributeCount(); i++) {
AttributeDescriptor att = schema.getDescriptor(i);
//if this is a joined attribute, don't include it
//TODO: make this a better check, actually verify it vs the query object
if (Feature.class.isAssignableFrom(att.getType().getBinding())
&& !query.getJoins().isEmpty()) {
continue;
}
props.add(att.getLocalName());
}
propNames = props.toArray(new String[props.size()]);
} else {
String[] queriedAtts = query.getPropertyNames();
int queriedAttCount = queriedAtts.length;
List allowedAtts = new LinkedList();
for (int i = 0; i < queriedAttCount; i++) {
if (schema.getDescriptor(queriedAtts[i]) != null) {
allowedAtts.add(queriedAtts[i]);
} else {
LOGGER.info("queried a not allowed property: " + queriedAtts[i]
+ ". Ommitting it from query");
}
}
propNames = (String[]) allowedAtts.toArray(new String[allowedAtts.size()]);
}
return propNames;
}
示例2: createDbaseHeader
import org.opengis.feature.simple.SimpleFeatureType; //導入方法依賴的package包/類
/**
* Attempt to create a DbaseFileHeader for the FeatureType. Note, we cannot set the number of
* records until the write has completed.
*
* @param featureType DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
* @throws DbaseFileException DOCUMENT ME!
*/
protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType)
throws IOException, DbaseFileException {
DbaseFileHeader header = new DbaseFileHeader();
for (int i = 0, ii = featureType.getAttributeCount(); i < ii; i++) {
AttributeDescriptor type = featureType.getDescriptor(i);
Class<?> colType = type.getType().getBinding();
String colName = type.getLocalName();
int fieldLen = FeatureTypes.getFieldLength(type);
if (fieldLen == FeatureTypes.ANY_LENGTH)
fieldLen = 255;
if ((colType == Integer.class) || (colType == Short.class) || (colType == Byte.class)) {
header.addColumn(colName, 'N', Math.min(fieldLen, 9), 0);
} else if (colType == Long.class) {
header.addColumn(colName, 'N', Math.min(fieldLen, 19), 0);
} else if (colType == BigInteger.class) {
header.addColumn(colName, 'N', Math.min(fieldLen, 33), 0);
} else if (Number.class.isAssignableFrom(colType)) {
int l = Math.min(fieldLen, 33);
int d = Math.max(l - 2, 0);
header.addColumn(colName, 'N', l, d);
// This check has to come before the Date one or it is never reached
// also, this field is only activated with the following system property:
// org.geotools.shapefile.datetime=true
} else if (java.util.Date.class.isAssignableFrom(colType)
&& Boolean.getBoolean("org.geotools.shapefile.datetime")) {
header.addColumn(colName, '@', fieldLen, 0);
} else if (java.util.Date.class.isAssignableFrom(colType)
|| Calendar.class.isAssignableFrom(colType)) {
header.addColumn(colName, 'D', fieldLen, 0);
} else if (colType == Boolean.class) {
header.addColumn(colName, 'L', 1, 0);
} else if (CharSequence.class.isAssignableFrom(colType) || colType == java.util.UUID.class) {
// Possible fix for GEOT-42 : ArcExplorer doesn't like 0 length
// ensure that maxLength is at least 1
header.addColumn(colName, 'C', Math.min(254, fieldLen), 0);
} else if (Geometry.class.isAssignableFrom(colType)) {
continue;
//skip binary data types
} else if (colType == byte[].class) {
continue;
} else {
throw new IOException("Unable to write column " +colName + " : " + colType.getName());
}
}
return header;
}