查找具有最重叠的bbox的形状(多边形)

时间:2012-09-03 17:59:20

标签: sorting gis intersection cql

我正在尝试构建一个CQL查询,以便在我的spartial数据库中找到某个形状。

我希望我的查询返回最大交点的形状。我的想法是设置LIMIT = 1和sortBy交集。

如果您看到附带的屏幕截图,我希望我的查询返回以下内容:

从左到右的三角形

  • Filter1 - >黄色形状
  • Filter2 - >黄色形状
  • 过滤器3 - >绿色形状

有什么方法可以解决我的问题吗?

到目前为止我使用了以下代码:

    Filter f1 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.07051 53.23476, 10.08143 53.23512, 10.07596 53.22838, 10.07051 53.23476)))");
    Filter f2 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.06268 53.23756, 10.06889 53.23865, 10.06260 53.24903, 10.06268 53.23756)))");
    Filter f3 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.08146 53.24462, 10.09540 53.24761, 10.08247 53.26067, 10.08146 53.24462)))");

    Query query = new Query( typeName, f3);
    query.setMaxFeatures(1);
    source.getFeatures(query);

    SimpleFeatureCollection features = source.getFeatures(query);
    SimpleFeatureIterator it = features.features();
    while (it.hasNext()){
        SimpleFeature sf = it.next();
        System.out.println(sf.getAttributes());
    }

See the screenshot here

0 个答案:

没有答案