use of org.openstreetmap.atlas.geography.atlas.items.complex.boundaries.ComplexBoundaryFinder in project atlas by osmlab.
the class CountryBoundaryMap method readFromAtlas.
/**
* Read a {@link CountryBoundaryMap} from the {@link ComplexBoundary}(ies) inside an
* {@link Atlas}
*
* @param atlas
* The {@link Atlas} to read from.
*/
public void readFromAtlas(final Atlas atlas) {
final Iterable<ComplexBoundary> deduplicatedComplexBoundaries = resolveOverlappingBorders(new ComplexBoundaryFinder().find(atlas));
for (final ComplexBoundary complexBoundary : deduplicatedComplexBoundaries) {
if (complexBoundary.hasCountryCode()) {
final List<String> countryCodes = new ArrayList<>();
try {
final MultiPolygon outline = complexBoundary.getOutline();
final org.locationtech.jts.geom.MultiPolygon multiPolygon = JTS_MULTI_POLYGON_TO_MULTI_POLYGON_CONVERTER.backwardConvert(outline);
complexBoundary.getCountries().forEach(isoCountry -> this.addCountry(isoCountry.getIso3CountryCode(), multiPolygon));
} catch (final IllegalArgumentException e) {
throw new CoreException("Unable to read country boundary for country codes {}", countryCodes, e);
}
}
}
}
Aggregations