org.geotools.data.store.ContentFeatureSource Java Examples
The following examples show how to use
org.geotools.data.store.ContentFeatureSource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticDataStore.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Override public ContentFeatureSource getFeatureSource(Name name, Transaction tx) throws IOException { final ElasticLayerConfiguration layerConfig = layerConfigurations.get(name.getLocalPart()); if (layerConfig != null) { docTypes.put(name, layerConfig.getDocType()); } final ContentFeatureSource featureSource = super.getFeatureSource(name, tx); featureSource.getEntry().getState(Transaction.AUTO_COMMIT).flush(); return featureSource; }
Example #2
Source File: ElasticDataStoreIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testSchema() throws IOException { Map<String,Serializable> params = createConnectionParams(); ElasticDataStoreFactory factory = new ElasticDataStoreFactory(); ElasticDataStore dataStore = (ElasticDataStore) factory.createDataStore(params); ContentFeatureSource featureSource = dataStore.getFeatureSource(dataStore.getTypeNames()[0]); SimpleFeatureType schema = featureSource.getSchema(); assertTrue(schema.getAttributeCount() > 0); assertNotNull(schema.getDescriptor("speed_is")); }
Example #3
Source File: ElasticDataStoreIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testSchemaWithValidCustomName() throws Exception { init(); Map<String,Serializable> params = createConnectionParams(); ElasticDataStoreFactory factory = new ElasticDataStoreFactory(); ElasticDataStore dataStore = (ElasticDataStore) factory.createDataStore(params); ElasticLayerConfiguration config2 = new ElasticLayerConfiguration(config); config2.setLayerName("fake"); dataStore.setLayerConfiguration(config2); ContentFeatureSource featureSource = dataStore.getFeatureSource("fake"); SimpleFeatureType schema = featureSource.getSchema(); assertTrue(schema.getAttributeCount() > 0); assertNotNull(schema.getDescriptor("speed_is")); }
Example #4
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 5 votes |
@Override protected ContentFeatureSource createFeatureSource(final ContentEntry entry) throws IOException { return new GeoWaveFeatureSource( entry, Query.ALL, getAdapter(entry.getTypeName()), transactionsAllocator); }
Example #5
Source File: OSMUtils.java From traffic-engine with GNU General Public License v3.0 | 4 votes |
static public void toShapefile( List<SpatialDataItem> segs, String filename ) throws SchemaException, IOException { final SimpleFeatureType TYPE = DataUtilities.createType("Location", "the_geom:LineString:srid=4326," + "name:String" ); System.out.println("TYPE:"+TYPE); List<SimpleFeature> features = new ArrayList<SimpleFeature>(); /* * GeometryFactory will be used to create the geometry attribute of each feature, * using a Point object for the location. */ GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE); for( SpatialDataItem seg : segs ){ featureBuilder.add( seg.getGeometry() ); featureBuilder.add( seg.id ); SimpleFeature feature = featureBuilder.buildFeature(null); features.add( feature ); } File newFile = new File( filename ); ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory(); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("url", newFile.toURI().toURL()); params.put("create spatial index", Boolean.TRUE); ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params); /* * TYPE is used as a template to describe the file contents */ newDataStore.createSchema(TYPE); ContentFeatureSource cfs = newDataStore.getFeatureSource(); if (cfs instanceof SimpleFeatureStore) { SimpleFeatureStore featureStore = (SimpleFeatureStore) cfs; SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features); try { featureStore.addFeatures(collection); } catch (Exception problem) { problem.printStackTrace(); } finally { } } }
Example #6
Source File: GamaShapeFile.java From gama with GNU General Public License v3.0 | 4 votes |
protected void readShapes(final IScope scope) { scope.getGui().getStatus(scope).beginSubStatus("Reading file " + getName(scope)); ShapefileDataStore store = null; final File file = getFile(scope); final IList list = getBuffer(); int size = 0; try { store = getDataStore(file.toURI().toURL()); final ContentFeatureSource source = store.getFeatureSource(); final Envelope3D env = Envelope3D.of(source.getBounds()); size = source.getCount(Query.ALL); int index = 0; computeProjection(scope, env); try (FeatureReader reader = store.getFeatureReader()) { while (reader.hasNext()) { index++; if (index % 20 == 0) { scope.getGui().getStatus(scope).setSubStatusCompletion(index / (double) size); } final Feature feature = reader.next(); Geometry g = (Geometry) feature.getDefaultGeometryProperty().getValue(); if (g != null && !g.isEmpty() /* Fix for Issue 725 && 677 */ ) { if (!with3D && !g.isValid()) { g = GeometryUtils.cleanGeometry(g); } g = gis.transform(g); if (!with3D) { g.apply(ZERO_Z); g.geometryChanged(); } g = multiPolygonManagement(g); GamaGisGeometry gt = new GamaGisGeometry(g, feature); if (gt.getInnerGeometry() != null) list.add(gt); } else if (g == null) { // See Issue 725 GAMA.reportError(scope, GamaRuntimeException .warning("GamaShapeFile.fillBuffer; geometry could not be added as it is " + "nil: " + feature.getIdentifier(), scope), false); } } } } catch (final IOException e) { throw GamaRuntimeException.create(e, scope); } finally { if (store != null) { store.dispose(); } scope.getGui().getStatus(scope).endSubStatus("Reading file " + getName(scope)); } if (size > list.size()) { GAMA.reportError(scope, GamaRuntimeException.warning("Problem with file " + getFile(scope) + ": only " + list.size() + " of the " + size + " geometries could be added", scope), false); } }
Example #7
Source File: ElasticDataStore.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
@Override protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { return new ElasticFeatureSource(entry, Query.ALL); }
Example #8
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 4 votes |
@Override public ContentFeatureSource getFeatureSource(final String typeName) throws IOException { return getFeatureSource(typeName, Transaction.AUTO_COMMIT); }
Example #9
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 4 votes |
@Override public ContentFeatureSource getFeatureSource(final String typeName, final Transaction tx) throws IOException { return super.getFeatureSource(new NameImpl(null, typeName), tx); }
Example #10
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 4 votes |
@Override public ContentFeatureSource getFeatureSource(final Name typeName, final Transaction tx) throws IOException { return getFeatureSource(typeName.getLocalPart(), tx); }
Example #11
Source File: GeoWaveGTDataStore.java From geowave with Apache License 2.0 | 4 votes |
@Override public ContentFeatureSource getFeatureSource(final Name typeName) throws IOException { return getFeatureSource(typeName.getLocalPart(), Transaction.AUTO_COMMIT); }
Example #12
Source File: DummyJdbcFactory.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
protected ContentFeatureSource createFeatureSource(ContentEntry entry) throws IOException { return null; }