【问题标题】:Geotools - get beside parcesGeotools - 在parces旁边
【发布时间】:2013-10-28 10:00:07
【问题描述】:

我有问题需要帮助。我在 postgis 中有包含多边形的 parces 地图层。该层遵循不重叠拓扑规则。 我如何使用 geotools api 获得“旁边”选定功能的功能? “旁边”特征是特征至少有一个相同的边缘。

For example in this picture, when select feature A, i need to get feature B,C,D, not get feature E.

任何帮助都非常感谢!谢谢!

【问题讨论】:

    标签: geotools


    【解决方案1】:

    我通过这段代码解决了我的问题

    public static void getRoundFeature(SimpleFeature feature, SimpleFeatureSource featureSource){ FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null ); 几何 g = (Geometry) feature.getAttribute("the_geom");

    Polygon polygon = geometryFactory.createPolygon(g.getCoordinates());
    //Polygon poly = (Polygon) feature;
    Filter filter = ff.intersects(ff.property("the_geom"), ff.literal(polygon));
    try {
        SimpleFeatureCollection featureCollection = featureSource.getFeatures(filter);
        //System.out.println("feature around: "+ featureCollection.size());
        FeatureIterator iter = featureCollection.features();
        while(iter.hasNext()){
            SimpleFeature rfeature = (SimpleFeature) iter.next();
            System.out.println("so to: "+rfeature.getAttribute("soto")+ "so thua: "+rfeature.getAttribute("sothua"));
        }
    
    } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e);
    }
    

    }

    【讨论】:

      猜你喜欢
      • 2017-06-21
      • 2013-12-10
      • 2015-11-13
      • 2018-05-09
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多