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


Java DataUtilities.dataStore方法代码示例

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


在下文中一共展示了DataUtilities.dataStore方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNewColumn

import org.geotools.data.DataUtilities; //导入方法依赖的package包/类
/**
 * Adds the new column.
 */
public void addNewColumn() {
    if (featureCollection != null) {
        String attributeName = getUniqueAttributeName();

        columnList.add(attributeName);

        // Populate field names
        SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder();
        featureTypeBuilder.init(featureCollection.getSchema());
        featureTypeBuilder.add(attributeName, String.class);

        SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType();

        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();
                    sfb.addAll(sf.getAttributes());
                    sfb.add(new String(""));
                    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,代码行数:60,代码来源:InLineFeatureModel.java

示例2: removeColumn

import org.geotools.data.DataUtilities; //导入方法依赖的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

示例3: updateCRS

import org.geotools.data.DataUtilities; //导入方法依赖的package包/类
/**
 * Update CRS.
 *
 * @param selectedValue the selected value
 */
public void updateCRS(ValueComboBoxData selectedValue) {
    if (selectedValue != null) {
        String crsCode = selectedValue.getKey();

        CoordinateReferenceSystem newCRS = CoordManager.getInstance().getCRS(crsCode);

        SimpleFeatureType newFeatureType = SimpleFeatureTypeBuilder
                .retype(featureCollection.getSchema(), newCRS);

        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> attributeValueList = sf.getAttributes();
                    sfb.addAll(attributeValueList);
                    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,代码行数:58,代码来源:InLineFeatureModel.java

示例4: addNewFeature

import org.geotools.data.DataUtilities; //导入方法依赖的package包/类
/**
 * Adds the new feature.
 */
public void addNewFeature() {
    SimpleFeatureType featureType = userLayer.getInlineFeatureType();

    String typeName = userLayer.getInlineFeatureType().getTypeName();
    try {
        SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore()
                .getFeatureSource(typeName);

        SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(featureType);

        ArrayList<SimpleFeature> featureList = new ArrayList<SimpleFeature>();

        SimpleFeatureIterator it = featureSource.getFeatures().features();
        try {
            while (it.hasNext()) {
                SimpleFeature sf = it.next();
                List<Object> attributeValueList = sf.getAttributes();
                sfb.addAll(attributeValueList);
                featureList.add(sfb.buildFeature(null));
            }
            // Add new feature
            String wktString = "wkt://POINT(0 0)";
            Geometry geometry = WKTConversion.convertToGeometry(wktString,
                    getSelectedCRSCode());
            sfb.add(geometry);
            featureList.add(sfb.buildFeature(null));
        } finally {
            it.close();
        }

        SimpleFeatureCollection collection = new ListFeatureCollection(featureType,
                featureList);

        featureCollection = collection;
        cachedFeature = null;
        lastRow = -1;
        DataStore dataStore = DataUtilities.dataStore(collection);
        userLayer.setInlineFeatureDatastore(dataStore);

    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }

    this.fireTableStructureChanged();
    this.fireTableDataChanged();

    if (parentObj != null) {
        parentObj.inlineFeatureUpdated();
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:54,代码来源:InLineFeatureModel.java

示例5: removeFeature

import org.geotools.data.DataUtilities; //导入方法依赖的package包/类
/**
 * Removes the feature.
 *
 * @param selectedRow the selected row
 */
public void removeFeature(int selectedRow) {
    if ((selectedRow < 0) || (selectedRow >= getRowCount())) {
        return;
    }

    SimpleFeatureType featureType = userLayer.getInlineFeatureType();

    String typeName = userLayer.getInlineFeatureType().getTypeName();
    try {
        SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore()
                .getFeatureSource(typeName);

        SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(featureType);

        ArrayList<SimpleFeature> featureList = new ArrayList<SimpleFeature>();

        SimpleFeatureIterator it = featureSource.getFeatures().features();
        try {
            int index = 0;
            while (it.hasNext()) {
                SimpleFeature sf = it.next();

                if (index != selectedRow) {
                    List<Object> attributeValueList = sf.getAttributes();
                    sfb.addAll(attributeValueList);
                    featureList.add(sfb.buildFeature(null));
                }
                index++;
            }
        } finally {
            it.close();
        }

        SimpleFeatureCollection collection = new ListFeatureCollection(featureType,
                featureList);

        featureCollection = collection;
        cachedFeature = null;
        lastRow = -1;
        DataStore dataStore = DataUtilities.dataStore(collection);
        userLayer.setInlineFeatureDatastore(dataStore);

    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }

    this.fireTableStructureChanged();
    this.fireTableDataChanged();

    if (parentObj != null) {
        parentObj.inlineFeatureUpdated();
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:59,代码来源:InLineFeatureModel.java


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