@Test public void testLineTouchingBoundary() { final Atlas rawAtlas = this.setup.getRoadTouchingBoundaryAtlas(); final Atlas slicedAtlas = new RawAtlasCountrySlicer(COUNTRIES, COUNTRY_BOUNDARY_MAP) .slice(rawAtlas); // Check Line correctness Assert.assertEquals("A single line exists in the raw Atlas", 1, rawAtlas.numberOfLines()); Assert.assertEquals("The line was untouched after cutting", 1, slicedAtlas.numberOfLines()); Assert.assertEquals("Expect the line to have Ivory Coast country code", "CIV", slicedAtlas.line(1).getTag(ISOCountryTag.KEY).get()); // Check Point correctness Assert.assertEquals("Two points exist in the raw Atlas", 2, rawAtlas.numberOfPoints()); Assert.assertEquals("Two points exist in the sliced Atlas", 2, slicedAtlas.numberOfPoints()); final Point fullyInIvoryCoast = slicedAtlas.point(1); Assert.assertEquals("Expect point to be fully inside Ivory Coast border", "CIV", fullyInIvoryCoast.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("Point should not have a synthetic boundary tag", fullyInIvoryCoast.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); final Point exactlyOnBorder = slicedAtlas.point(2); Assert.assertEquals("Expect point on border to have two country codes", "CIV,LBR", exactlyOnBorder.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals("Point should have an existing synthetic boundary tag", SyntheticBoundaryNodeTag.EXISTING.toString(), exactlyOnBorder.getTag(SyntheticBoundaryNodeTag.KEY).get()); }
@Test public void testLineFullyInsideOneCountry() { final Atlas rawAtlas = this.setup.getRoadFullyInOneCountryAtlas(); final Atlas slicedAtlas = RAW_ATLAS_SLICER.slice(rawAtlas); // Check Line correctness Assert.assertEquals("A single line exists in the raw Atlas", 1, rawAtlas.numberOfLines()); Assert.assertEquals("The line was untouched after cutting", 1, slicedAtlas.numberOfLines()); Assert.assertEquals("Expect the line to have Ivory Coast country code", "CIV", slicedAtlas.line(1).getTag(ISOCountryTag.KEY).get()); // Check Point correctness Assert.assertEquals("Two points exist in the raw Atlas", 2, rawAtlas.numberOfPoints()); Assert.assertEquals("Two points exist in the sliced Atlas", 2, slicedAtlas.numberOfPoints()); slicedAtlas.points().forEach(point -> { Assert.assertEquals("Expect all points to be fully inside Ivory Coast border", "CIV", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); }); }
"CIV", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); "LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); "CIV,LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals("All new points are non-existing synthetic boundary nodes", SyntheticBoundaryNodeTag.YES.toString(), point.getTag(SyntheticBoundaryNodeTag.KEY).get());
@Test public void testClosedLineInsideSingleCountry() { final Atlas rawAtlas = this.setup.getClosedLineFullyInOneCountryAtlas(); final Atlas slicedAtlas = RAW_ATLAS_SLICER.slice(rawAtlas); // Check Line correctness Assert.assertEquals("A single line exists in the raw Atlas", 1, rawAtlas.numberOfLines()); rawAtlas.lines().forEach(line -> Assert.assertTrue("The line is closed", line.isClosed())); Assert.assertEquals("The line was untouched", 1, slicedAtlas.numberOfLines()); slicedAtlas.lines() .forEach(line -> Assert.assertTrue("The line is still closed", line.isClosed())); Assert.assertEquals("The line should have an Guinea country code", "GIN", slicedAtlas.line(1).getTag(ISOCountryTag.KEY).get()); // Check Point correctness Assert.assertEquals("Four points exist in the raw Atlas", 4, rawAtlas.numberOfPoints()); Assert.assertEquals("The same 4 exist in the sliced Atlas", 4, slicedAtlas.numberOfPoints()); for (final Point point : slicedAtlas.points()) { Assert.assertEquals("Eeach point should have an Guinea country code", "GIN", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); } }
"CIV,LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals( "Expect the Point to have the synethetic boundary node tag value of existing", SyntheticBoundaryNodeTag.EXISTING.toString(), point.getTag(SyntheticBoundaryNodeTag.KEY).get()); point.getTag(ISOCountryTag.KEY).isPresent()); Assert.assertFalse( "None of the existing points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent());
Assert.assertEquals( "Expect the new Point on the border to contain both country codes", "CIV,LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals( "Expect the new Point to have the synethetic boundary node tag value of yes", SyntheticBoundaryNodeTag.YES.toString(), point.getTag(SyntheticBoundaryNodeTag.KEY).get()); point.getTag(ISOCountryTag.KEY).isPresent()); Assert.assertFalse( "None of the existing points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent());