use of org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap in project atlas-generator by osmlab.
the class WorldAtlasGenerator method onRun.
@Override
protected int onRun(final CommandMap command) {
CountryBoundaryMap countryBoundaryMap = (CountryBoundaryMap) command.get(BOUNDARIES);
if (countryBoundaryMap == null) {
final StringResource wholeWorld = new StringResource("AAA||" + Rectangle.MAXIMUM.toWkt());
countryBoundaryMap = CountryBoundaryMap.fromPlainText(wholeWorld);
}
final File edgeConfiguration = (File) command.get(EDGE_CONFIGURATION);
final File pbfWayConfiguration = (File) command.get(PBF_WAY_CONFIGURATION);
final File pbfNodeConfiguration = (File) command.get(PBF_NODE_CONFIGURATION);
final File pbfRelationConfiguration = (File) command.get(PBF_RELATION_CONFIGURATION);
final Resource pbf = (Resource) command.get(PBF);
final WritableResource output = (WritableResource) command.get(ATLAS);
final File statisticsOutput = (File) command.get(STATISTICS);
final String codeVersion = (String) command.get(CODE_VERSION);
final String dataVersion = (String) command.get(DATA_VERSION);
final Shard world = SlippyTile.ROOT;
final Time start = Time.now();
// Prepare
final AtlasLoadingOption loadingOptions = AtlasLoadingOption.createOptionWithAllEnabled(countryBoundaryMap);
if (edgeConfiguration != null) {
loadingOptions.setEdgeFilter(new BridgeConfiguredFilter("", AtlasLoadingOption.ATLAS_EDGE_FILTER_NAME, new StandardConfiguration(edgeConfiguration)));
}
if (pbfWayConfiguration == null) {
loadingOptions.setOsmPbfWayFilter(PBF_NO_FILTER_CONFIGURATION);
} else {
loadingOptions.setOsmPbfWayFilter(new ConfiguredTaggableFilter(new StandardConfiguration(pbfWayConfiguration)));
}
if (pbfNodeConfiguration == null) {
loadingOptions.setOsmPbfNodeFilter(PBF_NO_FILTER_CONFIGURATION);
} else {
loadingOptions.setOsmPbfNodeFilter(new ConfiguredTaggableFilter(new StandardConfiguration(pbfNodeConfiguration)));
}
if (pbfRelationConfiguration == null) {
loadingOptions.setOsmPbfRelationFilter(PBF_NO_FILTER_CONFIGURATION);
} else {
loadingOptions.setOsmPbfRelationFilter(new ConfiguredTaggableFilter(new StandardConfiguration(pbfRelationConfiguration)));
}
final AtlasMetaData metaData = new AtlasMetaData(null, true, codeVersion, dataVersion, "WORLD", world.getName(), Maps.hashMap());
final Counter counter = new Counter();
counter.setCountsDefinition(Counter.POI_COUNTS_DEFINITION.getDefault());
Atlas atlas;
logger.info("Generating world atlas from {}", pbf);
atlas = new RawAtlasGenerator(pbf, loadingOptions, MultiPolygon.MAXIMUM).withMetaData(metaData).build();
if (loadingOptions.isCountrySlicing()) {
atlas = new RawAtlasSlicer(loadingOptions, atlas).slice();
}
if (loadingOptions.isWaySectioning()) {
atlas = new WaySectionProcessor(atlas, loadingOptions).run();
}
if (atlas == null) {
logger.warn("There was no data to add to the Atlas.");
return 0;
}
logger.info("Saving world atlas to {}", output);
atlas.save(output);
if (statisticsOutput != null) {
logger.info("Generating world statistics...");
final AtlasStatistics statistics = counter.processAtlas(atlas);
logger.info("Saving world statistics to {}", statisticsOutput);
statistics.save(statisticsOutput);
}
logger.info("Finished creating world atlas in {}", start.elapsedSince());
return 0;
}
use of org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap in project atlas-generator by osmlab.
the class AtlasGeneratorTest method testGenerateTasksEmptyBoundaryAndCountryList.
@Test
public void testGenerateTasksEmptyBoundaryAndCountryList() {
final CountryBoundaryMap boundaryMap = new CountryBoundaryMap();
Assert.assertTrue(AtlasGenerator.generateTasks(Lists.newArrayList(), boundaryMap, SHARDING).isEmpty());
}
Aggregations