Search in sources :

Example 26 with CountryBoundaryMap

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;
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) WritableResource(org.openstreetmap.atlas.streaming.resource.WritableResource) Resource(org.openstreetmap.atlas.streaming.resource.Resource) StringResource(org.openstreetmap.atlas.streaming.resource.StringResource) Time(org.openstreetmap.atlas.utilities.time.Time) StandardConfiguration(org.openstreetmap.atlas.utilities.configuration.StandardConfiguration) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator) AtlasMetaData(org.openstreetmap.atlas.geography.atlas.AtlasMetaData) StringResource(org.openstreetmap.atlas.streaming.resource.StringResource) WritableResource(org.openstreetmap.atlas.streaming.resource.WritableResource) BridgeConfiguredFilter(org.openstreetmap.atlas.geography.atlas.pbf.BridgeConfiguredFilter) Counter(org.openstreetmap.atlas.geography.atlas.statistics.Counter) AtlasStatistics(org.openstreetmap.atlas.geography.atlas.statistics.AtlasStatistics) ConfiguredTaggableFilter(org.openstreetmap.atlas.tags.filters.ConfiguredTaggableFilter) CountryBoundaryMap(org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap) Shard(org.openstreetmap.atlas.geography.sharding.Shard) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) File(org.openstreetmap.atlas.streaming.resource.File)

Example 27 with CountryBoundaryMap

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());
}
Also used : CountryBoundaryMap(org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap) Test(org.junit.Test)

Aggregations

CountryBoundaryMap (org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap)27 Test (org.junit.Test)11 Atlas (org.openstreetmap.atlas.geography.atlas.Atlas)11 File (org.openstreetmap.atlas.streaming.resource.File)10 InputStreamResource (org.openstreetmap.atlas.streaming.resource.InputStreamResource)9 MultiPolygon (org.openstreetmap.atlas.geography.MultiPolygon)6 RawAtlasGenerator (org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)6 RawAtlasSlicer (org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer)6 StringList (org.openstreetmap.atlas.utilities.collections.StringList)6 AtlasLoadingOption (org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption)5 WaySectionProcessor (org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor)5 StandardConfiguration (org.openstreetmap.atlas.utilities.configuration.StandardConfiguration)5 Time (org.openstreetmap.atlas.utilities.time.Time)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Optional (java.util.Optional)4 CountryShard (org.openstreetmap.atlas.geography.sharding.CountryShard)4 Resource (org.openstreetmap.atlas.streaming.resource.Resource)4 StringResource (org.openstreetmap.atlas.streaming.resource.StringResource)4 HashMap (java.util.HashMap)3