I use drupal6 with wounderfull views2 and location. I created a view which displays a location and the distance to a specific point. When i enable the table-display and set the sorting to "Distance" the sorting will nor work correctly.
Sql-Query goes like this:
SELECT ... ORDER BY location_latitude ASC
but "location_latitude" is not the right way to sort by distance. MySql-Qeury must be:
$lat = latitude;
$lon = longitude;
SELECT SQRT( POW( 69.1 * ( l.latitude - ".$lat.") , 2 ) + POW( 69.1 * ( ".$lon." - l.longitude ) * COS( l.latitude / 57.3 ) , 2 ) ) AS distance .... ODER BY distance ASC
is this a known problem? How to fix that?
Thank you for your help!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | click_sort2.patch | 2.5 KB | nickl |
| #1 | click_sort.patch | 2.6 KB | traxer |
Comments
Comment #1
traxer commentedI implemented
location_handler_field_location_distance::click_sort(). For that I moved the code that retrieves the reference location to a designated functionlocation_handler_field_location_distance::_get_reference_location()so that it can be used bylocation_handler_field_location_distance::query()as well aslocation_handler_field_location_distance::click_sort().Comment #2
traxer commentedThe patch also fixes #356488: Distance Field Handler does not accept all valid longitudes and latitudes.
Comment #3
nickl commentedPatch did not apply and had to be re-rolled.
Works as advertised.
Comment #4
ankur commentedCommitted to HEAD and DRUPAL-6--3
Comment #5
yesct commentedhttp://drupal.org/cvs?commit=347454
http://drupal.org/cvs?commit=347452