How to count the total lake area in an Atlas

851 views java
4

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.

answered question

1 Answer

0

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

posted this

Have an answer?

JD

Please login first before posting an answer.