Raycasting algorithm with GPS coordinates

前端 未结 3 1044
庸人自扰
庸人自扰 2021-01-06 17:57

I\'m making a small application with Google maps that determines if an entered address is part of a predefined service region.

The user enters an address, and a PHP

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 18:27

    There is a bug with this algorithm, when the ray is tangent to the shape. Just add an epsilon to the test point's latitude when it might happen (line 3 of Ilmari's code):

    if ($test_point->lat == $p0->lat)
        $test_point->lat += 0.0000000001;
    

    Also see http://rosettacode.org/wiki/Ray-casting_algorithm (corrected URL).

    Thanks.

提交回复
热议问题