doushi7394 2016-09-02 23:37
浏览 19
已采纳

根据物理位置计算可能的旅程匹配

I need your help. I have a database table called 'journeys' which contains (fromlat, fromlng, tolat, tolng) and I also have another table called 'cityPostcodes' which contains (postcode, lat, lng).

Users can search journeys by just entering 'from postcode' and 'to postcode'. After mapping these postcodes to their actual physical locations, I want to calculate likely journey matches based upon these postcodes.

What I am struggling is, how to check if two journeys are heading to the same direction? for example, the journey searched by the user and those in the 'journeys' table.

  • 写回答

1条回答 默认 最新

  • douqi0090 2016-09-02 23:49
    关注

    You could use something like the geospatial extension for PHP to calculate the cardinal direction of the from/to lat/long coordinates to see if they head in the same cardinal direction.

    You would need an origin latitude/longitude set of coordinates and a destination lat/long for each journey. You can then using something like the Haversine formula or Vincenty's formulae to calculate distince and derive the cardinal North/South/East/West direction of the line segments along the ellipsoid.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估