开发者

Geofencing Algorithm

Given the latitude and longitude of a point. How do I get all the readings of latitude and longitude with in a particular 开发者_开发百科radius of that point? Is there any known method to calculate all latitudes and longitudes with in a radius with respect to a given point?


This kind of thing can be done efficiently by using an R-Tree


That would be a very very large number of lat/longs! For geofencing what you want to do is calculate the distance (as per pythagoras) and decide if you are outside the radius based on the distance from the point.

If you want to take it 1 step further you can calculate the distance from the line intersecting 2 points.

I suggest you have a look at this site for some geometry formulas.


It is not possible to get all the lat/long pairs within a 500m radius of a given point (as @Cobusve and I have pointed out) -- there is an infinite number of such pairs. You have to tell us more precisely what you want.

To help you work things out I suggest you take a map of the area you are interested in, choose a point and draw a circle of radius 500m around it. That will give you all the points you are after and perhaps suggest why you need to be more clear.

And, in passing, since the distance is only 500 metres I suggest you work out your answer, when you do, in plane geometry and forget the near-sphericity of the Earth. Any inaccuracies introduced by this simplification will be very very small and it will greatly simplify the mathematics and I am beginning to form the view that this will be useful to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