Forums / Extensions / eZ Find / Geographical search

Geographical search

Author Message

Fredrik Ardmar

Saturday 21 February 2009 9:08:21 am

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

http://www.areadigital.org

Custom google maps with eZ Publish

http://www.meresverige.dk
http://dsbfirst.meresverige.dk

Andreas Kaiser

Tuesday 24 February 2009 3:57:44 am

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...

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/

Fredrik Ardmar

Friday 06 March 2009 1:50:14 am

Hi

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

Fredrik

http://www.areadigital.org

Custom google maps with eZ Publish

http://www.meresverige.dk
http://dsbfirst.meresverige.dk

Andreas Kaiser

Monday 09 March 2009 5:33:41 am

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...

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/

anne martinet

Monday 06 April 2009 12: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,

Norman Leutner

Monday 06 April 2009 7:42:44 am

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...

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

anne martinet

Tuesday 05 May 2009 7:22:20 am

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?

Norman Leutner

Monday 11 May 2009 11:17:22 pm

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.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Nicolas Pastorino

Tuesday 12 May 2009 2: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,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Norman Leutner

Tuesday 12 May 2009 3:34:35 am

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.

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Norman Leutner

Tuesday 12 May 2009 5:17:25 am

Grant Ingersoll from Solr is currently working on spatial search:

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

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Nicolas Pastorino

Tuesday 12 May 2009 11:41:07 pm

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,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye