2013-10-28 3 views
1

У меня возникла проблема, требующая помощи. У меня есть слой карт parces в postgis, который содержит многоугольники. Этот слой следует за правилом топологии перекрытия. Как я могу получить функции, которые «рядом» с выбранной функцией с geotools api? Функция «рядом» имеет функцию по крайней мере одного края. enter image description hereGeotools - получить рядом с парами

Например, в этой картине, когда выберите функцию A, мне нужно получить функцию B, C, D, не получают особенность E.

Любая помощь высоко ценят! Благодаря!

ответ

1

Я решить мою проблему этим кодом

государственной статической силы getRoundFeature (функция SimpleFeature, SimpleFeatureSource featureSource) { FilterFactory2 ФФ = CommonFactoryFinder.getFilterFactory2(); ГеометрияFactory geometryFactory = JTSFactoryFinder.getGeometryFactory (null); Геометрия g = (Геометрия) 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); 
} 

}

Смежные вопросы