本文介绍了如何计算 Atlas 中的湖泊总面积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我在内存中加载了一个 Atlas 对象,是计算湖泊总面积的最佳方法?做一个简单的标签搜索找到所有简单的 Area 湖泊,但我错过了所有基于 type=multipolygon Relations 的湖泊,这些湖泊建立在外部"方式上,缝合在一起,制作一个完整的湖泊.

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.

推荐答案

Atlas 自带一个 ComplexEntity 概念,允许用户基于具体概念.ComplexWaterEntity 对象应该适合这种需要:

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

这篇关于如何计算 Atlas 中的湖泊总面积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 00:02