use of org.geotools.data.simple.SimpleFeatureSource in project sldeditor by robward-scisys.
the class DataSourceInfo method getFeatureCollection.
/**
* Gets the feature collection.
*
* @return the feature collection
*/
public SimpleFeatureCollection getFeatureCollection() {
SimpleFeatureCollection featureCollection = null;
try {
if (dataStore != null) {
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
featureCollection = source.getFeatures();
}
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
return featureCollection;
}
use of org.geotools.data.simple.SimpleFeatureSource in project sldeditor by robward-scisys.
the class DataSourceInfo method getFeatureCollection.
/**
* Gets the feature collection.
*
* @return the feature collection
*/
public SimpleFeatureCollection getFeatureCollection() {
SimpleFeatureCollection featureCollection = null;
try {
if (dataStore != null) {
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
featureCollection = source.getFeatures();
}
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
return featureCollection;
}
use of org.geotools.data.simple.SimpleFeatureSource in project sldeditor by robward-scisys.
the class DatabaseClient method hasGeometryField.
/**
* Checks for the presence of a geometry field.
*
* @param dataStore the data store
* @param name the name
* @return true, if geometry field present
*/
private boolean hasGeometryField(DataStore dataStore, Name name) {
try {
SimpleFeatureSource featureSource = dataStore.getFeatureSource(name);
GeometryDescriptor geometryDescriptor = featureSource.getSchema().getGeometryDescriptor();
return (geometryDescriptor != null);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
return false;
}
use of org.geotools.data.simple.SimpleFeatureSource in project sldeditor by robward-scisys.
the class InLineFeatureModel method removeFeature.
/**
* 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();
}
}
use of org.geotools.data.simple.SimpleFeatureSource in project sldeditor by robward-scisys.
the class InLineFeatureModel method updateCRS.
/**
* 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();
}
}
}
Aggregations