use of org.geotools.data.DataStore in project sldeditor by robward-scisys.
the class VectorReader method createSLDData.
/**
* Creates the SLD data.
*
* @param map the map
* @return the styled layer descriptor
*/
private StyledLayerDescriptor createSLDData(Map<String, Object> map, String featureClass) {
StyledLayerDescriptor sld = null;
DataStore dataStore = null;
try {
dataStore = DataStoreFinder.getDataStore(map);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
return null;
}
if (dataStore != null) {
// Try connecting to a vector data source
String typeName;
GeometryTypeEnum geometryTypeEnum = GeometryTypeEnum.UNKNOWN;
try {
if (featureClass == null) {
typeName = dataStore.getTypeNames()[0];
} else {
typeName = featureClass;
}
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
GeometryType geometryType = schema.getGeometryDescriptor().getType();
Class<?> bindingType = geometryType.getBinding();
geometryTypeEnum = GeometryTypeMapping.getGeometryType(bindingType);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
return null;
} finally {
dataStore.dispose();
}
switch(geometryTypeEnum) {
case POINT:
sld = DefaultSymbols.createNewPoint();
break;
case LINE:
sld = DefaultSymbols.createNewLine();
break;
case POLYGON:
sld = DefaultSymbols.createNewPolygon();
break;
default:
break;
}
}
return sld;
}
use of org.geotools.data.DataStore in project mkgmap by openstreetmap.
the class PrecompSeaGenerator method createShapefileAccess.
private void createShapefileAccess() throws IOException {
Map<String, URL> map = new HashMap<String, URL>();
map.put("url", shapeFile.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
shapeCollection = source.getFeatures();
}
Aggregations