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

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

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

Query.setProperties介绍

[英]Set the names of the properties that this Query should retrieve as part of the returned org.geotools.feature.FeatureCollection. As well as an array of names, the following constants can be used:

  • #ALL_PROPERTIES to retrieve all properties.
  • #NO_PROPERTIES to indicate no properties are required, just feature IDs.
    The available properties can be determined with FeatureSource#getSchema(). If properties that are not part of the source's schema are requested an exception will be thrown.
    [中]设置此查询应作为返回组织的一部分检索的属性的名称。地理工具。特色特色系列。除了名称数组之外,还可以使用以下常量:
    *#ALL_PROPERTIES以检索所有属性。
    *#NO_属性表示不需要属性,只需要功能ID。
    可用属性可通过FeatureSource#getSchema()确定。如果请求不属于源架构的属性,则会引发异常。

代码示例

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

  1. List<PropertyName> userProperties = userQuery.getProperties();
  2. if (userProperties == null) {
  3. result.setProperties(securityProperties);
  4. } else {
  5. for (PropertyName pn : userProperties) {
  6. result.setProperties(userProperties);

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

  1. Query q = new Query(nativeQuery);
  2. if (nativeProperties == Query.ALL_PROPERTIES) {
  3. q.setProperties(new ArrayList<>(sortProperties));
  4. } else {
  5. List<PropertyName> allProperties = new ArrayList<>(nativeProperties);
  6. q.setProperties(allProperties);

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

  1. private void buildIndexQuery() {
  2. Query idsQuery = new Query(query);
  3. idsQuery.setFilter(buildIndexFilter());
  4. idsQuery.setProperties(Query.NO_PROPERTIES);
  5. indexQuery = idsQuery;
  6. }

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

  1. /**
  2. * Convert query to retrieve only id field, no other fields
  3. *
  4. * @return converted Query
  5. */
  6. protected Query transformQueryToIdsOnly() {
  7. Query idsQuery = new Query(unrollIndexes(query));
  8. idsQuery.setProperties(getIndexQueryProperties());
  9. idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName());
  10. return idsQuery;
  11. }

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

  1. targetQuery.setProperties(null);

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

  1. /**
  2. * Build the query for execute on index source partial Implementation manages pagination by
  3. * itself, so remove bounds from query
  4. *
  5. * @return Query
  6. */
  7. @Override
  8. protected Query transformQueryToIdsOnly() {
  9. Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery()));
  10. idsQuery.setProperties(getIndexQueryProperties());
  11. idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName());
  12. idsQuery.setStartIndex(null);
  13. idsQuery.setMaxFeatures(Integer.MAX_VALUE);
  14. return idsQuery;
  15. }

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

  1. /** Test of set/getProperties method, of class org.geotools.data.Query. */
  2. public void testProperties() {
  3. final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  4. // System.out.println("testProperties");
  5. Query query = new Query();
  6. assertNull(query.getProperties());
  7. List<PropertyName> properties = new ArrayList<PropertyName>();
  8. NamespaceSupport nsContext = new NamespaceSupport();
  9. nsContext.declarePrefix("foo", "FooNamespace");
  10. PropertyName fooProp = ff.property("foo", nsContext);
  11. PropertyName barProp = ff.property("bar", nsContext);
  12. properties.add(fooProp);
  13. properties.add(barProp);
  14. query.setProperties(properties);
  15. List<PropertyName> properties2 = query.getProperties();
  16. assertNotNull(properties);
  17. assertEquals(fooProp, properties2.get(0));
  18. assertEquals(barProp, properties2.get(1));
  19. assertEquals(nsContext, properties2.get(0).getNamespaceContext());
  20. // test compatibility with getPropertyNames method
  21. String[] names = query.getPropertyNames();
  22. assertEquals("foo", names[0]);
  23. assertEquals("bar", names[1]);
  24. query.setProperties(Query.ALL_PROPERTIES);
  25. assertNull(query.getProperties());
  26. query = new Query("Test", Filter.INCLUDE, properties);
  27. assertNotNull(query.getProperties());
  28. }

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

  1. /** Test of retrieveAllProperties method, of class org.geotools.data.Query. */
  2. public void testRetrieveAllProperties() {
  3. // System.out.println("testRetrieveAllProperties");
  4. Query query = new Query();
  5. assertTrue(query.retrieveAllProperties());
  6. query.setPropertyNames(new String[] {"foo", "bar"});
  7. assertFalse(query.retrieveAllProperties());
  8. query.setPropertyNames(Query.ALL_NAMES);
  9. assertTrue(query.retrieveAllProperties());
  10. query.setProperties(Query.ALL_PROPERTIES);
  11. assertTrue(query.retrieveAllProperties());
  12. query.setPropertyNames(new String[] {"foo", "bar"});
  13. query.setProperties(Query.ALL_PROPERTIES);
  14. assertTrue(query.retrieveAllProperties());
  15. }

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

  1. query.setProperties(selectedProperties);

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

  1. query.setProperties(attributes);
  2. processRuleForQuery(styleList, query);
  3. query.setProperties(attributes);
  4. Envelope bounds = source.getBounds();
  5. if (bounds != null && envelope.intersects(bounds)) {

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

  1. targetQuery.setProperties(null);

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

  1. properties.add(propertyName1);
  2. Query query = new Query();
  3. query.setProperties(properties);
  4. query.setProperties(properties);

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

  1. newQuery.setTypeName(name);
  2. newQuery.setFilter(unrolledFilter);
  3. newQuery.setProperties(propNames);
  4. newQuery.setCoordinateSystem(query.getCoordinateSystem());
  5. newQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());

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

  1. private Query namedQuery(Query query) {
  2. Query namedQuery =
  3. namedQuery(
  4. query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
  5. namedQuery.setProperties(query.getProperties());
  6. namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  7. namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  8. namedQuery.setHandle(query.getHandle());
  9. namedQuery.setMaxFeatures(query.getMaxFeatures());
  10. namedQuery.setStartIndex(query.getStartIndex());
  11. namedQuery.setSortBy(query.getSortBy());
  12. namedQuery.setHints(query.getHints());
  13. if (query instanceof JoiningQuery) {
  14. ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
  15. ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping());
  16. }
  17. return namedQuery;
  18. }

