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 欧姆龙PLC 电机控制 限位
    • ¥30 如何处理shell命令接收到的视频流并实时播放出来
    • ¥15 虚心请教C#的代码优化问题
    • ¥15 有偿求做台风过境全过程模拟仿真
    • ¥50 求!AutomationDesk 如何自动导入Variant数据
    • ¥20 Next.JS 静态导出路由
    • ¥15 我做一个对中文文本情感分析的项目 我用了CNN,和keras框架 报的错误我一直处理不好
    • ¥15 unity使用bakery打光烘焙所遇到的问题。
    • ¥99 二维有限元方法求解,泊松方程
    • ¥35 我需要在PC端 开两个抖店工作台客户端.(语言-java)