How to implement geo-location search in Grails?

I am working on Grails 1.3.2 with MySql. I need to save the latitude and longitude of certain places in the database, and then, based on the user's current location, I need to return elements that are in a certain radius of this location. So, we basically have the following requirements:

  • Search for places c-in a given radius of the user's current coordinates
  • Provide full-text search. We are currently using search for this.
  • Do a combination of a full text search with a given radius of the user's current coordinates.

I studied the various options that we have and wanted to know what your views / suggestions are for their implementation. The various options that we have here are:

I believe that this is a very basic requirement in any application that integrates with cards.

So, I'm really interested in learning the most appropriate way to implement this functionality.

thanks

+7
grails spatial-index geospatial spatial-query
source share
2 answers

(I made a prototype using Long / Lat to search for rows in a radius, but now abandoned this in favor of the GridRef system available in the UK)

As a first step, do not use the WHERE clause based on the calculated field (for example, the actual distance based on the given coordinate and row coordinate).

Instead, try the following:

  • Imagine a circle where radius = maximum distance
  • Draw a box around it using curved lines of longitude.
  • Find items in this field.

In practice, this means:

  • determine how many degrees of longitude represents your maximum distance at a given latitude.
  • determine how many degrees latitude represents your maximum distance at a given longitude (this factor will be fixed when using the spherical-terrestrial model).
  • SELECT * FROM places WHERE long> $ westside AND long <$ eastside AND lat <$ northside and lat> $ southside

This means that you are doing very simple calculations to get an indefinite subset covering the area 30% more than your actual circle. If you also want to add a text search, either SELECT FROM (subquery), or add your text sentence AFTER a simple comparison above, since text queries are expensive.

+4
source share

There is a Grails Spatial plugin . It appears that some of its subpings support search, such as the HDB plugin .

+1
source share

All Articles