コード例 #1
0
def test_path1():
    prepare_files()
    track = gpx_to_path(track_fn)
    track = [loc[:2] for loc in track]
    track = track[:5]
    track_int = interpolate_path(track, 5)
    map_con = create_map_from_xml(osm_fn)

    matcher = DistanceMatcher(map_con,
                              max_dist=50,
                              obs_noise=50,
                              min_prob_norm=0.1)
    states, last_idx = matcher.match(track_int)

    if directory:
        # matcher.print_lattice_stats()
        mm_viz.plot_map(map_con,
                        matcher=matcher,
                        use_osm=True,
                        zoom_path=True,
                        show_graph=True,
                        filename=str(directory / "test_path_latlon_path1.png"))
    assert len(states) == len(track_int), f"Path ({len(track_int)}) not fully matched by best path ({len(states)}), " + \
                                          f"last index = {last_idx}"
    states_sol = [(2963305939, 249348325), (2963305939, 249348325),
                  (2963305939, 249348325), (2963305939, 249348325),
                  (2963305939, 249348325), (2963305939, 249348325),
                  (249348325, 1545679243), (249348325, 1545679243),
                  (1545679243, 3663115134), (1545679243, 3663115134),
                  (1545679243, 3663115134), (3663115134, 1545679251),
                  (1545679251, 20910628), (1545679251, 20910628),
                  (1545679251, 20910628), (1545679251, 20910628),
                  (20910628, 3663115130)]
    assert states == states_sol, f"Got states: {states}"
コード例 #2
0
def test_path1_full():
    prepare_files()
    track = gpx_to_path(track_fn)
    track = [loc[:2] for loc in track]
    track_int = interpolate_path(track, 5)
    map_con = create_map_from_xml(osm_fn,
                                  include_footways=True,
                                  include_parking=True)

    matcher = DistanceMatcher(map_con,
                              max_dist=50,
                              obs_noise=50,
                              min_prob_norm=0.1)
    states, last_idx = matcher.match(track_int)

    if directory:
        # matcher.print_lattice_stats()
        mm_viz.plot_map(map_con,
                        matcher=matcher,
                        use_osm=True,
                        zoom_path=True,
                        show_graph=True,
                        filename=str(directory / "test_path_latlon_path1.png"))
    assert len(states) == len(track_int), f"Path ({len(track_int)}) not fully matched by best path ({len(states)}), " + \
                                          f"last index = {last_idx}"
コード例 #3
0
ファイル: pc_test.py プロジェクト: pc2005/LeuvenMapMatching
def map_matching_osm():
    track = gpx_to_path("mytrack.gpx")
    matcher = DistanceMatcher(
        map_con,
        max_dist=100,
        max_dist_init=25,  # meter
        min_prob_norm=0.001,
        non_emitting_length_factor=0.75,
        obs_noise=50,
        obs_noise_ne=75,  # meter
        dist_noise=50,  # meter
        non_emitting_states=True)
    states, lastidx = matcher.match(track)
    return
コード例 #4
0
def test_path2_proj():
    prepare_files()
    map_con_latlon = create_map_from_xml(osm2_fn)
    map_con = map_con_latlon.to_xy()
    track = [map_con.latlon2yx(p[0], p[1]) for p in gpx_to_path(track2_fn)]
    matcher = DistanceMatcher(map_con,
                              max_dist=300,
                              max_dist_init=25,
                              min_prob_norm=0.0001,
                              non_emitting_length_factor=0.95,
                              obs_noise=50,
                              obs_noise_ne=50,
                              dist_noise=50,
                              max_lattice_width=5,
                              non_emitting_states=True)
    states, last_idx = matcher.match(track, unique=False)
    nodes = matcher.path_pred_onlynodes
    if directory:
        matcher.print_lattice_stats()
        mm_viz.plot_map(map_con,
                        matcher=matcher,
                        path=track,
                        use_osm=False,
                        show_graph=True,
                        show_matching=True,
                        show_labels=5,
                        filename=str(directory /
                                     "test_path_latlon_path2_proj.png"))
    nodes_sol = [
        2634474831, 1096512242, 3051083902, 1096512239, 1096512241, 1096512240,
        1096508366, 1096508372, 16483861, 1096508360, 159656075, 1096508382,
        16483862, 3051083898, 16526535, 3060597381, 3060515059, 16526534,
        16526532, 1274158119, 16526540, 3060597377, 16526541, 16424220,
        1233373340, 613125597, 1076057753
    ]
    nodes_sol2 = [
        1096512242, 3051083902, 1096512239, 1096512241, 1096512240, 159654664,
        1096508373, 1096508381, 16483859, 1096508369, 159654663, 1096508363,
        16483862, 3051083898, 16526535, 3060597381, 3060515059, 16526534,
        16526532, 611867918, 3060725817, 16483866, 3060725817, 611867918,
        16526532, 1274158119, 16526540, 3060597377, 16526541, 16424220,
        1233373340, 613125597, 1076057753
    ]
    assert (nodes
            == nodes_sol) or (nodes
                              == nodes_sol2), f"Nodes do not match: {nodes}"
コード例 #5
0
def test_path2():
    prepare_files()
    map_con = create_map(osm2_fn)
    track = [(p[0], p[1]) for p in gpx_to_path(track2_fn)]
    matcher = DistanceMatcher(map_con, max_dist=300, max_dist_init=25, min_prob_norm=0.0001,
                              non_emitting_length_factor=0.75,
                              obs_noise=50, obs_noise_ne=75,
                              dist_noise=30,
                              max_lattice_width=5,
                              non_emitting_states=True)
    states, last_idx = matcher.match(track, unique=False)
    nodes = matcher.path_pred_onlynodes
    if directory:
        mm_viz.plot_map(map_con, matcher=matcher, nodes=nodes, path=track, z=17, use_osm=True,
                        show_graph=True, show_matching=True,
                        filename=str(directory / "test_path_latlon_path2.png"))
    nodes_sol = [2634474831, 1096512242, 3051083902, 1096512239, 1096512241, 1096512240, 1096508366, 1096508372,
                 16483861, 3051083900, 16483864, 16483865, 3060515058, 16526534, 16526532, 1274158119, 16526540,
                 3060597377, 16526541, 16424220, 1233373340, 613125597, 1076057753]

    assert nodes == nodes_sol, f"Nodes do not match: {nodes}"