Home >Backend Development >PHP Tutorial >map路线有关问题

map路线有关问题

WBOY
WBOYOriginal
2016-06-13 12:06:18843browse

地图路线问题
我想做一个功能,是知道路线的起点和终点,那么,在给我一个地点,如何知道这个点在这个起点和终点的路线上?
------解决方案--------------------
起点(x0,y0)和终点(x1,y1),则斜率为 k = (y1-y0)/(x1-x0)
若点(x,y)在该直线上,则有(y-y0)/(x-x0) == k

地图路线为多段折线组成,你可逐段应用该判别算法,并适当的放宽误差
因为实际道路修建时,若线路临近 A,则可能绕行到 A,也可能在线路和 A 之间修建支线

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn