Search in sources :

Example 1 with RawAtlasGenerator

use of org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator 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 RawAtlasGenerator

use of org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator in project atlas by osmlab.

the class RawAtlasIntegrationTest method testStandAloneNodeIngest.

@Ignore
@Test
public void testStandAloneNodeIngest() {
    // Create a raw atlas, slice and section it
    final String pbfPath = RawAtlasIntegrationTest.class.getResource("node-4353689487.pbf").getPath();
    final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(pbfPath));
    final Atlas rawAtlas = rawAtlasGenerator.build();
    final Atlas slicedRawAtlas = new RawAtlasSlicer(loadingOptionAntarctica, rawAtlas).slice();
    final Atlas finalAtlas = new WaySectionProcessor(slicedRawAtlas, loadingOptionAntarctica).run();
    // Verify only a single point exists
    Assert.assertEquals(0, finalAtlas.numberOfNodes());
    Assert.assertEquals(0, finalAtlas.numberOfEdges());
    Assert.assertEquals(0, finalAtlas.numberOfAreas());
    Assert.assertEquals(1, finalAtlas.numberOfPoints());
    Assert.assertEquals(0, finalAtlas.numberOfLines());
    Assert.assertEquals(0, finalAtlas.numberOfRelations());
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) 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) Ignore(org.junit.Ignore) Test(org.junit.Test) ShardFileOverlapsPolygonTest(org.openstreetmap.atlas.geography.atlas.ShardFileOverlapsPolygonTest)

Example 3 with RawAtlasGenerator

use of org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator in project atlas by osmlab.

the class RawAtlasIntegrationTest method testTwoWaysWithDifferentLayersIntersectingInMiddle.

@Test
public void testTwoWaysWithDifferentLayersIntersectingInMiddle() {
    // Based on https://www.openstreetmap.org/way/467880095 and
    // https://www.openstreetmap.org/way/28247094 having two different layer tag values and
    // having overlapping nodes (https://www.openstreetmap.org/node/4661272336 and
    // https://www.openstreetmap.org/node/5501637097) that should not be merged.
    final Location overlappingLocation = Location.forString("1.3248985,103.6452864");
    final String path = RawAtlasIntegrationTest.class.getResource("twoWaysWithDifferentLayersIntersectingInMiddle.pbf").getPath();
    final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(path));
    final Atlas rawAtlas = rawAtlasGenerator.build();
    // Verify both points made it into the raw atlas
    Assert.assertTrue(Iterables.size(rawAtlas.pointsAt(overlappingLocation)) == 2);
    final Atlas slicedRawAtlas = new RawAtlasSlicer(loadingOptionIntersectionAtMiddle, rawAtlas).slice();
    final Atlas finalAtlas = new WaySectionProcessor(slicedRawAtlas, loadingOptionIntersectionAtMiddle).run();
    // Make sure there is no sectioning happening between the two ways with different layer tag
    // values. There is a one-way overpass and a bi-directional residential street, resulting in
    // 3 total edges and 4 nodes (one on both ends of the two segments)
    Assert.assertEquals(3, finalAtlas.numberOfEdges());
    Assert.assertEquals(4, finalAtlas.numberOfNodes());
    // Again, verify there is no node at the duplicated location
    Assert.assertTrue(Iterables.size(finalAtlas.nodesAt(overlappingLocation)) == 0);
    Assert.assertEquals(0, finalAtlas.numberOfPoints());
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) RawAtlasSlicer(org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer) File(org.openstreetmap.atlas.streaming.resource.File) Location(org.openstreetmap.atlas.geography.Location) RawAtlasGenerator(org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator) Test(org.junit.Test) ShardFileOverlapsPolygonTest(org.openstreetmap.atlas.geography.atlas.ShardFileOverlapsPolygonTest)

Example 4 with RawAtlasGenerator

use of org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator in project atlas by osmlab.

the class RawAtlasIntegrationTest method testPbfToSlicedRawAtlas.

