lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Bell (JIRA)" <>
Subject [jira] Commented: (SOLR-2125) Spatial filter is not accurate
Date Wed, 22 Sep 2010 02:55:32 GMT


Bill Bell commented on SOLR-2125:

There is another example... not sure - but this is also a good first
cut. Then if you want more accurate results calculate results that come back
 and through out ones that are not within. Cache results. The link above
appears a little more accurate. But this is simpler.


// first-cut bounding box (in degrees)
$maxLat = $lat + rad2deg($rad/$R);
$minLat = $lat - rad2deg($rad/$R);
// compensate for degrees longitude getting smaller with increasing latitude
$maxLon = $lon + rad2deg($rad/$R/cos(deg2rad($lat)));
$minLon = $lon - rad2deg($rad/$R/cos(deg2rad($lat)));
$sql = "Select ID, Postcode, Lat, Lon
        From MyTable
        Where Lat&gt;$minLat And Lat&lt;$maxLat
          And Lon&gt;$minLon And Lon&lt;$maxLon";

> Spatial filter is not accurate
> ------------------------------
>                 Key: SOLR-2125
>                 URL:
>             Project: Solr
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 1.5
>            Reporter: Bill Bell
>            Assignee: Grant Ingersoll
>         Attachments: solrspatial.xlsx
> The calculations of distance appears to be off.
> Note: "The radius of the sphere to be used when calculating distances on a sphere (i.e.
haversine). Default is the Earth's mean radius in kilometers (see
which is set to 3,958.761458084784856. Most applications will not need to set this."
> The radius of the earth in KM is  6371.009 km (≈3958.761 mi).
> Also filtering distance appears to be off - example data:
> 45.17614,-93.87341 to 44.9369054,-91.3929348 Approx 137 miles Google. 169 miles = 220
> http://....../solr/select?fl=*,score&start=0&rows=10&q={!sfilt%20fl=store_lat_lon}&qt=standard&pt=44.9369054,-91.3929348&d=280&sort=dist(2,store,vector(44.9369054,-91.3929348))
> Nothing shows. d=285 shows results. This is off by a lot.
> Bill

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message