一旦我在内存中加载了Atlas对象,计算总湖泊面积的最佳方法是什么?执行简单的标记搜索会找到所有简单的Area
湖泊,但是我错过了所有基于type = multipolygon Relations
的湖泊,这些湖泊是基于“外部”方式构建的,这些方式缝合在一起就构成了一个完整的湖泊。
答案 0 :(得分:0)
Atlas带有ComplexEntity
概念,该概念允许用户根据特定概念构造更高级别的实体。 ComplexWaterEntity
对象应符合需要:
Atlas atlas;
Iterable<ComplexWaterEntity> waterEntities =
new ComplexWaterEntityFinder().find(atlas);
// Get all water bodies and keep lakes only.
// This will include the multipolygon ones.
Iterable<ComplexWaterBody> lakes = Iterables.stream(waterEntities)
.filter(entity -> WaterType.LAKE == entity.getWaterType())
.map(entity -> (ComplexWaterBody) entity);
// Add all the surface areas
Surface result = Surface.MINIMUM;
for (ComplexWaterBody lake : lakes)
{
result = result.add(lake.getGeometry().getSurface()));
}
System.out.println(result.asKilometerSquared());