wannesm / LeuvenMapMatching

Leuven.MapMatching toolbox for aligning GPS measurements to locations on a map.
Other
222 stars 43 forks source link

node_path is an empty list with non-zero speed #25

Closed creatorLEI closed 2 years ago

creatorLEI commented 2 years ago

image

image

I want to find the corresponding way id of my GPS points, by the way, my GPS data has non-zero speed. But when I debug the "BaseMatcher", as shown in the first picture, I find "states" is an empty list. However, the matching picture is fine as shown in the second picture. I don't know why the list is empty. Is there anyone kindful to help me?

wannesm commented 2 years ago

I assume it didn't match any states, the lastidx is also 0 (which is the last location that is matched). This is probably because you are using BaseMatcher which is an empty matcher. You can try SimpleMatcher or DistanceMatcher.

creatorLEI commented 2 years ago

What is the difference between these three "matchers"?

wannesm commented 2 years ago
creatorLEI commented 2 years ago

Thank you very much! And I find that the value of "max_dist" in "BaseMatcher" is larger, runing time is longer. But with the larger value, it can match more observation. However, when the value is up to 1000, it will cost so much time that not once in the many times I have run I could wait it finish. So can you recommend me a proper value?

wannesm commented 2 years ago

In version 1.0, the max_lattice_width option was added for this reason. See also the docs on https://leuvenmapmatching.readthedocs.io/en/latest/usage/introduction.html . This allows you to have larger values for max_dist etc, thus allow more deviation, while keeping the runtime limited. In our applications, we run the matcher with a value of 10 or smaller.

creatorLEI commented 2 years ago

Thanks a lot! And I have another question. Now I matched GPS observation on my map, but I don't know which state segment the GPS point exactly in and how long is a state segment(along the road, not the straight-line distance) . Help me please, thanks!

wannesm commented 2 years ago

I'm not sure what you are asking for exactly, but all information about the matching can be found in matcher.lattice_best. Each entry in that list is a Matching object which in turn has all information about each match. Concretely, a edge_o.pi and edge_m.pi attribute that tells you which observation location links to which map location.

creatorLEI commented 2 years ago

Thank you very much! Concretely, how can I write the code which can call "edge_o.pi" and "edge_m.pi"? And how can I obtain the distance of each road segment in each entry of "matcher.lattice_best" list? such as the distance between "5018470949" and "5018470948" in row[0] as shown in picture. image

wannesm commented 2 years ago

These are entries of type BaseMatching. So getting the interpolated position of, for example the first entry, is matcher.lattice_best[0].edge_m.pi.

The distance between two nodes such as 5018470949 and 5018470948 is not included in the matching. This can be directly computed from your map/database using any library that supports coordinates / haversine (or the relevant functions in util.dist_latlon).

creatorLEI commented 2 years ago

Thanks! You help me a lot!

creatorLEI commented 2 years ago

And if I want to obtain the distance along the road, not the straight line distance, between two nodes, is there any function in matching to realize it?

wannesm commented 2 years ago

There wasn't but it's quite easy so I added one in commit dfdaf6a. You can call matcher.path_pred_distance(). It will only be part of the next release, so if you want to use it immediately you'll have to install from the github master branch (see https://leuvenmapmatching.readthedocs.io/en/latest/usage/installation.html).

creatorLEI commented 2 years ago

OK,thanks! And what is ".edge_m.pi"? I compared it with matching points and observation points, but they are all different. And another question is that if "m_prev.edge_m.label == m.edge_m.label", in other words, if I have more than one observation points in the same matching segment, what are "m_prev.edge_m.pi" and "m.edge_m.pi"?

wannesm commented 2 years ago

This is now documented in https://leuvenmapmatching.readthedocs.io/en/latest/classes/matcher/BaseMatching.html and https://leuvenmapmatching.readthedocs.io/en/latest/classes/util/Segment.html and