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


Java SimpleFeatureType.getAttributeDescriptors方法代码示例

本文整理汇总了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();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:34,代码来源:ClipProcess.java

示例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;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:35,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例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;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:15,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例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);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:78,代码来源:CreateSampleData.java

示例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();
            }
        }
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:72,代码来源:InLineFeatureModel.java


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