use of org.geotools.data.DataStore in project sldeditor by robward-scisys.
the class CreateSampleDataTest method testGetDataStore.
/**
* Test method for {@link com.sldeditor.datasource.impl.CreateSampleData#getDataStore()}.
*/
@Test
public void testGetDataStore() {
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
String typeName = "test type name";
b.setName(typeName);
String namespace = null;
b.setNamespaceURI(namespace);
// add a geometry property
// set crs first
b.setCRS(DefaultGeographicCRS.WGS84);
b.add("the_geom", Polygon.class);
b.setDefaultGeometry("the_geom");
// Build the feature type
SimpleFeatureType schema = b.buildFeatureType();
CreateSampleData sampleData = new CreateSampleData();
sampleData.create(null, null);
sampleData.create(schema, null);
DataStore dataStore = sampleData.getDataStore();
assertTrue(dataStore != null);
assertEquals(GeometryTypeEnum.POLYGON, sampleData.getGeometryType());
}
use of org.geotools.data.DataStore in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testGetFeatures.
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatures()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatures() {
URL url = SLDEditorFile.class.getClassLoader().getResource("point/sld/shp/sld_cookbook_point.shp");
Map map = new HashMap();
map.put("url", url);
DataStore dataStore;
try {
dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo dsInfo = new DataSourceInfo();
String typeName = dataStore.getTypeNames()[0];
dsInfo.setTypeName(typeName);
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
assertNull(dsInfo.getFeatures());
dsInfo.setSchema(schema);
assertNull(dsInfo.getFeatures());
dsInfo.setDataStore(dataStore);
assertTrue(dsInfo.getFeatures() != null);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.geotools.data.DataStore in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testGetGeometryFieldName.
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getGeometryFieldName()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetGeometryFieldName() {
URL url = SLDEditorFile.class.getClassLoader().getResource("point/sld/shp/sld_cookbook_point.shp");
Map map = new HashMap();
map.put("url", url);
DataStore dataStore;
try {
dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo dsInfo = new DataSourceInfo();
String typeName = dataStore.getTypeNames()[0];
dsInfo.setTypeName(typeName);
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
assertNull(dsInfo.getGeometryFieldName());
dsInfo.setSchema(schema);
assertEquals("the_geom", dsInfo.getGeometryFieldName());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.geotools.data.DataStore in project sldeditor by robward-scisys.
the class DataSourceInfoTest method testGetFeatureCollection.
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureCollection()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatureCollection() {
URL url = SLDEditorFile.class.getClassLoader().getResource("point/sld/shp/sld_cookbook_point.shp");
Map map = new HashMap();
map.put("url", url);
DataStore dataStore;
try {
dataStore = DataStoreFinder.getDataStore(map);
DataSourceInfo dsInfo = new DataSourceInfo();
String typeName = dataStore.getTypeNames()[0];
dsInfo.setTypeName(typeName);
SimpleFeatureSource source = dataStore.getFeatureSource(typeName);
SimpleFeatureType schema = source.getSchema();
assertNull(dsInfo.getGeometryFieldName());
dsInfo.setSchema(schema);
assertEquals("the_geom", dsInfo.getGeometryFieldName());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.geotools.data.DataStore in project incubator-rya by apache.
the class GeoMesaGeoIndexer method initInternal.
private void initInternal() throws IOException {
validPredicates = ConfigUtils.getGeoPredicates(conf);
final DataStore dataStore = createDataStore(conf);
try {
featureType = getStatementFeatureType(dataStore);
} catch (final IOException | SchemaException e) {
throw new IOException(e);
}
featureSource = dataStore.getFeatureSource(featureType.getName());
if (!(featureSource instanceof FeatureStore)) {
throw new IllegalStateException("Could not retrieve feature store");
}
featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
}
Aggregations