@Ignore
@Test
public void testPbfToSlicedRawAtlas() {
    // This PBF file contains really interesting data. 1. MultiPolygon with multiple inners and
    // outers spanning 3 countries (http://www.openstreetmap.org/relation/3638082) 2. Multiple
    // nested relations (http://www.openstreetmap.org/relation/3314886)
    final String pbfPath = RawAtlasIntegrationTest.class.getResource("8-122-122-trimmed.osm.pbf").getPath();
    final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(new File(pbfPath));
    final Atlas rawAtlas = rawAtlasGenerator.build();
    Assert.assertEquals(0, rawAtlas.numberOfNodes());
    Assert.assertEquals(0, rawAtlas.numberOfEdges());
    Assert.assertEquals(0, rawAtlas.numberOfAreas());
    Assert.assertEquals(74342, rawAtlas.numberOfPoints());
    Assert.assertEquals(7818, rawAtlas.numberOfLines());
    Assert.assertEquals(17, rawAtlas.numberOfRelations());
    final Atlas slicedRawAtlas = new RawAtlasSlicer(loadingOptionAll, rawAtlas).slice();
    Assert.assertEquals(0, slicedRawAtlas.numberOfNodes());
    Assert.assertEquals(0, slicedRawAtlas.numberOfEdges());
    Assert.assertEquals(0, slicedRawAtlas.numberOfAreas());
    Assert.assertEquals(74850, slicedRawAtlas.numberOfPoints());
    Assert.assertEquals(8086, slicedRawAtlas.numberOfLines());
    Assert.assertEquals(23, slicedRawAtlas.numberOfRelations());
    // Assert all raw Atlas entities have a country code
    assertAllEntitiesHaveCountryCode(slicedRawAtlas);
    final Atlas ivoryCoast = new RawAtlasSlicer(loadingOptionIvoryCoast, rawAtlas).slice();
    Assert.assertEquals(0, ivoryCoast.numberOfNodes());
    Assert.assertEquals(0, ivoryCoast.numberOfEdges());
    Assert.assertEquals(0, ivoryCoast.numberOfAreas());
    Assert.assertEquals(34962, ivoryCoast.numberOfPoints());
    Assert.assertEquals(3637, ivoryCoast.numberOfLines());
    Assert.assertEquals(12, ivoryCoast.numberOfRelations());
    // Assert all raw Atlas entities have a country code
    assertAllEntitiesHaveCountryCode(ivoryCoast);
    // Test sectioning!
    final Atlas finalAtlas = new WaySectionProcessor(slicedRawAtlas, loadingOptionAll).run();
    Assert.assertEquals(5011, finalAtlas.numberOfNodes());
    Assert.assertEquals(9764, finalAtlas.numberOfEdges());
    Assert.assertEquals(5133, finalAtlas.numberOfAreas());
    Assert.assertEquals(184, finalAtlas.numberOfPoints());
    Assert.assertEquals(326, finalAtlas.numberOfLines());
    Assert.assertEquals(23, finalAtlas.numberOfRelations());
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) WaySectionProcessor(org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor) 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) Ignore(org.junit.Ignore) Test(org.junit.Test) ShardFileOverlapsPolygonTest(org.openstreetmap.atlas.geography.atlas.ShardFileOverlapsPolygonTest)

Example 5 with RawAtlasGenerator

use of org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator 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)

Aggregations

RawAtlasGenerator (org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator)25 WaySectionProcessor (org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor)22 Atlas (org.openstreetmap.atlas.geography.atlas.Atlas)18 RawAtlasSlicer (org.openstreetmap.atlas.geography.atlas.raw.slicing.RawAtlasSlicer)16 Test (org.junit.Test)12 File (org.openstreetmap.atlas.streaming.resource.File)12 AtlasLoadingOption (org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption)9 CountryBoundaryMap (org.openstreetmap.atlas.geography.boundary.CountryBoundaryMap)7 MultiPolygon (org.openstreetmap.atlas.geography.MultiPolygon)6 ShardFileOverlapsPolygonTest (org.openstreetmap.atlas.geography.atlas.ShardFileOverlapsPolygonTest)6 Location (org.openstreetmap.atlas.geography.Location)5 PackedAtlas (org.openstreetmap.atlas.geography.atlas.packed.PackedAtlas)5 InputStreamResource (org.openstreetmap.atlas.streaming.resource.InputStreamResource)4 Resource (org.openstreetmap.atlas.streaming.resource.Resource)4 Ignore (org.junit.Ignore)3 ArrayList (java.util.ArrayList)2 AtlasMetaData (org.openstreetmap.atlas.geography.atlas.AtlasMetaData)2 Edge (org.openstreetmap.atlas.geography.atlas.items.Edge)2 MultiAtlas (org.openstreetmap.atlas.geography.atlas.multi.MultiAtlas)2 OsmPbfIngestIntegrationTest (org.openstreetmap.atlas.geography.atlas.pbf.OsmPbfIngestIntegrationTest)2