org.geotools.data.Query.getTypeName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(236)

本文整理了Java中org.geotools.data.Query.getTypeName方法的一些代码示例,展示了Query.getTypeName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getTypeName方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:getTypeName

Query.getTypeName介绍

[英]Get the name of the feature type to be queried.
[中]获取要查询的要素类型的名称。

代码示例

代码示例来源:origin: geoserver/geoserver

  1. public SimpleFeatureCollection getFeatures(Query query) throws IOException {
  2. if (query.getTypeName() == null) {
  3. query = new Query(query);
  4. ((Query) query).setTypeName(typeMap.getName());
  5. } else if (!typeMap.getName().equals(query.getTypeName())) {
  6. throw new IOException(
  7. "Cannot query this feature source with "
  8. + query.getTypeName()
  9. + " since it serves only "
  10. + typeMap.getName());
  11. }
  12. // GEOS-3210, if the query specifies a subset of property names we need to take that into
  13. // account
  14. SimpleFeatureType target = typeMap.getFeatureType(query);
  15. return new RetypingFeatureCollection(
  16. wrapped.getFeatures(store.retypeQuery(query, typeMap)), target);
  17. }

代码示例来源:origin: geoserver/geoserver

  1. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  2. Query query, Transaction transaction) throws IOException {
  3. FeatureTypeMap map = getTypeMapBackwards(query.getTypeName(), true);
  4. updateMap(map, false);
  5. FeatureReader<SimpleFeatureType, SimpleFeature> reader;
  6. reader = wrapped.getFeatureReader(retypeQuery(query, map), transaction);
  7. if (map.isUnchanged()) return reader;
  8. return new RetypingFeatureCollection.RetypingFeatureReader(
  9. reader, map.getFeatureType(query));
  10. }

代码示例来源:origin: geotools/geotools

  1. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  2. Query query, Transaction transaction) throws IOException {
  3. PreGeneralizedFeatureSource fs = featureSources.get(query.getTypeName());
  4. if (fs == null) throw new IOException(query.getTypeName() + " not found");
  5. return fs.getFeatureReader(query, transaction);
  6. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Returns a feature reader for the specified query and transaction.
  3. *
  4. * <p>This method is not intended to be overridden and is marked final. This implementation
  5. * delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureReader}.
  6. */
  7. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  8. Query query, Transaction tx) throws IOException {
  9. if (query.getTypeName() == null) {
  10. throw new IllegalArgumentException("Query does not specify type.");
  11. }
  12. return getFeatureSource(query.getTypeName(), tx).getReader(query);
  13. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  3. Query query, Transaction transaction) throws IOException {
  4. ensureNotDisposed();
  5. if (this.typeName.equals(query.getTypeName())) {
  6. return DataUtilities.reader(source.getFeatures());
  7. }
  8. throw new IOException(
  9. "Not found: "
  10. + query.getTypeName()
  11. + " DataStoreAdaptor contains "
  12. + this.typeName);
  13. }
  14. }

