当前位置: 首页>>代码示例>>Java>>正文


Java SimpleFeatureType.getAttributeCount方法代码示例

本文整理汇总了Java中org.opengis.feature.simple.SimpleFeatureType.getAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureType.getAttributeCount方法的具体用法?Java SimpleFeatureType.getAttributeCount怎么用?Java SimpleFeatureType.getAttributeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opengis.feature.simple.SimpleFeatureType的用法示例。


在下文中一共展示了SimpleFeatureType.getAttributeCount方法的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;
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:59,代码来源:ISOGeoServerFeatureSource.java

示例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;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:63,代码来源:ShapefileDataStore.java


注:本文中的org.opengis.feature.simple.SimpleFeatureType.getAttributeCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。