Search in sources :

Example 1 with DataSourceAttributeData

use of com.sldeditor.common.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceImpl method readAttributes.

/**
 * Read attributes.
 *
 * @param attributeData the attribute data
 */
/* (non-Javadoc)
     * @see com.sldeditor.datasource.DataSourceInterface#updateAttributes(com.sldeditor.render.iface.RenderAttributeDataInterface)
     */
@Override
public void readAttributes(DataSourceAttributeListInterface attributeData) {
    if (attributeData == null) {
        return;
    }
    List<DataSourceAttributeData> valueMap = new ArrayList<DataSourceAttributeData>();
    SimpleFeatureCollection featureCollection = dataSourceInfo.getFeatureCollection();
    if (featureCollection != null) {
        SimpleFeatureIterator iterator = featureCollection.features();
        if (iterator.hasNext()) {
            SimpleFeature feature = iterator.next();
            List<Object> attributes = feature.getAttributes();
            for (int i = 0; i < attributes.size(); i++) {
                Name fieldName = fieldNameMap.get(i);
                DataSourceAttributeData data = new DataSourceAttributeData(fieldName, fieldTypeMap.get(i), attributes.get(i));
                valueMap.add(data);
            }
        }
    }
    attributeData.setData(valueMap);
}
Also used : DataSourceAttributeData(com.sldeditor.common.datasource.attribute.DataSourceAttributeData) SimpleFeatureIterator(org.geotools.data.simple.SimpleFeatureIterator) ArrayList(java.util.ArrayList) SimpleFeature(org.opengis.feature.simple.SimpleFeature) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection) Name(org.opengis.feature.type.Name)

Aggregations

DataSourceAttributeData (com.sldeditor.common.datasource.attribute.DataSourceAttributeData)1 ArrayList (java.util.ArrayList)1 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)1 SimpleFeatureIterator (org.geotools.data.simple.SimpleFeatureIterator)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1 Name (org.opengis.feature.type.Name)1