代码示例来源:origin: geotools/geotools

  1. private Query namedQuery(final Query query) {
  2. final String localName = typeInfo.getFeatureTypeName();
  3. final String typeName = query.getTypeName();
  4. if (typeName != null && !localName.equals(typeName)) {
  5. throw new IllegalArgumentException(
  6. "Wrong type name: " + typeName + " (this is " + localName + ")");
  7. }
  8. Query namedQuery = new Query(query);
  9. namedQuery.setTypeName(localName);
  10. return namedQuery;
  11. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Return the name of the type that is queried.
  3. *
  4. * @param query
  5. * @return Name constructed from the query.
  6. */
  7. private Name getName(Query query) {
  8. if (query.getNamespace() == null) {
  9. return Types.typeName(query.getTypeName());
  10. } else {
  11. return Types.typeName(query.getNamespace().toString(), query.getTypeName());
  12. }
  13. }

代码示例来源:origin: geotools/geotools

  1. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  2. Query query, Transaction transaction) throws IOException {
  3. String typeName = query.getTypeName();
  4. return getDataStore(typeName).getFeatureReader(query, transaction);
  5. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Return a 'view' of the given {@code DataStore} constrained by a {@code Query}.
  3. *
  4. * @param store the data store
  5. * @param query the query
  6. * @return the constrained view
  7. * @throws IOException if the data store cannot be accessed
  8. * @throws SchemaException if the query is incompatible with the store's contents
  9. */
  10. public static SimpleFeatureSource createView(final DataStore store, final Query query)
  11. throws IOException, SchemaException {
  12. return createView(store.getFeatureSource(query.getTypeName()), query);
  13. }

代码示例来源:origin: geotools/geotools

  1. public SimpleFeatureCollection getFeatures(Query query) throws IOException {
  2. String schemaName = wrapped.getSchema().getName().getLocalPart();
  3. if (query.getTypeName() != null && !schemaName.equals(query.getTypeName())) {
  4. throw new DataSourceException(
  5. "Typename mismatch, query asks for '"
  6. + query.getTypeName()
  7. + " but this feature source provides '"
  8. + schemaName
  9. + "'");
  10. }
  11. return getFeatureCollection(query, getEnvelope(query.getFilter()));
  12. }

代码示例来源:origin: geotools/geotools

  1. public PropertyFeatureWriter(
  2. ContentFeatureSource source, ContentState contentState, Query query, boolean append)
  3. throws IOException {
  4. this.state = contentState;
  5. this.featureSource = source;
  6. PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore();
  7. String namespaceURI = store.getNamespaceURI();
  8. String typeName = query.getTypeName();
  9. File dir = store.dir;
  10. read = new File(store.dir, typeName + ".properties");
  11. write = File.createTempFile(typeName + System.currentTimeMillis(), null, dir);
  12. // start reading
  13. delegate = new PropertyFeatureReader(namespaceURI, read);
  14. type = delegate.getFeatureType();
  15. // open writer
  16. writer = new BufferedWriter(new FileWriter(write));
  17. // write header
  18. writer.write("_=");
  19. writer.write(DataUtilities.encodeType(type));
  20. }
  21. // constructor end

代码示例来源:origin: geotools/geotools

  1. public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException {
  2. final Lock lock = rwLock.readLock();
  3. try {
  4. lock.lock();
  5. checkStore();
  6. SimpleFeatureSource fs = slicesIndexStore.getFeatureSource(query.getTypeName());
  7. if (fs instanceof ContentFeatureSource)
  8. ((ContentFeatureSource) fs).accepts(query, function, null);
  9. else {
  10. final SimpleFeatureCollection collection = fs.getFeatures(query);
  11. collection.accepts(function, null);
  12. }
  13. } finally {
  14. lock.unlock();
  15. }
  16. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
  3. Query query, Transaction transaction) throws IOException {
  4. SimpleFeatureSource fs = getFeatureSource(query.getTypeName());
  5. if (fs == null) {
  6. throw new IOException(
  7. "Could not find feature type mentioned in query: '"
  8. + query.getTypeName()
  9. + "'");
  10. }
  11. if (fs instanceof SimpleFeatureStore) {
  12. ((SimpleFeatureStore) fs).setTransaction(transaction);
  13. }
  14. SimpleFeatureIterator iterator = fs.getFeatures().features();
  15. return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(
  16. fs.getSchema(), iterator);
  17. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Hashcode based on all parameters other than the handle.
  3. *
  4. * @return hascode for this Query
  5. */
  6. @Override
  7. public int hashCode() {
  8. String[] n = getPropertyNames();
  9. return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode())))
  10. | getMaxFeatures()
  11. | ((getFilter() == null) ? 0 : getFilter().hashCode())
  12. | ((getTypeName() == null) ? 0 : getTypeName().hashCode())
  13. | ((getVersion() == null) ? 0 : getVersion().hashCode())
  14. | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode())
  15. | ((getCoordinateSystemReproject() == null)
  16. ? 0
  17. : getCoordinateSystemReproject().hashCode())
  18. | getStartIndex();
  19. }

