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

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

本文整理了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

List<PropertyName> userProperties = userQuery.getProperties();
if (userProperties == null) {
  result.setProperties(securityProperties);
} else {
  for (PropertyName pn : userProperties) {
  result.setProperties(userProperties);

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

Query q = new Query(nativeQuery);
if (nativeProperties == Query.ALL_PROPERTIES) {
  q.setProperties(new ArrayList<>(sortProperties));
} else {
  List<PropertyName> allProperties = new ArrayList<>(nativeProperties);
  q.setProperties(allProperties);

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

private void buildIndexQuery() {
  Query idsQuery = new Query(query);
  idsQuery.setFilter(buildIndexFilter());
  idsQuery.setProperties(Query.NO_PROPERTIES);
  indexQuery = idsQuery;
}

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

/**
 * Convert query to retrieve only id field, no other fields
 *
 * @return converted Query
 */
protected Query transformQueryToIdsOnly() {
  Query idsQuery = new Query(unrollIndexes(query));
  idsQuery.setProperties(getIndexQueryProperties());
  idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName());
  return idsQuery;
}

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

targetQuery.setProperties(null);

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

/**
 * Build the query for execute on index source partial Implementation manages pagination by
 * itself, so remove bounds from query
 *
 * @return Query
 */
@Override
protected Query transformQueryToIdsOnly() {
  Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery()));
  idsQuery.setProperties(getIndexQueryProperties());
  idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName());
  idsQuery.setStartIndex(null);
  idsQuery.setMaxFeatures(Integer.MAX_VALUE);
  return idsQuery;
}

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

/** Test of set/getProperties method, of class org.geotools.data.Query. */
public void testProperties() {
  final FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  // System.out.println("testProperties");
  Query query = new Query();
  assertNull(query.getProperties());
  List<PropertyName> properties = new ArrayList<PropertyName>();
  NamespaceSupport nsContext = new NamespaceSupport();
  nsContext.declarePrefix("foo", "FooNamespace");
  PropertyName fooProp = ff.property("foo", nsContext);
  PropertyName barProp = ff.property("bar", nsContext);
  properties.add(fooProp);
  properties.add(barProp);
  query.setProperties(properties);
  List<PropertyName> properties2 = query.getProperties();
  assertNotNull(properties);
  assertEquals(fooProp, properties2.get(0));
  assertEquals(barProp, properties2.get(1));
  assertEquals(nsContext, properties2.get(0).getNamespaceContext());
  // test compatibility with getPropertyNames method
  String[] names = query.getPropertyNames();
  assertEquals("foo", names[0]);
  assertEquals("bar", names[1]);
  query.setProperties(Query.ALL_PROPERTIES);
  assertNull(query.getProperties());
  query = new Query("Test", Filter.INCLUDE, properties);
  assertNotNull(query.getProperties());
}

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

/** Test of retrieveAllProperties method, of class org.geotools.data.Query. */
public void testRetrieveAllProperties() {
  // System.out.println("testRetrieveAllProperties");
  Query query = new Query();
  assertTrue(query.retrieveAllProperties());
  query.setPropertyNames(new String[] {"foo", "bar"});
  assertFalse(query.retrieveAllProperties());
  query.setPropertyNames(Query.ALL_NAMES);
  assertTrue(query.retrieveAllProperties());
  query.setProperties(Query.ALL_PROPERTIES);
  assertTrue(query.retrieveAllProperties());
  query.setPropertyNames(new String[] {"foo", "bar"});
  query.setProperties(Query.ALL_PROPERTIES);
  assertTrue(query.retrieveAllProperties());
}

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

query.setProperties(selectedProperties);

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

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

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

targetQuery.setProperties(null);

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

properties.add(propertyName1);
Query query = new Query();
query.setProperties(properties);
query.setProperties(properties);

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

newQuery.setTypeName(name);
newQuery.setFilter(unrolledFilter);
newQuery.setProperties(propNames);
newQuery.setCoordinateSystem(query.getCoordinateSystem());
newQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());

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

private Query namedQuery(Query query) {
  Query namedQuery =
      namedQuery(
          query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
  namedQuery.setProperties(query.getProperties());
  namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  namedQuery.setHandle(query.getHandle());
  namedQuery.setMaxFeatures(query.getMaxFeatures());
  namedQuery.setStartIndex(query.getStartIndex());
  namedQuery.setSortBy(query.getSortBy());
  namedQuery.setHints(query.getHints());
  if (query instanceof JoiningQuery) {
    ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
    ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping());
  }
  return namedQuery;
}

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

