Query q = new Query(currFt.getTypeName(), Filter.INCLUDE); FeatureReader<SimpleFeatureType, SimpleFeature> ilReader; DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore(); ilReader = inlineFeatureDatastore.getFeatureReader(q, Transaction.AUTO_COMMIT); CoordinateReferenceSystem crs = (fallbackCrs == null) ? DefaultGeographicCRS.WGS84 : fallbackCrs; String typeName = inlineFeatureDatastore.getTypeNames()[0]; MemoryDataStore reTypedDS = new MemoryDataStore(new ForceCoordinateSystemFeatureReader(ilReader, crs)); } else { DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore(); String typeName = inlineFeatureDatastore.getTypeNames()[0]; featureSource = inlineFeatureDatastore.getFeatureSource(typeName);
public void dispose() { wrapped.dispose(); }
public void createSchema(SimpleFeatureType featureType) throws IOException { delegate.createSchema(featureType); }
File file = new File("mayshapefile.shp"); try { Map connect = new HashMap(); connect.put("url", file.toURL()); DataStore dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); String typeName = typeNames[0]; System.out.println("Reading content " + typeName); FeatureSource featureSource = dataStore.getFeatureSource(typeName); FeatureCollection collection = featureSource.getFeatures(); FeatureIterator iterator = collection.features(); try { while (iterator.hasNext()) { Feature feature = iterator.next(); Geometry sourceGeometry = feature.getDefaultGeometry(); } } finally { iterator.close(); } } catch (Throwable e) {}
expect(ds.getTypeNames()).andReturn(new String[] {"trees"}).anyTimes(); expect(ds.getSchema("trees")).andReturn(type).anyTimes(); expect(ds.getFeatureSource("trees")).andReturn(fs); replay(ds);
public void createType(SimpleFeatureType featureType) throws IOException { Utilities.ensureNonNull("featureType", featureType); final Lock lock = rwLock.writeLock(); String typeName = null; try { lock.lock(); checkStore(); SimpleFeatureType existing = null; try { existing = slicesIndexStore.getSchema(name); } catch (IOException ioe) { slicesIndexStore.createSchema(featureType); } else { lock.unlock();
public void removeGranules(String typeName, Filter filter, Transaction transaction) throws IOException { Utilities.ensureNonNull("typeName", typeName); Utilities.ensureNonNull("filter", filter); Utilities.ensureNonNull("transaction", transaction); final Lock lock = rwLock.writeLock(); try { lock.lock(); // check if the index has been cleared checkStore(); final SimpleFeatureStore store = (SimpleFeatureStore) slicesIndexStore.getFeatureSource(typeName); store.setTransaction(transaction); store.removeFeatures(filter); } finally { lock.unlock(); } }
public ReferencedEnvelope getBounds(final String typeName) { final Lock lock = rwLock.readLock(); try { lock.lock(); checkStore(); return this.slicesIndexStore.getFeatureSource(typeName).getBounds(); } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); return null; } finally { lock.unlock(); } }
public void dispose() { final Lock l = rwLock.writeLock(); try { l.lock(); try { if (slicesIndexStore != null && !repositoryStore) slicesIndexStore.dispose(); } catch (Throwable e) { if (LOGGER.isLoggable(Level.FINE)) LOGGER.log(Level.FINE, e.getLocalizedMessage(), e); } finally { slicesIndexStore = null; } } finally { l.unlock(); } }
public QueryCapabilities getQueryCapabilities(final String typeName) { final Lock lock = rwLock.readLock(); try { lock.lock(); checkStore(); return slicesIndexStore.getFeatureSource(typeName).getQueryCapabilities(); } catch (IOException e) { if (LOGGER.isLoggable(Level.INFO)) LOGGER.log(Level.INFO, "Unable to collect QueryCapabilities", e); return null; } finally { lock.unlock(); } }
public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException { final Lock lock = rwLock.readLock(); try { lock.lock(); checkStore(); SimpleFeatureSource fs = slicesIndexStore.getFeatureSource(query.getTypeName()); if (fs instanceof ContentFeatureSource) ((ContentFeatureSource) fs).accepts(query, function, null); else { final SimpleFeatureCollection collection = fs.getFeatures(query); collection.accepts(function, null); } } finally { lock.unlock(); } }
final SimpleFeatureSource featureSource = slicesIndexStore.getFeatureSource(typeName); if (featureSource == null) { throw new NullPointerException( ((FeatureStore) featureSource).setTransaction(tx); String[] requestedProperties = q.getPropertyNames(); boolean postRetypeRequired = requestedProperties != Query.ALL_NAMES; SimpleFeatureType target = null; requestedProperties, 0, properties, 0, requestedProperties.length); properties[requestedProperties.length] = IMAGE_INDEX_ATTR; q.setPropertyNames(properties); featureSource.getSchema(), requestedProperties); final SimpleFeatureCollection features = featureSource.getFeatures(q); if (features == null) { throw new NullPointerException( throw ioe; } finally { lock.unlock();
public int removeGranules(final Query query) { Utilities.ensureNonNull("query",query); final Lock lock=rwLock.writeLock(); try{ lock.lock(); try{ fs = (SimpleFeatureStore) tileIndexStore.getFeatureSource(typeName); final int retVal=fs.getCount(query); fs.removeFeatures(query.getFilter()); bounds=tileIndexStore.getFeatureSource(typeName).getBounds(); lock.unlock();
public void addGranules(final Collection<SimpleFeature> granules, final Transaction transaction) throws IOException { Utilities.ensureNonNull("granuleMetadata",granules); final Lock lock=rwLock.writeLock(); try{ lock.lock(); try{ fw = tileIndexStore.getFeatureWriterAppend(typeName,transaction); final AttributeDescriptor descriptor = tileIndexStore.getSchema(typeName).getDescriptor(i); if(descriptor.getType().getBinding().equals(String.class)) bounds=tileIndexStore.getFeatureSource(typeName).getBounds(Query.ALL); }finally{ lock.unlock();
public void getGranules(final Query q, final GranuleCatalogVisitor visitor) throws IOException { Utilities.ensureNonNull("query",q); final Lock lock=rwLock.readLock(); try{ lock.lock(); checkStore(); final SimpleFeatureSource featureSource = tileIndexStore.getFeatureSource(this.typeName); if (featureSource == null) throw new NullPointerException( "The provided SimpleFeatureSource is null, it's impossible to create an index!"); final SimpleFeatureCollection features = featureSource.getFeatures( q ); if (features == null) throw new NullPointerException( lock.unlock();
/** * Test the first page of one feature per page with reverse sorting. * * @throws IOException */ @Test public void reverseSortedOneFeatureFirstPage() throws IOException { Query query = new Query(); query.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER}); query.setMaxFeatures(1); query.setStartIndex(0); SimpleFeatureSource fs = store.getFeatureSource(TYPENAME); SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray(); Assert.assertEquals(1, fs.getCount(query)); Assert.assertEquals("mock.3", features[0].getID()); }
DataStoreInfo ds = cat.getFactory().createDataStore(); ds.setName(SQLVIEW_DATASTORE); WorkspaceInfo ws = cat.getDefaultWorkspace(); ds.setWorkspace(ws); ds.setEnabled(true); new File(getTestData().getDataDirectoryRoot().getAbsolutePath(), "data/h2test"); params.put("database", dbFile.getAbsolutePath()); cat.add(ds); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(fsp.getSchema()); tb.remove("surfaceProperty"); // the store cannot create multi-geom tables it seems tb.remove("curveProperty"); // the store cannot create multi-geom tables it seems tb.setName("pgeo"); SimpleFeatureType schema = tb.buildFeatureType(); store.createSchema(schema); SimpleFeatureStore featureStore = (SimpleFeatureStore) store.getFeatureSource("pgeo"); featureStore.addFeatures(fsp.getFeatures());
DataStoreInfo ds = cat.getFactory().createDataStore(); ds.setName("foo"); ds.setWorkspace(cat.getDefaultWorkspace()); params.put("database", getTestData().getDataDirectoryRoot().getAbsolutePath()); ds.setEnabled(true); cat.add(ds); store.createSchema(tb.buildFeatureType()); store.createSchema(tb.buildFeatureType()); FeatureStore fs = (FeatureStore) store.getFeatureSource("Fifteen"); fs.addFeatures(fs1.getFeatures()); FeatureTypeInfo ft = cb.buildFeatureType(fs); cat.add(ft); fs = (FeatureStore) store.getFeatureSource("Seven"); fs.addFeatures(fs2.getFeatures()); ft = cb.buildFeatureType(fs);
for (String typeName : dataStore.getTypeNames()) { if (monitor.isCanceled()) { break; cb.buildFeatureType(dataStore.getFeatureSource(typeName)); featureType.setStore(null); featureType.setNamespace(null); SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName); cb.setupBounds(featureType, featureSource); CatalogFactory factory = catalog.getFactory(); SimpleFeatureType schema = featureSource.getSchema(); for (AttributeDescriptor ad : schema.getAttributeDescriptors()) { AttributeTypeInfo att = factory.createAttribute(); dataStore.dispose();