bmwcarit / barefoot

Java map matching library for integrating the map into software and services with state-of-the-art online and offline map matching that can be used stand-alone and in the cloud.
Apache License 2.0
665 stars 186 forks source link

Strange routing behaviour #105

Closed GeoWonk closed 6 years ago

GeoWonk commented 6 years ago

Hi I am using your wonderful package to use GPS traces to derive information about the road network by modifying the output to return the gids of the roads matched to, and those on the imputed routes between matched points. I have previously posted under the username GeoCrunch.

I have noticed a particular problem where vehicles are incorrectly (well, highly implausibly) being routed off a freeway on to a side road, and then back on to the freeway for the next point (so points are matched correctly despite the incorrect route). The relevant segment is here. For vehicles travelling either East or West along the Monash highway where there are no GPS pings between Warrigal Road and Huntingdale Road, barefoot imputes a route that travels by the surface road Waverly Road.

This doesn't seem to be an OSM map error. The roads are connected properly and the trip routing in the OSM web display routes along the Freeway, as would be expected. This also happens systematically on this section of road (~100 examples).

I know my usage is unusual (and I also have an unusually low frequency of pings (~ every 60 seconds) and the intended behaviour of barefoot is still correct (points are still matched to the correct road) but whatever is causing this might cause problems elsewhere.

Here's a representative example (I've truncated the trace because the data is confidential but this replicates the result). If I pass this to barefoot via the batch python script on a bfmap constructed from an April 16 barefoot download, the output returns gids which I match to the following list of osm_ids.

[{"point":"POINT(145.14432 -37.89485)","time":1453443247000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.10837 -37.88668)","time":1453443370000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.06803 -37.87597)","time":1453443509000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05938 -37.86023)","time":1453443580000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05922 -37.85968)","time":1453443583000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.0586 -37.85747)","time":1453443608000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05855 -37.85725)","time":1453443629000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05847 -37.85697)","time":1453443643000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05792 -37.85575)","time":1453443695000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05783 -37.85562)","time":1453443698000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05763 -37.85533)","time":1453443705000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.0574 -37.855)","time":1453443714000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05722 -37.85475)","time":1453443720000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.0571 -37.85463)","time":1453443723000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.057 -37.8545)","time":1453443726000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05682 -37.85432)","time":1453443731000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05637 -37.85397)","time":1453443749000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05418 -37.85268)","time":1453443869000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"},{"point":"POINT(145.05173 -37.8518)","time":1453443989000,"id":"6389eb89d31c00c3dee84b1529f6ce7b8fccda695da6017d734964f80019b6a6_56a1bbdb"}]

List of osm ids "480536447, 480536446, 480536446, 480536446, 480536446, 11339489, 480535756, 153277918, 480534947, 29478440, 404804624, 404804624, 29478465, 29478479, 29478442, 29478434, 29478468, 29478427, 29478436, 29478436, 29478441, 29478465, 29478479, 29478442, 29478434, 29478434, 29478434, 168809671, 168809671, 168809671, 168809671, 168809671, 168809671, 168809689, 168809689, 168809689, 168809689, 168809689, 124466340, 124466340, 124466340, 124466340, 124466340, 124466340, 124466340, 124466340, 124466340, 124466340, 419161666, 419161666, 419161666, 29479367, 29479367, 29479367, 578606456, 29479394, 29479394, 70193905, 480534363, 480534363, 480534363, 480534363, 480534363, 203031632, 203031632, 310454026, 29479321, 29479321, 70528656, 152759145, 4535345, 152759000, 152759000, 485230549, 485230556, 83250635, 83250635, 357016933, 357016933, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 53788186, 25448446, 25448643, 25448643" "

Everything between 153277918 and 70528656 is erroneous.

If necessary, the actual JSON output with barefoot gids for the particular map I created is as follows. My matcher.radius.max is currently set to 50, and matcher.sigma to 5.

