How to count the total lake area in an Atlas

☆樱花仙子☆ 提交于 2020-01-16 16:09:25

问题


Once I have loaded an Atlas object in memory, what is the best way to count the total lake area? Doing a simple tag search finds all the simple Area lakes but I am missing all the lakes based on type=multipolygon Relations that are built on "outer" ways that, stitched together, make a full lake.


回答1:


Atlas comes with a ComplexEntity concept that allows the user to construct higher-level entities based on specific concepts. The ComplexWaterEntity object should fit that need:

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());


来源:https://stackoverflow.com/questions/53199589/how-to-count-the-total-lake-area-in-an-atlas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!