【问题标题】:Geotools wfs plugin using multiple filterGeotools wfs 插件使用多个过滤器
【发布时间】:2014-01-20 06:54:20
【问题描述】:

我正在使用 Geotools 开发 wfs 应用程序。我正在使用比较过滤器对象进行我的 wfs 功能属性过滤。例如 Shape_Area > 0 或 CITY ="ANKARA" 查询工作正常,但如果我定义另一个过滤器问题就会出现。

System.out.println("type name:"+data.getTypeNames()[3]);
features = data.getFeatureSource(data.getTypeNames()[3]);
//count features
col = features.getFeatures();
System.out.println("# All feature's count= "+col.size());
//create the filter
filter = filterFactory.createCompareFilter(CompareFilter.COMPARE_GREATER_THAN);
FeatureType featureType = features.getFeatures().getSchema();
filter.addLeftValue(filterFactory.createAttributeExpression("Shape_Area"));
filter.addRightValue(filterFactory.createLiteralExpression(100000));
//count filtered features
col = features.getFeatures(filter);
System.out.println("# Filtered results "+col.size());

另一个过滤器(filter2)定义代码示例

 filter2 =filterFactory.createCompareFilter(CompareFilter.COMPARE_EQUALS);
 filter2.addLeftValue(filterFactory.createAttributeExpression("CITY"));
 filter2.addRightValue(filterFactory.createLiteralExpression("ANKARA"));

使用多个过滤器获取结果

col = features.getFeatures(filter.and(filter2));

我哪里做错了?

【问题讨论】:

    标签: java plugins filtering geotools


    【解决方案1】:

    您一定是在使用非常旧的 GeoTools 副本 - 我没有看到 filter.and(filter2) 的使用,因为我们在 GeoTools 2.3 中使过滤器接口不可变?

    您可以尝试一直使用过滤器工厂进行设置吗:

    filter = ff.and(
      ff.greater( ff.property("Shape_Area"), ff.literal(100000)),
      ff.equal( ff.property("CITY"), ff.literal("ANKARA"));
    

    或者使用 CQL:

    filter = CQL.toFilter(" Shape_Area > 100000 AND CITY = 'ANKARA'")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      • 1970-01-01
      • 2014-08-06
      相关资源
      最近更新 更多