Search in sources :

Example 1 with AtlasLoadingOption

use of org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption in project atlas by osmlab.

the class AbstractAtlas method createAndSaveOsmPbfWithSlicing.

/**
 * Create an {@link Atlas} from an OSM protobuf that has already been sliced and save it to a
 * resource
 *
 * @param osmPbf
 *            The OSM protobuf
 * @param atlasResource
 *            The {@link WritableResource} to save the {@link Atlas} to
 * @param boundaryMap
 *            The {@link CountryBoundaryMap} to use for country-slicing
 * @return The created {@link Atlas}
 */
public static Atlas createAndSaveOsmPbfWithSlicing(final Resource osmPbf, final WritableResource atlasResource, final CountryBoundaryMap boundaryMap) {
    Atlas atlas = new RawAtlasGenerator(osmPbf).build();
    final AtlasLoadingOption loadingOption = AtlasLoadingOption.createOptionWithAllEnabled(boundaryMap);
    atlas = new RawAtlasSlicer(loadingOption, atlas).slice();
    atlas = new WaySectionProcessor(atlas, AtlasLoadingOption.createOptionWithAllEnabled(boundaryMap)).run();
    atlas.save(atlasResource);
    return atlas;
}
Also used : PackedAtlas(org.openstreetmap.atlas.geography.atlas.packed.PackedAtlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)

Example 2 with AtlasLoadingOption

use of org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption in project atlas by osmlab.

the class AtlasIntegrationTest method loadBahamas.

protected Atlas loadBahamas(final Polygon polygon) {
    final String path = OsmPbfIngestIntegrationTest.class.getResource("BHS-6-18-27.pbf").getPath();
    final AtlasLoadingOption loadingOption = AtlasLoadingOption.createOptionWithOnlySectioning().setLoadWaysSpanningCountryBoundaries(false);
    final Atlas atlas = new RawAtlasGenerator(new File(path), loadingOption, MultiPolygon.forPolygon(polygon)).build();
    return new WaySectionProcessor(atlas, loadingOption).run();
}
Also used : WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) OsmPbfIngestIntegrationTest(org.openstreetmap.atlas.geography.atlas.pbf.OsmPbfIngestIntegrationTest) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) File(org.openstreetmap.atlas.streaming.resource.File) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)

Example 3 with AtlasLoadingOption

use of org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption in project atlas by osmlab.

the class AtlasDebugTool method onRun.

@Override
protected int onRun(final CommandMap command) {
    final File pbf = (File) command.get(PBF);
    final File atlasFile = (File) command.get(ATLAS);
    final File geojson = (File) command.get(GEOJSON);
    final File text = (File) command.get(TEXT);
    final java.io.File boundaryFile = (java.io.File) command.get(BOUNDARY);
    final String country = (String) command.get(COUNTRY);
    final Rectangle bound = (Rectangle) command.get(BOUND);
    final MultiPolygon inputMultipolygon = (MultiPolygon) command.get(MULTIPOLYGON);
    @SuppressWarnings("unchecked") final List<Location> startEndRoute = (List<Location>) command.get(ROUTE);
    Atlas atlas;
    if (pbf != null && pbf.exists()) {
        final AtlasLoadingOption option;
        MultiPolygon multiPolygon = MultiPolygon.forPolygon(Rectangle.MAXIMUM);
        if (boundaryFile != null) {
            final CountryBoundaryMap boundaryMap = CountryBoundaryMap.fromShapeFile(boundaryFile);
            option = AtlasLoadingOption.createOptionWithAllEnabled(boundaryMap);
            if (country != null) {
                if (new CountryListTwoWayStringConverter().convert(country).size() == 1) {
                    multiPolygon = boundaryMap.countryBoundary(country).get(0).getBoundary();
                }
                option.setCountryCode(country);
            }
        } else {
            option = AtlasLoadingOption.createOptionWithNoSlicing();
        }
        if (bound != null) {
            multiPolygon = MultiPolygon.forPolygon(bound);
        }
        if (inputMultipolygon != null) {
            multiPolygon = inputMultipolygon;
        }
        atlas = new RawAtlasGenerator(pbf, option, multiPolygon).build();
        if (option.isCountrySlicing()) {
            atlas = new RawAtlasSlicer(option, atlas).slice();
        }
        atlas = new WaySectionProcessor(atlas, option).run();
        atlas.save(atlasFile);
    } else if (atlasFile != null && atlasFile.exists()) {
        atlas = new AtlasResourceLoader().load(atlasFile);
    } else {
        logger.error("Must have at least one source, -pbf or -atlas");
        atlas = null;
        System.exit(1);
    }
    logger.info("Loaded {}", atlas.summary());
    if (geojson != null) {
        atlas.saveAsGeoJson(geojson);
    }
    if (text != null) {
        atlas.saveAsText(text);
    }
    if (startEndRoute != null) {
        logger.info("Route between {} and {} = {}", startEndRoute.get(0), startEndRoute.get(1), AStarRouter.dijkstra(atlas, Distance.TEN_MILES).route(startEndRoute.get(0), startEndRoute.get(1)));
    }
    return 0;
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) Rectangle(org.openstreetmap.atlas.geography.Rectangle) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator) AtlasResourceLoader(org.openstreetmap.atlas.geography.atlas.AtlasResourceLoader) MultiPolygon(org.openstreetmap.atlas.geography.MultiPolygon) ArrayList(java.util.ArrayList) List(java.util.List) StringList(org.openstreetmap.atlas.utilities.collections.StringList) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) CountryBoundaryMap(org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap) CountryListTwoWayStringConverter(org.openstreetmap.atlas.geography.boundary.converters.CountryListTwoWayStringConverter) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) File(org.openstreetmap.atlas.streaming.resource.File) Location(org.openstreetmap.atlas.geography.Location)

