/** * In some cases, ways can be outside the loading area (still inside the osm PBF) and connected * to some other ways that are inside the loading area, but still inside the country boundary. * That happens at shard boundaries, which do a soft cut. * * @throws IOException * Exception thrown when {@link OsmosisReaderMock} fails to close */ @Test public void testBoundaryNodesForWayOutsideLoadingAreaButInsideCountryBoundary() throws IOException { try (OsmosisReaderMock osmosis = new OsmosisReaderMock(this.store)) { // Here, reduce the loading bounds to a small area around Edge 3. In this case // Node 3 is included in the country boundary but not in the loading area. It // should not have any boundary tag. final AtlasLoadingOption loadingOption = AtlasLoadingOption.createOptionWithNoSlicing(); Atlas atlas = new RawAtlasGenerator(() -> osmosis, loadingOption, MultiPolygon.MAXIMUM) .build(); atlas = new WaySectionProcessor(atlas, loadingOption).run(); logger.info("{}", atlas); final Edge edgeIn = atlas.edgesIntersecting(DE_ANZA_AT_280.bounds()).iterator().next(); final Node nodeIn = edgeIn.end(); Assert.assertNull(nodeIn.tag(SyntheticBoundaryNodeTag.KEY)); } }
@Test public void testOutsideWayBoundaryNodes() throws IOException { try (OsmosisReaderMock osmosis = new OsmosisReaderMock(this.store)) { final AtlasLoadingOption loadingOption = AtlasLoadingOption .createOptionWithAllEnabled(this.countryBoundaries1) .setAdditionalCountryCodes(COUNTRY_1_NAME); Atlas atlas = new RawAtlasGenerator(() -> osmosis, loadingOption, MultiPolygon.MAXIMUM) .build(); atlas = new RawAtlasCountrySlicer(COUNTRY_1_NAME, loadingOption.getCountryBoundaryMap()) .slice(atlas); atlas = new WaySectionProcessor(atlas, AtlasLoadingOption.createOptionWithNoSlicing()) .run(); logger.info("{}", atlas); final Edge edgeOut = atlas.edgesIntersecting(OUTSIDE_COUNTRY_1.bounds()).iterator() .next(); final Node nodeOut = edgeOut.end(); Assert.assertNotNull(nodeOut.tag(SyntheticBoundaryNodeTag.KEY)); final Edge edgeIn = atlas.edgesIntersecting(Location.TEST_7.bounds()).iterator().next(); final Node nodeIn = edgeIn.end(); Assert.assertNull(nodeIn.tag(SyntheticBoundaryNodeTag.KEY)); Assert.assertEquals(2, atlas.numberOfPoints()); } } }
@Test public void allNodesAreTrafficLights() { resetAndChange("allNodesAreTrafficLights", atlas -> { return Iterables .stream(atlas.nodes()).map(node -> CompleteNode.shallowFrom(node) .withAddedTag("highway", "traffic_signals")) .map(FeatureChange::add).collectToSet(); }); final Predicate<Node> trafficSignal = node -> "traffic_signals".equals(node.tag("highway")); final long changeAtlasNodesWithTrafficSignals = Iterables .size(this.changeAtlas.nodes(trafficSignal)); final long originalAtlasNodesWithTrafficSignals = Iterables .size(this.atlas.nodes(trafficSignal)); final long subAtlasNodesWithTrafficSignals = Iterables .size(this.subAtlas.nodes(trafficSignal)); Assert.assertEquals(162, changeAtlasNodesWithTrafficSignals); Assert.assertEquals(9, originalAtlasNodesWithTrafficSignals); Assert.assertEquals(4, subAtlasNodesWithTrafficSignals); Assert.assertEquals(changeAtlasNodesWithTrafficSignals - originalAtlasNodesWithTrafficSignals + subAtlasNodesWithTrafficSignals, this.subAtlas.numberOfNodes()); }