本文整理匯總了Java中org.geotools.data.DataStore.getTypeNames方法的典型用法代碼示例。如果您正苦於以下問題:Java DataStore.getTypeNames方法的具體用法?Java DataStore.getTypeNames怎麽用?Java DataStore.getTypeNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.geotools.data.DataStore
的用法示例。
在下文中一共展示了DataStore.getTypeNames方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import org.geotools.data.DataStore; //導入方法依賴的package包/類
public void read(URL file) throws IOException {
Map<String, Object> map = new HashMap<>();
map.put("url", file);
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();
FeatureIterator<SimpleFeature> features = collection.features();
int count = 0;
LOGGER.info("reading world time zones ...");
while (features.hasNext()) {
count++;
SimpleFeature feature = features.next();
ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(feature.getBounds());
quadtree.insert(referencedEnvelope,feature);
}
LOGGER.info(count + " features read");
}
示例2: testLoadShapeFile
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* Test if shapeRDD get correct number of shapes from .shp file
* @throws IOException
*/
@Test
public void testLoadShapeFile() throws IOException {
// load shape with geotool.shapefile
InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/polygon").getPath();
File file = new File(InputLocation);
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore
.getFeatureSource(typeName);
Filter filter = Filter.INCLUDE;
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
// load shapes with our tool
ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
Assert.assertEquals(shapefileRDD.getShapeRDD().collect().size(), collection.size());
dataStore.dispose();
}
示例3: getStatementFeatureType
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException {
SimpleFeatureType featureType;
final String[] datastoreFeatures = dataStore.getTypeNames();
if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) {
featureType = dataStore.getSchema(FEATURE_NAME);
} else {
featureType = DataUtilities.createType(FEATURE_NAME,
SUBJECT_ATTRIBUTE + ":String," +
PREDICATE_ATTRIBUTE + ":String," +
OBJECT_ATTRIBUTE + ":String," +
CONTEXT_ATTRIBUTE + ":String," +
GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326," +
GEO_ID_ATTRIBUTE + ":String");
dataStore.createSchema(featureType);
}
return featureType;
}
示例4: getStatementFeatureType
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException {
SimpleFeatureType featureType;
final String[] datastoreFeatures = dataStore.getTypeNames();
if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) {
featureType = dataStore.getSchema(FEATURE_NAME);
} else {
final String featureSchema = SUBJECT_ATTRIBUTE + ":String," //
+ PREDICATE_ATTRIBUTE + ":String," //
+ OBJECT_ATTRIBUTE + ":String," //
+ CONTEXT_ATTRIBUTE + ":String," //
+ GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326;geomesa.mixed.geometries='true'";
featureType = SimpleFeatureTypes.createType(FEATURE_NAME, featureSchema);
dataStore.createSchema(featureType);
}
return featureType;
}
示例5: showTypeNameChooser
import org.geotools.data.DataStore; //導入方法依賴的package包/類
public static String showTypeNameChooser( DataStore dataStore ){
if( dataStore == null ){
return null; // could not connect
}
String typeNames[];
try {
typeNames = dataStore.getTypeNames();
} catch (IOException e) {
return null; // could not connect
}
if( typeNames.length == 0 ){
return null; // could not connect
}
if (typeNames.length == 1) {
return typeNames[0]; // no need to choose only one option
} else {
String typeName = (String) JOptionPane
.showInputDialog(null, "Please select a type name.", "Type Name",
JOptionPane.QUESTION_MESSAGE, null, typeNames, typeNames[0]);
return typeName;
}
}
示例6: testLoadShapeFilePolyLine
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* test if shapeRDD load .shp fie with shape type = PolyLine correctly.
* @throws IOException
*/
@Test
public void testLoadShapeFilePolyLine() throws IOException{
InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/polyline").getPath();
// load shape with geotool.shapefile
File file = new File(InputLocation);
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore
.getFeatureSource(typeName);
Filter filter = Filter.INCLUDE;
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
FeatureIterator<SimpleFeature> features = collection.features();
ArrayList<String> featureTexts = new ArrayList<String>();
while(features.hasNext()){
SimpleFeature feature = features.next();
featureTexts.add(String.valueOf(feature.getDefaultGeometry()));
}
final Iterator<String> featureIterator = featureTexts.iterator();
ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
LineStringRDD spatialRDD = new LineStringRDD(shapefileRDD.getLineStringRDD());
try {
RangeQuery.SpatialRangeQuery(spatialRDD, new Envelope(-180,180,-90,90), false, false).count();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (Geometry geometry : shapefileRDD.getShapeRDD().collect()) {
Assert.assertEquals(featureIterator.next(), geometry.toText());
}
dataStore.dispose();
}
示例7: testLoadShapeFileMultiPoint
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* Test if shapeRDD load shape type = MultiPoint correctly.
* @throws IOException
*/
@Test
public void testLoadShapeFileMultiPoint() throws IOException{
InputLocation = ShapefileRDDTest.class.getClassLoader().getResource("shapefiles/multipoint").getPath();
// load shape with geotool.shapefile
File file = new File(InputLocation);
Map<String, Object> map = new HashMap<String, Object>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore
.getFeatureSource(typeName);
Filter filter = Filter.INCLUDE;
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
FeatureIterator<SimpleFeature> features = collection.features();
ArrayList<String> featureTexts = new ArrayList<String>();
while(features.hasNext()){
SimpleFeature feature = features.next();
featureTexts.add(String.valueOf(feature.getDefaultGeometry()));
}
final Iterator<String> featureIterator = featureTexts.iterator();
ShapefileRDD shapefileRDD = new ShapefileRDD(sc,InputLocation);
for (Geometry geometry : shapefileRDD.getShapeRDD().collect()) {
Assert.assertEquals(featureIterator.next(), geometry.toText());
}
dataStore.dispose();
}
示例8: getLayernames
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private void getLayernames() {
if (isValid(wCapabilitiesUrl.getText(),
Messages.getString("WFSInputDialog.CapabilitiesURL.Label"))) {
DataStore ds = buildDataStore();
try {
if (ds != null)
layernames = ds.getTypeNames();
} catch (IOException e) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(Messages
.getString("WFSInputDialog.ErrorGettingLayernames.DialogMessage"));
mb.setText(Messages
.getString("WFSInputDialog.Error.DialogTitle"));
mb.open();
}
}
}
示例9: readParameters
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private List<ShapeFileParameter> readParameters(DataStore dataStore) {
if (dataStore == null)
return Collections.emptyList();
try {
Map<String, ShapeFileParameter> params = new HashMap<>();
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureCollection source = dataStore.getFeatureSource(
typeName).getFeatures();
SimpleFeatureIterator it = source.features();
while (it.hasNext()) {
SimpleFeature feature = it.next();
readParameters(params, feature);
}
it.close();
List<ShapeFileParameter> list = new ArrayList<>();
list.addAll(params.values());
return list;
} catch (Exception e) {
log.error("failed to get parameters from shape file", e);
return Collections.emptyList();
}
}
示例10: create
import org.geotools.data.DataStore; //導入方法依賴的package包/類
public static Style create(DataStore dataStore, ShapeFileParameter param,
FeatureType type) {
try {
StyleBuilder styleBuilder = new StyleBuilder();
Style style = styleBuilder.createStyle();
double[] breaks = createBreaks(param.min, param.max);
Color[] colors = createColors();
Rule[] rules = createRules(param.name, styleBuilder, breaks,
colors, type);
String typeName = dataStore.getTypeNames()[0];
FeatureTypeStyle fts = styleBuilder.createFeatureTypeStyle(
typeName, rules);
style.featureTypeStyles().add(fts);
return style;
} catch (Exception e) {
Logger log = LoggerFactory.getLogger(SFMapStyle.class);
log.error("failed to create shape file style", e);
return null;
}
}
示例11: readParameters
import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static Collection<ShapeFileParameter> readParameters(
DataStore dataStore) {
if (dataStore == null)
return Collections.emptyList();
Logger log = LoggerFactory.getLogger(ShapeFileUtils.class);
try {
Map<String, ShapeFileParameter> params = new HashMap<>();
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureCollection source = dataStore.getFeatureSource(
typeName).getFeatures();
SimpleFeatureIterator it = source.features();
while (it.hasNext()) {
SimpleFeature feature = it.next();
readParameters(params, feature);
}
it.close();
return params.values();
} catch (Exception e) {
log.error("failed to get parameters from shape file", e);
return Collections.emptyList();
}
}
示例12: testGetFeatures
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* 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());
}
}
示例13: testGetFeatureCollection
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* 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());
}
}
示例14: testGetFeatureStore
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* Test method for {@link com.sldeditor.datasource.impl.DataSourceInfo#getFeatureStore()}. Test
* method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#setSchema(org.opengis.feature.type.FeatureType)}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetFeatureStore() {
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();
dsInfo.setSchema(schema);
assertNull(dsInfo.getFeatureStore());
dsInfo.setDataStore(dataStore);
FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = dsInfo.getFeatureStore();
assertTrue(featureStore != null);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例15: testGetPropertyDescriptorList
import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
* Test method for
* {@link com.sldeditor.datasource.impl.DataSourceInfo#getPropertyDescriptorList()}.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetPropertyDescriptorList() {
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.getPropertyDescriptorList());
dsInfo.setSchema(schema);
Collection<PropertyDescriptor> fieldList = dsInfo.getPropertyDescriptorList();
assertTrue(fieldList.size() == 3);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}