代码示例来源:origin: geotools/geotools

  1. private Query setupBaseQuery(Query q) {
  2. if (q == null) {
  3. q = new Query();
  4. } else {
  5. q = new Query(q);
  6. }
  7. if (hints != null) {
  8. q.setHints(hints);
  9. }
  10. if (q.getTypeName() == null) {
  11. q.setTypeName(typeName);
  12. }
  13. return q;
  14. }

代码示例来源:origin: geotools/geotools

  1. /** Test of getTypeName method, of class org.geotools.data.Query. */
  2. public void testTypeName() {
  3. Query query = new Query();
  4. assertNull(query.getTypeName());
  5. query.setTypeName("foobar");
  6. assertEquals("foobar", query.getTypeName());
  7. query = new Query("mytype", Filter.EXCLUDE);
  8. assertEquals("mytype", query.getTypeName());
  9. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public SimpleFeatureCollection getGranules(Query q) throws IOException {
  3. Utilities.ensureNonNull("query", q);
  4. q = mergeHints(q);
  5. String typeName = q.getTypeName();
  6. checkStore();
  7. //
  8. // Load tiles informations, especially the bounds, which will be
  9. // reused
  10. //
  11. final SimpleFeatureSource featureSource = getTileIndexStore().getFeatureSource(typeName);
  12. if (featureSource == null) {
  13. throw new NullPointerException(
  14. "The provided SimpleFeatureSource is null, it's impossible to create an index!");
  15. }
  16. return featureSource.getFeatures(q);
  17. }

代码示例来源:origin: geotools/geotools

  1. public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException {
  2. query = mergeHints(query);
  3. checkStore();
  4. SimpleFeatureSource fs = getTileIndexStore().getFeatureSource(query.getTypeName());
  5. if (fs instanceof ContentFeatureSource)
  6. ((ContentFeatureSource) fs).accepts(query, function, null);
  7. else {
  8. final SimpleFeatureCollection collection = fs.getFeatures(query);
  9. collection.accepts(function, null);
  10. }
  11. }

代码示例来源:origin: geotools/geotools

  1. public SimpleFeatureType getQueryType(Query query) throws IOException {
  2. final String typeName = query.getTypeName();
  3. final String propertyNames[] = query.getPropertyNames();
  4. final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName);
  5. final SimpleFeatureType completeSchema = typeInfo.getFeatureType();
  6. SimpleFeatureType featureType = completeSchema;
  7. if (!query.retrieveAllProperties() || query.getCoordinateSystem() != null) {
  8. try {
  9. featureType =
  10. DataUtilities.createSubType(
  11. featureType, propertyNames, query.getCoordinateSystem());
  12. } catch (SchemaException e) {
  13. LOGGER.log(Level.FINEST, e.getMessage(), e);
  14. throw new DataSourceException("Could not create Feature Type for query", e);
  15. }
  16. }
  17. return featureType;
  18. }

代码示例来源:origin: geotools/geotools

  1. /** Get features based on the query specified. */
  2. @Override
  3. public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException {
  4. GetFeatureRequest request = client.createGetFeatureRequest();
  5. FeatureType schema = dataAccess.getSchema(typeName);
  6. QName name = dataAccess.getRemoteTypeName(typeName);
  7. request.setTypeName(new QName(query.getTypeName()));
  8. request.setFullType(schema);
  9. request.setFilter(query.getFilter());
  10. request.setPropertyNames(query.getPropertyNames());
  11. request.setSortBy(query.getSortBy());
  12. String srsName = null;
  13. request.setSrsName(srsName);
  14. return new WFSContentComplexFeatureCollection(request, schema, name);
  15. }

相关文章