public SimpleFeatureCollection getFeatures(Query query) throws IOException { if (query.getTypeName() == null) { query = new Query(query); ((Query) query).setTypeName(typeMap.getName()); } else if (!typeMap.getName().equals(query.getTypeName())) { throw new IOException( "Cannot query this feature source with " + query.getTypeName() + " since it serves only " + typeMap.getName()); } // GEOS-3210, if the query specifies a subset of property names we need to take that into // account SimpleFeatureType target = typeMap.getFeatureType(query); return new RetypingFeatureCollection( wrapped.getFeatures(store.retypeQuery(query, typeMap)), target); }
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { FeatureTypeMap map = getTypeMapBackwards(query.getTypeName(), true); updateMap(map, false); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = wrapped.getFeatureReader(retypeQuery(query, map), transaction); if (map.isUnchanged()) return reader; return new RetypingFeatureCollection.RetypingFeatureReader( reader, map.getFeatureType(query)); }
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { PreGeneralizedFeatureSource fs = featureSources.get(query.getTypeName()); if (fs == null) throw new IOException(query.getTypeName() + " not found"); return fs.getFeatureReader(query, transaction); }
/** * Returns a feature reader for the specified query and transaction. * * <p>This method is not intended to be overridden and is marked final. This implementation * delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureReader}. */ public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction tx) throws IOException { if (query.getTypeName() == null) { throw new IllegalArgumentException("Query does not specify type."); } return getFeatureSource(query.getTypeName(), tx).getReader(query); }
@Override public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { ensureNotDisposed(); if (this.typeName.equals(query.getTypeName())) { return DataUtilities.reader(source.getFeatures()); } throw new IOException( "Not found: " + query.getTypeName() + " DataStoreAdaptor contains " + this.typeName); } }
private Query namedQuery(final Query query) { final String localName = typeInfo.getFeatureTypeName(); final String typeName = query.getTypeName(); if (typeName != null && !localName.equals(typeName)) { throw new IllegalArgumentException( "Wrong type name: " + typeName + " (this is " + localName + ")"); } Query namedQuery = new Query(query); namedQuery.setTypeName(localName); return namedQuery; }
/** * Return the name of the type that is queried. * * @param query * @return Name constructed from the query. */ private Name getName(Query query) { if (query.getNamespace() == null) { return Types.typeName(query.getTypeName()); } else { return Types.typeName(query.getNamespace().toString(), query.getTypeName()); } }
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { String typeName = query.getTypeName(); return getDataStore(typeName).getFeatureReader(query, transaction); }
/** * Return a 'view' of the given {@code DataStore} constrained by a {@code Query}. * * @param store the data store * @param query the query * @return the constrained view * @throws IOException if the data store cannot be accessed * @throws SchemaException if the query is incompatible with the store's contents */ public static SimpleFeatureSource createView(final DataStore store, final Query query) throws IOException, SchemaException { return createView(store.getFeatureSource(query.getTypeName()), query); }
public SimpleFeatureCollection getFeatures(Query query) throws IOException { String schemaName = wrapped.getSchema().getName().getLocalPart(); if (query.getTypeName() != null && !schemaName.equals(query.getTypeName())) { throw new DataSourceException( "Typename mismatch, query asks for '" + query.getTypeName() + " but this feature source provides '" + schemaName + "'"); } return getFeatureCollection(query, getEnvelope(query.getFilter())); }
public PropertyFeatureWriter( ContentFeatureSource source, ContentState contentState, Query query, boolean append) throws IOException { this.state = contentState; this.featureSource = source; PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore(); String namespaceURI = store.getNamespaceURI(); String typeName = query.getTypeName(); File dir = store.dir; read = new File(store.dir, typeName + ".properties"); write = File.createTempFile(typeName + System.currentTimeMillis(), null, dir); // start reading delegate = new PropertyFeatureReader(namespaceURI, read); type = delegate.getFeatureType(); // open writer writer = new BufferedWriter(new FileWriter(write)); // write header writer.write("_="); writer.write(DataUtilities.encodeType(type)); } // constructor end
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(); } }
@Override public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader( Query query, Transaction transaction) throws IOException { SimpleFeatureSource fs = getFeatureSource(query.getTypeName()); if (fs == null) { throw new IOException( "Could not find feature type mentioned in query: '" + query.getTypeName() + "'"); } if (fs instanceof SimpleFeatureStore) { ((SimpleFeatureStore) fs).setTransaction(transaction); } SimpleFeatureIterator iterator = fs.getFeatures().features(); return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>( fs.getSchema(), iterator); }
/** * Hashcode based on all parameters other than the handle. * * @return hascode for this Query */ @Override public int hashCode() { String[] n = getPropertyNames(); return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode()))) | getMaxFeatures() | ((getFilter() == null) ? 0 : getFilter().hashCode()) | ((getTypeName() == null) ? 0 : getTypeName().hashCode()) | ((getVersion() == null) ? 0 : getVersion().hashCode()) | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode()) | ((getCoordinateSystemReproject() == null) ? 0 : getCoordinateSystemReproject().hashCode()) | getStartIndex(); }
private Query setupBaseQuery(Query q) { if (q == null) { q = new Query(); } else { q = new Query(q); } if (hints != null) { q.setHints(hints); } if (q.getTypeName() == null) { q.setTypeName(typeName); } return q; }
/** Test of getTypeName method, of class org.geotools.data.Query. */ public void testTypeName() { Query query = new Query(); assertNull(query.getTypeName()); query.setTypeName("foobar"); assertEquals("foobar", query.getTypeName()); query = new Query("mytype", Filter.EXCLUDE); assertEquals("mytype", query.getTypeName()); }
@Override public SimpleFeatureCollection getGranules(Query q) throws IOException { Utilities.ensureNonNull("query", q); q = mergeHints(q); String typeName = q.getTypeName(); checkStore(); // // Load tiles informations, especially the bounds, which will be // reused // final SimpleFeatureSource featureSource = getTileIndexStore().getFeatureSource(typeName); if (featureSource == null) { throw new NullPointerException( "The provided SimpleFeatureSource is null, it's impossible to create an index!"); } return featureSource.getFeatures(q); }
public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException { query = mergeHints(query); checkStore(); SimpleFeatureSource fs = getTileIndexStore().getFeatureSource(query.getTypeName()); if (fs instanceof ContentFeatureSource) ((ContentFeatureSource) fs).accepts(query, function, null); else { final SimpleFeatureCollection collection = fs.getFeatures(query); collection.accepts(function, null); } }
public SimpleFeatureType getQueryType(Query query) throws IOException { final String typeName = query.getTypeName(); final String propertyNames[] = query.getPropertyNames(); final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName); final SimpleFeatureType completeSchema = typeInfo.getFeatureType(); SimpleFeatureType featureType = completeSchema; if (!query.retrieveAllProperties() || query.getCoordinateSystem() != null) { try { featureType = DataUtilities.createSubType( featureType, propertyNames, query.getCoordinateSystem()); } catch (SchemaException e) { LOGGER.log(Level.FINEST, e.getMessage(), e); throw new DataSourceException("Could not create Feature Type for query", e); } } return featureType; }
/** Get features based on the query specified. */ @Override public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException { GetFeatureRequest request = client.createGetFeatureRequest(); FeatureType schema = dataAccess.getSchema(typeName); QName name = dataAccess.getRemoteTypeName(typeName); request.setTypeName(new QName(query.getTypeName())); request.setFullType(schema); request.setFilter(query.getFilter()); request.setPropertyNames(query.getPropertyNames()); request.setSortBy(query.getSortBy()); String srsName = null; request.setSrsName(srsName); return new WFSContentComplexFeatureCollection(request, schema, name); }