Example 4 with AtlasLoadingOption

use of org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption in project atlas by osmlab.

the class OsmPbfToAtlasSubCommand method execute.

@Override
public int execute(final CommandMap map) {
    final AtlasLoadingOption options = this.getAtlasLoadingOption(map);
    Atlas atlas = new RawAtlasGenerator((File) map.get(INPUT_PARAMETER), options, MultiPolygon.MAXIMUM).build();
    if (options.isCountrySlicing()) {
        atlas = new RawAtlasSlicer(options, atlas).slice();
    }
    atlas = new WaySectionProcessor(atlas, options).run();
    atlas.save((File) map.get(OUTPUT_PARAMETER));
    return 0;
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) File(org.openstreetmap.atlas.streaming.resource.File) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)

Example 5 with AtlasLoadingOption

use of org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption in project atlas by osmlab.

the class TestAtlasHandler method buildAtlasFromPbf.

/**
 * Builds an {@link Atlas} from the given pbf resource, using the raw atlas flow. This does NOT
 * country-slice the pbf resource since no corresponding boundary file is supplied and the flow
 * is not meant to test slicing logic.
 *
 * @param pbfResource
 *            The pbf input resource to use
 * @param iso
 *            ISO code to be applied to all features
 * @return the resulting Atlas
 */
private static Atlas buildAtlasFromPbf(final Resource pbfResource, final Optional<String> iso) {
    // Create raw Atlas
    final AtlasLoadingOption loadingOption = AtlasLoadingOption.withNoFilter();
    if (iso.isPresent()) {
        loadingOption.setCountrySlicing(true);
        loadingOption.setCountryBoundaryMap(CountryBoundaryMap.fromBoundaryMap(Collections.singletonMap(iso.get(), MultiPolygon.MAXIMUM)));
    }
    final Atlas rawAtlas = new RawAtlasGenerator(pbfResource, loadingOption, MultiPolygon.MAXIMUM).build();
    // Country Slice and Way-Section
    return new WaySectionProcessor(iso.isPresent() ? new RawAtlasSlicer(loadingOption, rawAtlas).slice() : rawAtlas, loadingOption).run();
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) AtlasLoadingOption(org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)

Aggregations

AtlasLoadingOption (org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption)11 Atlas (org.openstreetmap.atlas.geography.atlas.Atlas)7 RawAtlasGenerator (org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)7 WaySectionProcessor (org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor)6 CountryBoundaryMap (org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap)6 RawAtlasSlicer (org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer)5 File (org.openstreetmap.atlas.streaming.resource.File)5 MultiPolygon (org.openstreetmap.atlas.geography.MultiPolygon)3 StringResource (org.openstreetmap.atlas.streaming.resource.StringResource)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Rectangle (org.openstreetmap.atlas.geography.Rectangle)2 BridgeConfiguredFilter (org.openstreetmap.atlas.geography.atlas.pbf.BridgeConfiguredFilter)2 Shard (org.openstreetmap.atlas.geography.sharding.Shard)2 ConfiguredTaggableFilter (org.openstreetmap.atlas.tags.filters.ConfiguredTaggableFilter)2 StandardConfiguration (org.openstreetmap.atlas.utilities.configuration.StandardConfiguration)2 Time (org.openstreetmap.atlas.utilities.time.Time)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1