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

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

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

Query.setFilter介绍

[英]Sets the filter to constrain the features that will be retrieved by this Query. If no filter is set all features will be retrieved (taking into account any bounds set via #setMaxFeatures(int) and #setStartIndex(java.lang.Integer)).

The default is Filter#INCLUDE.
[中]设置过滤器以约束此查询将检索的要素。如果未设置过滤器,将检索所有功能(考虑通过#setMaxFeatures(int)和#setStartIndex(java.lang.Integer)设置的任何边界)。
默认设置为过滤器#包含。

代码示例

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

/** Returns a GeoTools query build with the provided attributes and filters */
private Query buildQuery(List<PropertyName> attributes, Filter filter) {
  if (attributes == null && (filter == null || filter == Filter.INCLUDE)) {
    return Query.ALL;
  } else {
    Query q = new Query();
    q.setFilter(filter);
    // TODO: switch this to property names when possible
    q.setPropertyNames(flattenNames(attributes));
    return q;
  }
}

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

GranuleStoreViewFilterVisitor.unmapIdentifiers(
        q.getFilter(), coverageView.getName());
renamedQuery.setFilter(unmapped);

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

query.setFilter(Filter.EXCLUDE);
FeatureSource fs = getFeatureSource(null, null);
FeatureCollection fc = fs.getFeatures(query);

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

dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000)));
FeatureCollection fc = fs.getFeatures(dq);
if (fc.size() != 1) {

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

Query modified = new Query(q);
modified.setTypeName(typeMap.getOriginalName());
modified.setFilter(retypeFilter(q.getFilter(), typeMap));
List<Join> joins = q.getJoins();
if (!joins.isEmpty()) {

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

defQuery.setFilter(filter);
defQuery.setPropertyNames(propNames);

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

reprojectedQuery.setFilter(reprojectedFilter);
  return reprojectedQuery;
} catch (Exception e) {

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

FF.literal(range.getMinValue()),
        FF.literal(range.getMaxValue()));
query.setFilter(rangeFilter);
query.setMaxFeatures(maxEntries);
query.setPropertyNames(new String[] {descriptor.getStartAttribute()});

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

public Query buildCombinedQuery(
    FeatureCollection<? extends FeatureType, ? extends Feature> featureCollection) {
  List<String> ids =
      FeatureStreams.toFeatureStream(featureCollection)
          .map(Feature::getIdentifier)
          .map(FeatureId::getID)
          .collect(Collectors.toList());
  Filter filter1 = buildCombinedFilter(ids);
  Query query1 = new Query(query);
  query1.setFilter(filter1);
  return query1;
}

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

/**
 * This method changes the query object by simplifying the filter using SimplifyingFilterVisitor
 */
public static Query simplifyFilter(Query query) {
  if (query == null || query == Query.ALL) {
    return query;
  }
  Filter filter = SimplifyingFilterVisitor.simplify(query.getFilter());
  query.setFilter(filter);
  return query;
}

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

public Query buildCombinedQuery(List<String> ids) {
  Filter filter1 = buildCombinedFilter(ids);
  Query query1 = new Query(query);
  query1.setFilter(filter1);
  return query1;
}

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

/**
 * Refine query to make sure to restrict the query to the single file associated.
 *
 * @param q
 * @return
 */
private Query refineQuery(Query q) {
  Query query = new Query(q);
  query.setFilter(refineFilter(q.getFilter()));
  return query;
}

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

protected Query unrollIndexes(Query query) {
  Query newQuery = new Query(query);
  newQuery.setFilter(unrollFilter(query.getFilter()));
  return newQuery;
}

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

public SimpleFeatureCollection subCollection(Filter filter) {
  Query query = new Query();
  query.setFilter(filter);
  query = DataUtilities.mixQueries(this.query, query, null);
  return new ContentFeatureCollection(featureSource, query);
}

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

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

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

private CalcResult countGranulesMatchingCalc(Filter filter, RasterManager manager)
    throws IOException {
  Query q = new Query(manager.getTypeName());
  q.setFilter(filter);
  SimpleFeatureCollection lc = manager.getGranuleCatalog().getGranules(q);
  List<Expression> groupByExpressions =
      Arrays.asList((Expression) getLocationProperty(manager));
  GroupByVisitor groupVisitor =
      new GroupByVisitor(Aggregate.COUNT, NilExpression.NIL, groupByExpressions, null);
  lc.accepts(groupVisitor, null);
  return groupVisitor.getResult();
}

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

private void invertAxisInFilter(Query query) {
  Filter filter = query.getFilter();
  FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null);
  InvertAxisFilterVisitor visitor = new InvertAxisFilterVisitor(ff, new GeometryFactory());
  filter = (Filter) filter.accept(visitor, null);
  query.setFilter(filter);
}

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

public void testSimplifyFilter() {
  FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
  Filter filter = ff.and(Filter.INCLUDE, Filter.INCLUDE);
  Query query = new Query(Query.ALL);
  query.setFilter(filter);
  DataUtilities.simplifyFilter(query);
  assertEquals(Filter.INCLUDE, query.getFilter());
}

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

/** Test of getFilter method, of class org.geotools.data.Query. */
public void testFilter() {
  // System.out.println("testGetFilter");
  Query query = new Query();
  query.setFilter(Filter.EXCLUDE);
  assertEquals(Filter.EXCLUDE, query.getFilter());
  query = new Query("test", Filter.INCLUDE);
  assertEquals(Filter.INCLUDE, query.getFilter());
}

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

public void testCountWithFilter() throws Exception {
  FilterFactory ff = dataStore.getFilterFactory();
  PropertyIsEqualTo filter =
      ff.equals(ff.property(aname("stringProperty")), ff.literal("one"));
  Query query = new Query();
  query.setFilter(filter);
  assertEquals(1, featureSource.getCount(query));
}

相关文章