/** * Finds out whether there is a road inconsistency or not. These roads correspond to same OSM * way, but they come from different sub atlases. If their shape is different in any way (start * location, end location, length etc), that implies a inconsistency. * * @param roads * Roads to check for consistency * @return Indicator whether given roads are consistent or not */ private boolean areRoadsConsistent(final List<TemporaryRoad> roads) { // Use first road as reference final PolyLine referencePolyLine = createPolyLineFromRoad(roads.get(0)); // Go through the roads and make sure their shape is same // Polyline equality check will go through location by location for (int i = 1; i < roads.size(); i++) { final PolyLine otherPolyLine = createPolyLineFromRoad(roads.get(i)); if (!referencePolyLine.equalsShape(otherPolyLine)) { return false; } } return true; }
@Test public void testAppend() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1); final PolyLine line2 = new PolyLine(Location.TEST_1, Location.TEST_7); final PolyLine appended = line.append(line2); Assert.assertTrue(appended.equalsShape( new PolyLine(Location.CROSSING_85_280, Location.TEST_1, Location.TEST_7))); }
@Test public void testPrepend() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1); final PolyLine line2 = new PolyLine(Location.TEST_7, Location.CROSSING_85_280); final PolyLine prepended = line.prepend(line2); Assert.assertTrue(prepended.equalsShape( new PolyLine(Location.TEST_7, Location.CROSSING_85_280, Location.TEST_1))); }
@Test public void testEqualsShape() { final PolyLine polyLine1 = PolyLine .wkt("LINESTRING (10.5553105 48.3419094, 10.5552096 48.3417501, 10.5551312 48.3416583, " + "10.5551027 48.341611, 10.5550183 48.3415143, 10.5549357 48.3414668, " + "10.5548325 48.3414164, 10.5548105 48.3415201, 10.5548015 48.3415686, " + "10.5548925 48.3416166, 10.5550334 48.3416375, 10.5551312 48.3416583)"); final PolyLine polyLine2 = PolyLine .wkt("LINESTRING (10.5551312 48.3416583, 10.5551027 48.341611, 10.5550183 48.3415143, " + "10.5549357 48.3414668, 10.5548325 48.3414164, 10.5548105 48.3415201, " + "10.5548015 48.3415686, 10.5548925 48.3416166, 10.5550334 48.3416375, " + "10.5551312 48.3416583, 10.5552096 48.3417501, 10.5553105 48.3419094)"); Assert.assertFalse(polyLine1.equals(polyLine2)); Assert.assertTrue(polyLine1.equalsShape(polyLine2)); }