Ejemplo n.º 1
0
def get_test_linelocation_2():
    "Return a undecodable line location with 2 LRPs"
    # References node 0 / line 1 / lines 1, 3
    lrp1 = LocationReferencePoint(13.41, 52.525, FRC.FRC0,
                                  FOW.SINGLE_CARRIAGEWAY, 90.0, FRC.FRC2, 0.0)
    # References node 13 / ~ line 17
    lrp2 = LocationReferencePoint(13.429, 52.523, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 270.0, None, None)
    return LineLocationReference([lrp1, lrp2], 0.0, 0.0)
Ejemplo n.º 2
0
def get_test_linelocation_3():
    """Returns a line location that is within a line.
    
    This simulates that the start and end junction are missing on the target map."""
    # References a point on line 1
    lrp1 = LocationReferencePoint(13.411, 52.525, FRC.FRC1,
                                  FOW.SINGLE_CARRIAGEWAY, 90.0, FRC.FRC1, 135)
    # References another point on line 1
    lrp2 = LocationReferencePoint(13.413, 52.525, FRC.FRC1,
                                  FOW.SINGLE_CARRIAGEWAY, -90.0, None, None)
    return LineLocationReference([lrp1, lrp2], 0.0, 0.0)
Ejemplo n.º 3
0
def get_test_linelocation_1():
    "Return a prepared line location with 3 LRPs"
    # References node 0 / line 1 / lines 1, 3
    lrp1 = LocationReferencePoint(13.41, 52.525, FRC.FRC0,
                                  FOW.SINGLE_CARRIAGEWAY, 90.0, FRC.FRC2,
                                  717.8)
    # References node 3 / line 4
    lrp2 = LocationReferencePoint(13.4145, 52.529, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 170, FRC.FRC2, 456.6)
    # References node 4 / line 4
    lrp3 = LocationReferencePoint(13.416, 52.525, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 320.0, None, None)
    return LineLocationReference([lrp1, lrp2, lrp3], 0.0, 0.0)
Ejemplo n.º 4
0
def get_test_linelocation_4() -> LineLocationReference:
    "Test backtracking with a location that tries the decoder to get lost"
    # Seems to reference line 19 -> Decoder gets lost
    lrp1 = LocationReferencePoint(13.41, 52.5245, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 120.0, FRC.FRC2, 424)
    # Matches still roughly line 19
    lrp2 = LocationReferencePoint(13.4125, 52.521, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 130.0, FRC.FRC2,
                                  1313)
    # Matches only line 20 -> Decoding fails and backtracking resolves LRPs 1 and 2 to line 20
    lrp3 = LocationReferencePoint(13.429, 52.523, FRC.FRC2,
                                  FOW.SINGLE_CARRIAGEWAY, 230.0, None, None)
    return LineLocationReference([lrp1, lrp2, lrp3], 0.0, 0.0)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 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)