def test_remove_offsets_raises(self): "Remove too big offsets" node0 = DummyNode(Coordinates(13.128987, 52.494595)) node1 = DummyNode(extrapolate(node0.coord, 10, 180.0)) line = DummyLine(0, node0, node1) route = Route(PointOnLine(line, 0.0), [], PointOnLine(line, 1.0)) with self.assertRaises(LRDecodeError): remove_offsets(route, 11, 0) with self.assertRaises(LRDecodeError): remove_offsets(route, 0, 11)
def test_bearingscore_5(self): "Test perfect/worst possible bearing" node1 = DummyNode(Coordinates(1.0, 0.0)) node2 = DummyNode(Coordinates(0.0, 0.0)) wanted_bearing = degrees(bearing(node1.coordinates, node2.coordinates)) wanted = LocationReferencePoint(13.416, 52.525, FRC.FRC2, FOW.SINGLE_CARRIAGEWAY, wanted_bearing, None, None) line = DummyLine(1, node1, node2) score = score_bearing(wanted, PointOnLine(line, 0.0), False, self.config.bear_dist) self.assertAlmostEqual(score, 1.0) score = score_bearing(wanted, PointOnLine(line, 1.0), True, self.config.bear_dist) self.assertAlmostEqual(score, 0.0)
def test_remove_offsets(self): "Remove offsets containing lines" node0 = DummyNode(Coordinates(13.128987, 52.494595)) node1 = DummyNode(extrapolate(node0.coord, 20, 180.0)) node2 = DummyNode(extrapolate(node1.coord, 90, 90.0)) node3 = DummyNode(extrapolate(node2.coord, 20, 180.0)) lines = [ DummyLine(0, node0, node1), DummyLine(1, node1, node2), DummyLine(2, node2, node3) ] route = Route(PointOnLine(lines[0], 0.5), [lines[1]], PointOnLine(lines[2], 0.5)) route = remove_offsets(route, 40, 40) self.assertListEqual(route.lines, [lines[1]]) self.assertAlmostEqual(route.length(), 30, delta=1)
def test_geoscore_0(self): "Test scoring a non-matching LRP candidate line" lrp = LocationReferencePoint(0.0, 0.0, None, None, None, None, None) node1 = DummyNode(Coordinates(0.0, 0.0)) node2 = DummyNode(Coordinates(0.0, 90.0)) pal = PointOnLine(DummyLine(None, node1, node2), 1.0) score = score_geolocation(lrp, pal, 1.0) self.assertEqual(score, 0.0)
def test_bearingscore_4(self): "Test bearing difference of -90°" node1 = DummyNode(Coordinates(0.0, 0.0)) node2 = DummyNode(Coordinates(0.0, 90.0)) node3 = DummyNode(Coordinates(-1.0, 0.0)) wanted_bearing = degrees(bearing(node1.coordinates, node2.coordinates)) wanted = LocationReferencePoint(13.416, 52.525, FRC.FRC2, FOW.SINGLE_CARRIAGEWAY, wanted_bearing, None, None) line = DummyLine(1, node1, node3) score = score_bearing(wanted, PointOnLine(line, 1.0), True, self.config.bear_dist) self.assertAlmostEqual(score, 0.5)