Download & Extend

Implement click_sort in distance field handler

Project:Location
Version:6.x-3.x-dev
Component:Location_views
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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!

Comments

#1

Title:sort by distance» Implement click_sort in distance field handler
Version:6.x-3.0-rc2» 6.x-3.x-dev
Status:active» needs review

I implemented location_handler_field_location_distance::click_sort(). For that I moved the code that retrieves the reference location to a designated function location_handler_field_location_distance::_get_reference_location() so that it can be used by location_handler_field_location_distance::query() as well as location_handler_field_location_distance::click_sort().

AttachmentSize
click_sort.patch 2.6 KB

#2

#3

Status:needs review» reviewed & tested by the community

Patch did not apply and had to be re-rolled.
Works as advertised.

AttachmentSize
click_sort2.patch 2.5 KB

#4

Status:reviewed & tested by the community» fixed

Committed to HEAD and DRUPAL-6--3

#5

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here