@GetMapping(
  path = "{collection}/ogcLinks",
  produces = {MediaType.APPLICATION_JSON_VALUE}
)
@ResponseBody
public OgcLinks getCollectionOgcLinks(
    HttpServletRequest request,
    @PathVariable(name = "collection", required = true) String collection)
    throws IOException {
  // query one collection and grab its OGC links
  Feature feature =
      queryCollection(
          collection,
          q -> {
            q.setProperties(
                Collections.singletonList(
                    FF.property(OpenSearchAccess.OGC_LINKS_PROPERTY_NAME)));
          });
  OgcLinks links = buildOgcLinksFromFeature(feature, true);
  return links;
}

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

@GetMapping(
  path = "{collection}/layer",
  produces = {MediaType.APPLICATION_JSON_VALUE}
)
@ResponseBody
public CollectionLayer getCollectionLayer(
    HttpServletRequest request,
    @PathVariable(name = "collection", required = true) String collection)
    throws IOException {
  // query one collection and grab its OGC links
  final Name layerPropertyName = getCollectionLayerPropertyName();
  final PropertyName layerProperty = FF.property(layerPropertyName);
  Feature feature =
      queryCollection(
          collection,
          q -> {
            q.setProperties(Collections.singletonList(layerProperty));
          });
  CollectionLayer layer = buildCollectionLayerFromFeature(feature, true);
  return layer;
}

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

private CollectionLayer getCollectionLayer(String collection) throws IOException {
  final Name layerPropertyName = getCollectionLayerPropertyName();
  final PropertyName layerProperty = FF.property(layerPropertyName);
  Feature feature =
      queryCollection(
          collection,
          q -> {
            q.setProperties(Collections.singletonList(layerProperty));
          });
  CollectionLayer layer = buildCollectionLayerFromFeature(feature, false);
  return layer;
}

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

@Override
  public FeatureCollection getFeatures(Query query) throws IOException {
    Query q = new Query(query);
    if (propertyNames == null || propertyNames.length == 0) {
      // no property selection, we return them all
      q.setProperties(Query.ALL_PROPERTIES);
    } else {
      // properties got selected, mix them with the ones needed by the renderer
      if (query.getPropertyNames() == null || query.getPropertyNames().length == 0) {
        q.setPropertyNames(propertyNames);
      } else {
        Set<String> names = new LinkedHashSet<>(Arrays.asList(propertyNames));
        names.addAll(Arrays.asList(q.getPropertyNames()));
        String[] newNames = names.toArray(new String[names.size()]);
        q.setPropertyNames(newNames);
      }
    }
    return super.getFeatures(q);
  }
}

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

private Query namedQuery(Query query) {
  Query namedQuery = namedQuery(query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);        
  namedQuery.setProperties(query.getProperties());
  namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  namedQuery.setHandle(query.getHandle());
  namedQuery.setMaxFeatures(query.getMaxFeatures());
  namedQuery.setSortBy(query.getSortBy());
  namedQuery.setHints(query.getHints());
  if (query instanceof JoiningQuery) {
    ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
  }
  return namedQuery;
}

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

@Test
  public void testCollectionLayerRemoval() throws Exception {
    // read it
    FeatureStore<FeatureType, Feature> store =
        (FeatureStore<FeatureType, Feature>) osAccess.getCollectionSource();
    Query q = new Query();
    q.setProperties(Arrays.asList(FF.property(LAYER_NAME)));
    final PropertyIsEqualTo filter =
        FF.equal(
            FF.property(new NameImpl(OpenSearchAccess.EO_NAMESPACE, "identifier")),
            FF.literal("SENTINEL2"),
            false);
    q.setFilter(filter);

    // update the feature to remove the layer information
    store.modifyFeatures(new Name[] {LAYER_NAME}, new Object[] {null}, filter);

    // read it back and check it's not set
    Feature collection = DataUtilities.first(store.getFeatures(q));
    assertNotNull(collection);
    Property layerProperty = collection.getProperty(LAYER_NAME);
    assertNull(layerProperty);
  }
}

相关文章