use of org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor 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;
}
use of org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor 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());
}
use of org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor 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());
}
use of org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor 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());
}
use of org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor 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();
}
Aggregations