google-maps - 到最近的火车站的距离
问题描述
使用谷歌地图或任何其他地图提供商,如果我在火车上有 GPS 跟踪设备,我如何获得火车到最近火车站之间的铁路距离?
解决方案
If you are physically on the train and have a GPS tracked device, most mapping platforms won't be able to snap you to the railway line unless the device/user is sitting at a station. If the device is close enough to road, usually within 150 meters, it will likely snap to that. If the user was at a station, its much easier and just a matter of calculating a transit route.
That said, most transit data uses straight line distances between stations and not true travel distances. I've worked with many large transit agencies around the world and many of them don't even know where their railway lines run, let along the true distance between stations. What they do know is how long it takes to travel between stations and that's all they generally care about for the most part.
To do this correctly, you will need access to the raw railway line vector data. Open street maps has some, but I don't know how accurate or complete it is. Many agencies or governments publish this data, but often it is just straight lines drawn between stations, so you would have to look and see what's available. Once you have complete data, then you can snap to your GPS point to the nearest railway line then calculate the shortest path along all railway lines to the station in question. This is fairly complex, but I've done this before for both railway lines and private road networks. There are several open source libraries that can assist with this, like this one: https://github.com/perliedman/geojson-path-finder
推荐阅读
- dspace - 如何手动将缩略图上传到 dspace?
- python - 根据某些列重新排列二维数组中的条目
- html - Chrome 更新会影响与 text-indent 相关的 CSS text-overflow
- android - 在尝试发送大型 BASE64 时,使用 RX 进行改造会运行 OutOfMemory
- android - Android 在 TextView 中崩溃并出现 IndexOutOfBoundsException 并且没有自定义代码的痕迹
- node.js - 如何用子文档的数组填充猫鼬结果?
- python - 使用 Python 条件变量的有界大小队列的生产者消费者
- xslt - 使用带有嵌套节点的 XSLT 转换 XML
- android - 使用类 ContextWrapper 更改语言 Android 应用程序在发布模式下不起作用
- sql - 将变量放入方程中会对其值进行四舍五入