dongyong8071 2017-07-08 17:52
浏览 42

将点添加到线串

So I'm tracking a number of vessels as they travel across the ocean, creating a LINESTRING() in MySQL once I've gotten all the known GPS points from departure to arrival. Sometimes, however, I'm able to find additional points after creating the linestring, sometimes without associated time data.

So my question is: What would be the simplest way to take a linestring and add a point to it? It's reasonable to assume that, point by point, the LINESTRING doesn't change direction much and that it should be possible to deduce mathematically between which points the new point should be placed; but I can't seem to figure it out.

My solution so far finds which given coordinate on the LINESTRING is the closest, but I haven't been able to figure out the math that decides whether it should come before or after. Maybe the solution involves finding out which part of the linestring the point is closest to and then inserting it between the two coordinates that define that part of the line?

  • 写回答

1条回答 默认 最新

  • dongyu6276 2018-01-20 01:15
    关注

    A possible answer...

    Sort the GPS points by either latitude or longitude. Pick the one that has the most variation. Then construct the string that defines a line.

    If the line is not "straight" or arcs in certain ways around the globe, or has to maneuver around a peninsula, or ..., the algorithm is to simplistic. Also, if the error in GPS is sometimes greater than the distance between two 'consecutive' points, the algorithm is flawed.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看