Geofencing with MongoDB

I read the documentation for MongoDB here , and I found this really interesting. However, there was one feature that seemed to be very large, but was not clearly documented. This is the concept of geo-fencing. If I create a radius (or rectangle), how can I execute the request so that I can specify a point, and Mongo can tell me if this point is inside certain areas, instead of asking for neighboring areas and execute the Ray-Casting algorithm (or any other algorithm) to determine if my provided point is in these areas.

Any help in the right direction, or, even better, some examples of how to do this with MongoDB, is greatly appreciated. Thanks!

Refresh
Just to let everyone know what I did. I have finished my own solution built on top of Mongo (to use its existing geospatial index / query capabilities) and it works well enough for a prototype. As a solution for use in production, he can definitely use some improvements. But I wrote a series of blogs about how I approached the problem with an example server in Ruby. You can find the first part of your blog on my website here .

+8
mongodb geolocation geospatial
source share
2 answers

Unfortunately, mongodb geoinformers are designed to store point data only. Storage of the regions will require serious processing of the data structure that we use and is a long-term goal, but will not happen in the short term. As a job, if your regions are about the same size, you can leave while maintaining the central point of each region. Then you can get the ten nearest regions and make a client filter in your application to find out what area the request point is in.

Alternatively, you can create an idealized grid and save the grid squares that each region contains in the array for that region. Then match the query point with the grid square and determine in which area (if more than one for this square) is the point. This is actually similar to how we implement our geographic information index, although we use a dynamic grid. If you want to go this route, you must use the regular (non-geo) index.

While none of them are perfect, we hope that they provide an acceptable solution.

+5
source share

Why not just use collections for your regions and use polygons for your regions - here is a great presentation from Greg Studer @ 10gen that can give you some ideas: https://docs.google.com/present/edit?id=0ARXrl_iXSUmXZGhieDhqcTdfMTdjcjI4eDNkNQ&hl= en_US

+2
source share

All Articles