[{"road":4230072, "time":1453443247, "geom":"POINT (145.14429968490194 -37.89488406290779)", "frac":0.08893471005181323}, {"road":866006, "length":3526.845663096745, "roads":[{"id":4230072, "geom":"LINESTRING (145.1443652 -37.8949086, 145.14402130000002 -37.8947798, 145.143622 -37.8946442)"}, {"id":4230064, "geom":"LINESTRING (145.143622 -37.8946442, 145.1433009 -37.8945382, 145.14296810000002 -37.8944448, 145.142711 -37.8943789, 145.1423727 -37.8942987, 145.142036 -37.8942333, 145.1416634 -37.8941645, 145.1413475 -37.894116, 145.14089620000001 -37.8940642, 145.1402705 -37.8939897, 145.1376817 -37.8937094)"}, {"id":4230066, "geom":"LINESTRING (145.1376817 -37.8937094, 145.1372685 -37.8936647)"}, {"id":4230068, "geom":"LINESTRING (145.1372685 -37.8936647, 145.1361378 -37.8935407)"}, {"id":4230070, "geom":"LINESTRING (145.1361378 -37.8935407, 145.13513930000002 -37.8934282, 145.1307319 -37.8929716)"}, {"id":204602, "geom":"LINESTRING (145.1307319 -37.8929716, 145.1301023 -37.8928974)"}, {"id":4230016, "geom":"LINESTRING (145.1301023 -37.8928974, 145.1268879 -37.8925365, 145.1244633 -37.8922871)"}, {"id":2251404, "geom":"LINESTRING (145.1244633 -37.8922871, 145.12341750000002 -37.8921721, 145.1225594 -37.8920714, 145.1219111 -37.8919881, 145.12055790000002 -37.8917364, 145.1193402 -37.8914062, 145.1181814 -37.8909955, 145.1174465 -37.890678, 145.1169637 -37.8904494, 145.11575670000002 -37.889789)"}, {"id":4229988, "geom":"LINESTRING (145.11575670000002 -37.889789, 145.1151452 -37.8894376, 145.1142708 -37.8889126, 145.113552 -37.8885231, 145.1126015 -37.8880619)"}, {"id":866008, "geom":"LINESTRING (145.1126015 -37.8880619, 145.11182050000002 -37.8878181, 145.11121110000002 -37.8876352, 145.11035280000002 -37.8874116, 145.11000710000002 -37.8873317)"}, {"id":4043592, "geom":"LINESTRING (145.11000710000002 -37.8873317, 145.1095031 -37.8872152, 145.1086448 -37.8870662)"}, {"id":4043594, "geom":"LINESTRING (145.1086448 -37.8870662, 145.1083523 -37.8870179, 145.1082757 -37.8870052)"}, {"id":866022, "geom":"LINESTRING (145.1082757 -37.8870052, 145.1081972 -37.886975, 145.1081432 -37.8869353)"}, {"id":866030, "geom":"LINESTRING (145.1081432 -37.8869353, 145.1081521 -37.8869031)"}, {"id":866016, "geom":"LINESTRING (145.1081521 -37.8869031, 145.1082671 -37.8863752)"}, {"id":866000, "geom":"LINESTRING (145.1082671 -37.8863752, 145.1083149 -37.8861331, 145.1083288 -37.8860628)"}, {"id":866024, "geom":"LINESTRING (145.1083288 -37.8860628, 145.1084559 -37.8860772)"}, {"id":865998, "geom":"LINESTRING (145.1084559 -37.8860772, 145.108413 -37.8863955)"}, {"id":866006, "geom":"LINESTRING (145.108413 -37.8863955, 145.10829420000002 -37.8869229)"}], "time":1453443370, "frac":0.5339568438712179}, {"road":2248728, "length":4728.486524154065, "roads":[{"id":866006, "geom":"LINESTRING (145.108413 -37.8863955, 145.10829420000002 -37.8869229)"}, {"id":866010, "geom":"LINESTRING (145.10829420000002 -37.8869229, 145.1082757 -37.8870052)"}, {"id":866022, "geom":"LINESTRING (145.1082757 -37.8870052, 145.1081972 -37.886975, 145.1081432 -37.8869353)"}, {"id":866030, "geom":"LINESTRING (145.1081432 -37.8869353, 145.1081521 -37.8869031)"}, {"id":866016, "geom":"LINESTRING (145.1081521 -37.8869031, 145.1082671 -37.8863752)"}, {"id":866000, "geom":"LINESTRING (145.1082671 -37.8863752, 145.1083149 -37.8861331, 145.1083288 -37.8860628)"}, {"id":866002, "geom":"LINESTRING (145.1083288 -37.8860628, 145.1083443 -37.8859698)"}, {"id":866004, "geom":"LINESTRING (145.1083443 -37.8859698, 145.1084044 -37.8856097, 145.1084764 -37.8852593)"}, {"id":2375743, "geom":"LINESTRING (145.1084764 -37.8852593, 145.1085414 -37.8849186)"}, {"id":2375741, "geom":"LINESTRING (145.1085414 -37.8849186, 145.1085769 -37.8847323)"}, {"id":2375739, "geom":"LINESTRING (145.1085769 -37.8847323, 145.1086883 -37.8841206)"}, {"id":2375737, "geom":"LINESTRING (145.1086883 -37.8841206, 145.10885140000002 -37.8832919)"}, {"id":2375735, "geom":"LINESTRING (145.10885140000002 -37.8832919, 145.1089387 -37.8828337)"}, {"id":2375733, "geom":"LINESTRING (145.1089387 -37.8828337, 145.10899980000002 -37.882513)"}, {"id":2375927, "geom":"LINESTRING (145.10899980000002 -37.882513, 145.10857710000002 -37.8824637)"}, {"id":2375925, "geom":"LINESTRING (145.10857710000002 -37.8824637, 145.1063714 -37.8822062)"}, {"id":2375923, "geom":"LINESTRING (145.1063714 -37.8822062, 145.1061559 -37.882181, 145.10589710000002 -37.8821508)"}, {"id":2375921, "geom":"LINESTRING (145.10589710000002 -37.8821508, 145.10486450000002 -37.8820302)"}, {"id":2375919, "geom":"LINESTRING (145.10486450000002 -37.8820302, 145.1043022 -37.8819646)"}, {"id":2051727, "geom":"LINESTRING (145.1043022 -37.8819646, 145.1038112 -37.8819074)"}, {"id":2051725, "geom":"LINESTRING (145.1038112 -37.8819074, 145.10262020000002 -37.8817685)"}, {"id":2051723, "geom":"LINESTRING (145.10262020000002 -37.8817685, 145.1018635 -37.8816803)"}, {"id":2051721, "geom":"LINESTRING (145.1018635 -37.8816803, 145.1014706 -37.8816345)"}, {"id":2051719, "geom":"LINESTRING (145.1014706 -37.8816345, 145.10110690000002 -37.8815921, 145.1004206 -37.8815121)"}, {"id":2051717, "geom":"LINESTRING (145.1004206 -37.8815121, 145.09917850000002 -37.8813673)"}, {"id":2051715, "geom":"LINESTRING (145.09917850000002 -37.8813673, 145.09889420000002 -37.8813342)"}, {"id":2051713, "geom":"LINESTRING (145.09889420000002 -37.8813342, 145.09785060000002 -37.8812125)"}, {"id":2051711, "geom":"LINESTRING (145.09785060000002 -37.8812125, 145.0959994 -37.8809967)"}, {"id":2051709, "geom":"LINESTRING (145.0959994 -37.8809967, 145.0958318 -37.8809772)"}, {"id":4073713, "geom":"LINESTRING (145.0958318 -37.8809772, 145.0947683 -37.8808544)"}, {"id":4073711, "geom":"LINESTRING (145.0947683 -37.8808544, 145.0945739 -37.8808322)"}, {"id":4073709, "geom":"LINESTRING (145.0945739 -37.8808322, 145.09309470000002 -37.8806671)"}, {"id":866225, "geom":"LINESTRING (145.09309470000002 -37.8806671, 145.09299810000002 -37.8806564)"}, {"id":866223, "geom":"LINESTRING (145.09299810000002 -37.8806564, 145.0929199 -37.8806477)"}, {"id":866221, "geom":"LINESTRING (145.0929199 -37.8806477, 145.092477 -37.8805987)"}, {"id":4559813, "geom":"LINESTRING (145.092477 -37.8805987, 145.0921214 -37.8805558)"}, {"id":866226, "geom":"LINESTRING (145.0921214 -37.8805558, 145.0917685 -37.8805365, 145.09148240000002 -37.8805089, 145.09128750000002 -37.8804799)"}, {"id":866228, "geom":"LINESTRING (145.09128750000002 -37.8804799, 145.091232 -37.8804642)"}, {"id":1701702, "geom":"LINESTRING (145.091232 -37.8804642, 145.0909933 -37.8804812, 145.0909291 -37.8805019, 145.0908834 -37.8805166, 145.0907936 -37.8805885)"}, {"id":4229968, "geom":"LINESTRING (145.0907936 -37.8805885, 145.09077910000002 -37.8806621)"}, {"id":4229970, "geom":"LINESTRING (145.09077910000002 -37.8806621, 145.09074280000002 -37.8808791)"}, {"id":4229972, "geom":"LINESTRING (145.09074280000002 -37.8808791, 145.0906768 -37.8812535)"}, {"id":4229974, "geom":"LINESTRING (145.0906768 -37.8812535, 145.0905884 -37.8817746)"}, {"id":4229976, "geom":"LINESTRING (145.0905884 -37.8817746, 145.09056280000001 -37.8818933)"}, {"id":3113874, "geom":"LINESTRING (145.09056280000001 -37.8818933, 145.0904647 -37.8823471, 145.09044 -37.8824612)"}, {"id":3113876, "geom":"LINESTRING (145.09044 -37.8824612, 145.09024780000001 -37.8832732, 145.090208 -37.8834413)"}, {"id":3689210, "geom":"LINESTRING (145.090208 -37.8834413, 145.0900148 -37.8833111)"}, {"id":866210, "geom":"LINESTRING (145.0900148 -37.8833111, 145.0897191 -37.8831033)"}, {"id":866212, "geom":"LINESTRING (145.0897191 -37.8831033, 145.08947020000002 -37.8829204, 145.08920410000002 -37.8826968, 145.088938 -37.882453, 145.0885962 -37.8821437)"}, {"id":1704976, "geom":"LINESTRING (145.0885962 -37.8821437, 145.0884044 -37.8819723, 145.08807720000001 -37.8817034, 145.0877111 -37.8814187, 145.087239 -37.8810736, 145.0866301 -37.8806216)"}, {"id":2248730, "geom":"LINESTRING (145.0866301 -37.8806216, 145.08544980000002 -37.8799138, 145.0844037 -37.8793041, 145.0836468 -37.8789012, 145.0823915 -37.8782534, 145.08190810000002 -37.8779975)"}, {"id":18822, "geom":"LINESTRING (145.08190810000002 -37.8779975, 145.0813824 -37.8777339)"}, {"id":2248728, "geom":"LINESTRING (145.0813824 -37.8777339, 145.0809812 -37.8775384, 145.0803799 -37.8772922, 145.07975760000002 -37.8770932, 145.07892130000002 -37.876916, 145.0780839 -37.8768434, 145.0767374 -37.8768899, 145.0752091 -37.8770345, 145.07233910000002 -37.8772293, 145.0716251 -37.877199, 145.0711262 -37.8771482, 145.0702417 -37.8769541, 145.0692809 -37.8766359, 145.0685191 -37.8762971, 145.0680524 -37.8760219, 145.06732340000002 -37.8754805, 145.0666952 -37.8748532, 145.0660891 -37.8740402, 145.0656384 -37.8731255, 145.06526350000001 -37.8722115, 145.06489870000001 -37.871335, 145.0645178 -37.8705727, 145.06406130000002 -37.8698352, 145.0637239 -37.8693658, 145.062393 -37.8678873)"}], "time":1453443509, "frac":0.5424293036142334}, {"road":1779296, "length":1937.4117237405517, "roads":[{"id":2248728, "geom":"LINESTRING (145.0813824 -37.8777339, 145.0809812 -37.8775384, 145.0803799 -37.8772922, 145.07975760000002 -37.8770932, 145.07892130000002 -37.876916, 145.0780839 -37.8768434, 145.0767374 -37.8768899, 145.0752091 -37.8770345, 145.07233910000002 -37.8772293, 145.0716251 -37.877199, 145.0711262 -37.8771482, 145.0702417 -37.8769541, 145.0692809 -37.8766359, 145.0685191 -37.8762971, 145.0680524 -37.8760219, 145.06732340000002 -37.8754805, 145.0666952 -37.8748532, 145.0660891 -37.8740402, 145.0656384 -37.8731255, 145.06526350000001 -37.8722115, 145.06489870000001 -37.871335, 145.0645178 -37.8705727, 145.06406130000002 -37.8698352, 145.0637239 -37.8693658, 145.062393 -37.8678873)"}, {"id":4243448, "geom":"LINESTRING (145.062393 -37.8678873, 145.06173370000002 -37.8671637)"}, {"id":4243450, "geom":"LINESTRING (145.06173370000002 -37.8671637, 145.06123960000002 -37.8664389, 145.06102560000002 -37.865978, 145.0608158 -37.8653717, 145.0605985 -37.864632)"}, {"id":1779296, "geom":"LINESTRING (145.0605985 -37.864632, 145.0593203 -37.8602185)"}], "time":1453443580, "frac":0.9951858646045249}, {"road":3874326, "length":62.618972011833364, "roads":[{"id":1779296, "geom":"LINESTRING (145.0605985 -37.864632, 145.0593203 -37.8602185)"}, {"id":3874326, "geom":"LINESTRING (145.0593203 -37.8602185, 145.0592311 -37.8599185, 145.0586451 -37.8579501)"}], "time":1453443583, "frac":0.2327042494093401}, {"road":1560294, "length":251.33559402786392, "roads":[{"id":3874326, "geom":"LINESTRING (145.0593203 -37.8602185, 145.0592311 -37.8599185, 145.0586451 -37.8579501)"}, {"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443608, "frac":0.1535377585813958}, {"road":1560294, "length":24.763398190880196, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443629, "frac":0.22549243879789305}, {"road":1560294, "length":31.237338964047893, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443643, "frac":0.31625836351658393}, {"road":1560294, "length":142.75530727463587, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443695, "frac":0.731060581086915}, {"road":1560294, "length":16.033779994671107, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443698, "frac":0.7776497245996625}, {"road":1560294, "length":36.362508089448845, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}], "time":1453443705, "frac":0.8833077857945784}, {"road":1560296, "length":41.32423678343778, "roads":[{"id":1560294, "geom":"LINESTRING (145.0586451 -37.8579501, 145.0584962 -37.8574313, 145.0583769 -37.8570204, 145.05821590000002 -37.8565979, 145.05808720000002 -37.8563025, 145.05793970000002 -37.856005, 145.0577854 -37.8557286, 145.057658 -37.8555242, 145.057485 -37.8552712, 145.0573268 -37.8550488)"}, {"id":1560296, "geom":"LINESTRING (145.0573268 -37.8550488, 145.05699230000002 -37.8546261, 145.0567407 -37.8543902)"}], "time":1453443714, "frac":0.01298301539805848}, {"road":1560296, "length":31.924022614167725, "roads":[{"id":1560296, "geom":"LINESTRING (145.0573268 -37.8550488, 145.05699230000002 -37.8546261, 145.0567407 -37.8543902)"}], "time":1453443720, "frac":0.36896673542910674}, {"road":1560296, "length":16.89513812030738, "roads":[{"id":1560296, "geom":"LINESTRING (145.0573268 -37.8550488, 145.05699230000002 -37.8546261, 145.0567407 -37.8543902)"}], "time":1453443723, "frac":0.5573638616683368}, {"road":1560296, "length":15.653814019707092, "roads":[{"id":1560296, "geom":"LINESTRING (145.0573268 -37.8550488, 145.05699230000002 -37.8546261, 145.0567407 -37.8543902)"}], "time":1453443726, "frac":0.7319190239283855}, {"road":1560298, "length":25.805222889513544, "roads":[{"id":1560296, "geom":"LINESTRING (145.0573268 -37.8550488, 145.05699230000002 -37.8546261, 145.0567407 -37.8543902)"}, {"id":1560298, "geom":"LINESTRING (145.0567407 -37.8543902, 145.056553 -37.8542027, 145.0563813 -37.8540471, 145.0562137 -37.853902)"}], "time":1453443731, "frac":0.02472315563877533}, {"road":1560298, "length":54.736521311156885, "roads":[{"id":1560298, "geom":"LINESTRING (145.0567407 -37.8543902, 145.056553 -37.8542027, 145.0563813 -37.8540471, 145.0562137 -37.853902)"}], "time":1453443749, "frac":0.7918027977453752}, {"road":603688, "length":239.555303262067, "roads":[{"id":1560298, "geom":"LINESTRING (145.0567407 -37.8543902, 145.056553 -37.8542027, 145.0563813 -37.8540471, 145.0562137 -37.853902)"}, {"id":603582, "geom":"LINESTRING (145.0562137 -37.853902, 145.0561064 -37.8538141)"}, {"id":603688, "geom":"LINESTRING (145.0561064 -37.8538141, 145.0558279 -37.853603, 145.05552210000002 -37.8533997, 145.0551976 -37.8532112, 145.0549173 -37.853064, 145.0546303 -37.8529263, 145.05430570000001 -37.8527908, 145.0539718 -37.8526637, 145.0536472 -37.8525515, 145.053257 -37.8524255, 145.05291770000002 -37.8523143, 145.05242280000002 -37.8521438, 145.0521626 -37.8520432, 145.0519011 -37.8519383, 145.0516691 -37.8518335, 145.0514532 -37.8517297, 145.05116890000002 -37.8515804, 145.050839 -37.8513866, 145.05055330000002 -37.8512087, 145.0502605 -37.8510122, 145.0500231 -37.8508481, 145.04962880000002 -37.8505727, 145.04930960000002 -37.8503503, 145.049091 -37.8502053, 145.04888590000002 -37.8500761, 145.0486552 -37.8499405, 145.0484513 -37.8498315, 145.04827160000002 -37.8497372, 145.0480101 -37.8496112, 145.0477338 -37.8494862, 145.04746830000002 -37.8493761, 145.0472645 -37.8492977)"}], "time":1453443869, "frac":0.2265379971693358}, {"road":603688, "length":237.29641524119842, "roads":[{"id":603688, "geom":"LINESTRING (145.0561064 -37.8538141, 145.0558279 -37.853603, 145.05552210000002 -37.8533997, 145.0551976 -37.8532112, 145.0549173 -37.853064, 145.0546303 -37.8529263, 145.05430570000001 -37.8527908, 145.0539718 -37.8526637, 145.0536472 -37.8525515, 145.053257 -37.8524255, 145.05291770000002 -37.8523143, 145.05242280000002 -37.8521438, 145.0521626 -37.8520432, 145.0519011 -37.8519383, 145.0516691 -37.8518335, 145.0514532 -37.8517297, 145.05116890000002 -37.8515804, 145.050839 -37.8513866, 145.05055330000002 -37.8512087, 145.0502605 -37.8510122, 145.0500231 -37.8508481, 145.04962880000002 -37.8505727, 145.04930960000002 -37.8503503, 145.049091 -37.8502053, 145.04888590000002 -37.8500761, 145.0486552 -37.8499405, 145.0484513 -37.8498315, 145.04827160000002 -37.8497372, 145.0480101 -37.8496112, 145.0477338 -37.8494862, 145.04746830000002 -37.8493761, 145.0472645 -37.8492977)"}], "time":1453443989, "frac":0.48116272547906463}]

jongiddy commented 6 years ago

Do you know the date of the OSM map download? e.g. which URL, and when it was downloaded (and perhaps the size of the downloaded file, as a check).

As you seem to be confident looking at the road database, are there max speed limits in the data for the freeway and the returned roads, and do they look to be correct?

GeoWonk commented 6 years ago

The OSM download (that I used for testing this example data before making this post) was downloaded at 16:24 April 16 (Australian Eastern Standard Time) from this url and is 356 MB on disk (my data covers the entire continent).

The motorway has a maxspeed of 100 kph in the OSM data (which I think is correct). Most of the incorrectly returned roads lack speed limits (except for one which is 60 kph) and are labeled "secondary road".

smattheis commented 6 years ago

Sorry for getting back to you so late. I've checked the matcher with your data. It seems that a default of matcher.sigma=4.5 in the config/server.properties is not optimal (which I will change in a future release). For your case, try with a greater value such as matcher.sigma=8. That solves it for the sample data that you provided.

GeoWonk commented 6 years ago

Hi

Thank you for your response. Fortunately I have also just done a run on my entire data set with a very high matcher.sigma=15, because I had other matching issues on freeways which are in deep sandstone cuttings with parallel secondary roads. This is a natural place to expect more GPS error since it mimics the same problem in dense urban areas. The higher sigma has definitely reduced the mismatching/misrouting, but has not eliminated it or made it immaterial (also the free way in the example I have is not in a cutting but that's a mystery). On the other hand I haven't (yet) noticed any bad effects elsewhere from the high sigma.

My data covers the whole continent of Australia and the data varies by source. I may have to investigate using different server.properties by firm and area or fiddling with road-types.json a little more. Alternatively, since the number of egregious errors is fairly low I might make special cases of them, for instance maintaining a file of troublesome segments and changing their priority in bfmap.segment() which I have already edited to remove no access roads that were being matched to. I would change the priority rather than eliminate them because some of the roads are clearly being used in some cases.

Anyway, given the problem seems to be a matter of fiddling with parameters rather than an underlying problem with the code I'm happy for you to close the issue, although I'm also happy to provide examples that continue to be misrouted if you want to investigate them for your own purposes. Thanks again!

GeoWonk commented 6 years ago

I'm adding a further note for anyone else looking at this because they're having similar problems, particularly with data of mixed provenance. Further investigation revealed that the errors (not just at this road but others) were overwhelmingly related to just some of the sources. Furthermore the pings that were mismatched onto offramps and sideroads were slap bang on the incorrect segment even though I could tell by looking at later pings they had stayed on the motorway. From this I assume that those particular sources had already had a map match correction applied to them using nearest neighbour matching. That is, the natural GPS error had been magnified by an inferior matching technique before it had come to me. Which isn't fun for me given how long I spent digging into this, but hopefully I'll save someone else some grief.

smattheis commented 6 years ago

Am I correct that you mean the raw GPS data isn't raw but map matched onto wrong roads which increases the GPS error? That is true and sorry that I haven't addressed this issue before. It is mostly the case for GPS traces recorded with, e.g., Android devices which don't provide raw GPS data (even if you write your own tracing app) but snap or map match positions onto roads of the Google (!) map and not the OSM map. (This is even the case for the sample trace provided with this library which is recorded with Android, although it's good enough here.) A GPS tracker device (not a smartphone!) would provide raw GPS data. However, there are other factors that may also require a larger tolerance of position errors. In city areas, GPS errors may increase to a multitude of usual GPS error of 5 meters. Further, OSM data has also some position error and, moreover, roads are represented as simple lines while roads are often several meters wide. This all together, requires some more tolerance to position errors than usual GPS standard error and it can even vary between regions.