eZ Community » Forums » Extensions » eZ Find » Geographical search
expandshrink

Geographical search

Geographical search

Saturday 21 February 2009 6:08:21 pm - 11 replies

Hi

We have been doing a custom google maps site for a larger Scandinavian client.
We are currently using eZ FInd for standard search functions but our client has now requested geographical search functions such as proximity searches etc..

As an example: Show me all petrol stations within 25 km from the following lat/long.
Then rate the results based on the closest geographical match.

I have been looking into the local solr and it looks like it can provide the needed functions.

Anyone has experience with geographical searches and eZ Find?

Fredrik

Tuesday 24 February 2009 12:57:44 pm

I have no experience with such a situation, but if I'm not wrong in partner day ez system said that ez find 2 could handle such situations...

Friday 06 March 2009 10:50:14 am

Hi

Unfortunately I was not there then.
You would not have access to a presentation or document that mentions this?

Fredrik

Monday 09 March 2009 1:33:41 pm

I'm sorry, but there is no presentation about this feature (the ezfind presentation was about indexing external data.)

But a partner asked if it would be possible to do such a geographical search and the answer was yes.

I've been looking the ezfind documentation and perhaps this example (page 16) can help you:

Example:
fetch( ezfind, search, hash( query, 'eZ Systems', filter,
array( 'or', array( 'and', 'article/body:hello','article/rating:[1 TO 10]' ),
array( 'and', 'article/body:goodbye', 'article/rating:[10 TO 20]' ) ) )
Returns:
Result with articles containing the words “ez” and “systems”, either having both 'hello' present in the body and a rating comprized between 1 and 10, either both 'goodbye' in the body and a rating comprized between 10 and 20.

Using this kind of range filter could do the job...

Modified on Monday 09 March 2009 1:35:29 pm by Andreas Kaiser

Monday 06 April 2009 9:31:51 am

Hi,

I see these sites :
http://www.meresverige.dk/
http://dsbfirst.meresverige.dk/

And it interest me to use geographical searches (Google Maps) and eZ Find 2.0.0....!
But I don't know how...
Are you found out?

Thanks,

Monday 06 April 2009 4:42:44 pm

Hi Anne, Fredrik,

I implemented a range search within the GIS operators,
its based on latitude and longitude.

It's a template operator which provides the needed functions.
http://svn.projects.ez.no/gisoperators/

We use the google geocoder to get the lat and long.

The range search is done with a more or less complex SQL statement based on the GRS80-Ellipsoid Modell ( http://en.wikipedia.org/wiki/GRS80 ) which is also the standard for GPS systems:

$query=SELECT street, zip, city, state, country, ".$radius."*ACOS(cos(RADIANS(latitude))*cos(".$theta.")*(sin(RADIANS(longitude))*sin(".$phi.")+cos(RADIANS(longitude))*cos(".$phi."))+sin(RADIANS(latitude))*sin(".$theta.")) AS Distance FROM ezgis_position WHERE ".$radius."*ACOS(cos(RADIANS(latitude))*cos(".$theta.")*(sin(RADIANS(longitude))*sin(".$phi.")+cos(RADIANS(longitude))*cos(".$phi."))+sin(RADIANS(latitude))*sin(".$theta.")) <= ".$range." ORDER BY Distance";

In fact working with the GRS80 modell is very fast and accurate compared to other even when using large databases.

The whole work is done directly within the MySQL Database with a single fast query.

So if you have the geodata available this should be easy...

Modified on Monday 06 April 2009 4:50:47 pm by Norman Leutner

Tuesday 05 May 2009 4:22:20 pm

Thanks Normann for your operator.

For the moment I explore the solution to use eZ Find 2.0.0 with the extension googlemaps : http://projects.ez.no/googlemaps.

I indexed with ez Find more camping and I do:

{def 	$environ=fetch(ezfind, search, 
                       hash(query,'',
                            filter,array(
                              'geolocalisation_temp/latitude:[40 TO 45]'
)))}

When attribute is a float the search doesn't work! Why?
When attribute is a text_line the search work but the result isn't relevant.

Any idea?

Tuesday 12 May 2009 8:17:22 am

Hi anne,

due to a longitude can something between 111km (equator) or 1km (north pole) this is not a good general solution...

We're in need of getting this also working with eZ Find within the next weeks,
so I'll have a closer look into the solr raw query documenation to see if solr is able to handle the formula also.

Modified on Tuesday 12 May 2009 12:38:03 pm by Norman Leutner

Tuesday 12 May 2009 11:35:40 am

Hi !

eZ Find 2.0 supports range searches on attributes, as Andreas pointed out. Plus, storing the coordinates of a place is possible, either using the http://projects.ez.no/googlemaps extension ( and probably extending it to have the correct subattributes structures in Solr's index ), or, simpler approach, using 2 ezfloat attributes.
The very issue here is that float attributes are not indexable ( issue coming from the datatype itself, self-described as not indexable ). This is something we are planning on circumventing in eZ Find 2.1. This would allow the coordinates to be pushed in Solr.

You will then need a nice black box, taking as input the search distance ( 2 km ), the original coordinates ( 45, 77 ), and the search-surface type : square, circle, and outputting, for instance, the boundaries of the search surface, as coordinates ( this is a simplisitic assumption, i am sure that the ones who already tackled the subject can give some valuable input on this ). You can then use the built-in ezfind/search fetch function, or directly the PHP API, indifferently, to gather all restaurants located within 2km walking distance around your current geographical location.

This would take the following form :

fetch( 'ezfind', 'search', 
          hash( 'query', '', 
                'filter',
                         array(  'and', 
                                'restaurant/latitude:[44 TO 46]',
                                'restaurant/longitude:[76 TO 78]', 
                               ) 
               )

Any input on this ?
Cheers,

Modified on Tuesday 12 May 2009 11:38:06 am by Nicolas Pastorino

Tuesday 12 May 2009 12:34:35 pm

Hi Nicolas,

as far as i understood you're trying search for latitude and longitude whithin a given lat and long range (rectangle).

Due tue the surface distance on 0° latitude is 111.320 km per 1° longitude,
on 90° latitude it is 0 km per 1° longitude.
Due to the used rectangle does not include any sphere information,
this would be very inaccurate.

Here's what I want to achieve:

Let's say where're in a helicoter with our Iphone and need to know the next gas station within 30km. We browse to our site http://www.helikopter-tankstellen.de, enter our lat on long (or address) and submit the form.

The result displays the list on gas stations available within 30km with the actual distance sorted by distance.

I've build this before within a single MySQL Query (shown above) so the only question from my side is if we can use mathematical functions like radians, sin, cos, acos in some way within a solr raw query and build a new attribute 'actual_distance' for the serach result.

Modified on Tuesday 12 May 2009 12:41:59 pm by Norman Leutner

Tuesday 12 May 2009 2:17:25 pm

Grant Ingersoll from Solr is currently working on spatial search:

https://issues.apache.org/jira/browse/SOLR-773

Wednesday 13 May 2009 8:41:07 am

Hi,

Thanks for the Solr issue link. I had seen this pass by on the Solr mailing list yesterday.
We'll closely follow up on this. Here is the enhancement request :
http://issues.ez.no/IssueView.php?Id=14901&ProjectId=8. You may want to add input to it.

Best Regards,

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from