代码示例来源:origin: org.geoserver.community/gs-oseo-rest

  1. @GetMapping(
  2. path = "{collection}/ogcLinks",
  3. produces = {MediaType.APPLICATION_JSON_VALUE}
  4. )
  5. @ResponseBody
  6. public OgcLinks getCollectionOgcLinks(
  7. HttpServletRequest request,
  8. @PathVariable(name = "collection", required = true) String collection)
  9. throws IOException {
  10. // query one collection and grab its OGC links
  11. Feature feature =
  12. queryCollection(
  13. collection,
  14. q -> {
  15. q.setProperties(
  16. Collections.singletonList(
  17. FF.property(OpenSearchAccess.OGC_LINKS_PROPERTY_NAME)));
  18. });
  19. OgcLinks links = buildOgcLinksFromFeature(feature, true);
  20. return links;
  21. }

代码示例来源:origin: org.geoserver.community/gs-oseo-rest

  1. @GetMapping(
  2. path = "{collection}/layer",
  3. produces = {MediaType.APPLICATION_JSON_VALUE}
  4. )
  5. @ResponseBody
  6. public CollectionLayer getCollectionLayer(
  7. HttpServletRequest request,
  8. @PathVariable(name = "collection", required = true) String collection)
  9. throws IOException {
  10. // query one collection and grab its OGC links
  11. final Name layerPropertyName = getCollectionLayerPropertyName();
  12. final PropertyName layerProperty = FF.property(layerPropertyName);
  13. Feature feature =
  14. queryCollection(
  15. collection,
  16. q -> {
  17. q.setProperties(Collections.singletonList(layerProperty));
  18. });
  19. CollectionLayer layer = buildCollectionLayerFromFeature(feature, true);
  20. return layer;
  21. }

代码示例来源:origin: org.geoserver.community/gs-oseo-rest

  1. private CollectionLayer getCollectionLayer(String collection) throws IOException {
  2. final Name layerPropertyName = getCollectionLayerPropertyName();
  3. final PropertyName layerProperty = FF.property(layerPropertyName);
  4. Feature feature =
  5. queryCollection(
  6. collection,
  7. q -> {
  8. q.setProperties(Collections.singletonList(layerProperty));
  9. });
  10. CollectionLayer layer = buildCollectionLayerFromFeature(feature, false);
  11. return layer;
  12. }

代码示例来源:origin: org.geoserver/gs-wms

  1. @Override
  2. public FeatureCollection getFeatures(Query query) throws IOException {
  3. Query q = new Query(query);
  4. if (propertyNames == null || propertyNames.length == 0) {
  5. // no property selection, we return them all
  6. q.setProperties(Query.ALL_PROPERTIES);
  7. } else {
  8. // properties got selected, mix them with the ones needed by the renderer
  9. if (query.getPropertyNames() == null || query.getPropertyNames().length == 0) {
  10. q.setPropertyNames(propertyNames);
  11. } else {
  12. Set<String> names = new LinkedHashSet<>(Arrays.asList(propertyNames));
  13. names.addAll(Arrays.asList(q.getPropertyNames()));
  14. String[] newNames = names.toArray(new String[names.size()]);
  15. q.setPropertyNames(newNames);
  16. }
  17. }
  18. return super.getFeatures(q);
  19. }
  20. }

代码示例来源:origin: org.geotools/gt-app-schema

  1. private Query namedQuery(Query query) {
  2. Query namedQuery = namedQuery(query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
  3. namedQuery.setProperties(query.getProperties());
  4. namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  5. namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  6. namedQuery.setHandle(query.getHandle());
  7. namedQuery.setMaxFeatures(query.getMaxFeatures());
  8. namedQuery.setSortBy(query.getSortBy());
  9. namedQuery.setHints(query.getHints());
  10. if (query instanceof JoiningQuery) {
  11. ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
  12. }
  13. return namedQuery;
  14. }

代码示例来源:origin: org.geoserver.community/gs-oseo-core

  1. @Test
  2. public void testCollectionLayerRemoval() throws Exception {
  3. // read it
  4. FeatureStore<FeatureType, Feature> store =
  5. (FeatureStore<FeatureType, Feature>) osAccess.getCollectionSource();
  6. Query q = new Query();
  7. q.setProperties(Arrays.asList(FF.property(LAYER_NAME)));
  8. final PropertyIsEqualTo filter =
  9. FF.equal(
  10. FF.property(new NameImpl(OpenSearchAccess.EO_NAMESPACE, "identifier")),
  11. FF.literal("SENTINEL2"),
  12. false);
  13. q.setFilter(filter);
  14. // update the feature to remove the layer information
  15. store.modifyFeatures(new Name[] {LAYER_NAME}, new Object[] {null}, filter);
  16. // read it back and check it's not set
  17. Feature collection = DataUtilities.first(store.getFeatures(q));
  18. assertNotNull(collection);
  19. Property layerProperty = collection.getProperty(LAYER_NAME);
  20. assertNull(layerProperty);
  21. }
  22. }

相关文章