lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Bell (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (SOLR-2125) Spatial filter is not accurate
Date Tue, 21 Sep 2010 03:18:33 GMT

    [ https://issues.apache.org/jira/browse/SOLR-2125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912820#action_12912820
] 

Bill Bell edited comment on SOLR-2125 at 9/20/10 11:18 PM:
-----------------------------------------------------------

Yes there is still a bug.

Most of what I was saying was right. I just did a quick maps.google.com - click directions
- and then put the 2 lat,long in both fields.

137 miles = 220.480128 kilometers (Google)
196.6km using http://www.movable-type.co.uk/scripts/latlong.html 

See on map: http://www.movable-type.co.uk/scripts/latlong-map.html?lat1=45.176140&long1=-93.873410&lat2=44.936905&long2=-91.392935

Distance:	196.6 km
Initial bearing:	096°53′44″
Final bearing:	098°39′05″
Midpoint:	45°03′48″N, 092°37′50″W

As the crow flies is less distance (which makes sense).

I even used the JS function on http://www.movable-type.co.uk/scripts/latlong.html:

<code>
function toRad(a) {
    return (a*Math.PI/180);
};

function hsin(lat1,lon1,lat2,lon2) {
var R = 6371; // km
var dLat = toRad(lat2-lat1);
var dLon = toRad(lon2-lon1); 
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * 
        Math.sin(dLon/2) * Math.sin(dLon/2); 
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
var d = R * c;
return d;
};

<code>

As a Javascript function - while looping through the results. Since I cannot find a way to
output the distance automagically from the XML coming back from SOLR.

<script>document.write(hsin(lat,lon,solr.lat,solr.lom));</script>

I kept playing with d=<km> to see when the filter is not longer showing on the results
at while value.

&sort=dist(2,store,vector(44.9369054,-91.3929348)) asc 

d=285 shows.
d=284 does not show.






      was (Author: billnbell):
    Yes there is still a bug.

Most of what I was saying was right. I just did a quick maps.google.com - click directions
- and then put the 2 lat,long in both fields.

137 miles = 220.480128 kilometers (Google)
196.6km using http://www.movable-type.co.uk/scripts/latlong.html 

See on map: http://www.movable-type.co.uk/scripts/latlong-map.html?lat1=45.176140&long1=-93.873410&lat2=44.936905&long2=-91.392935

Distance:	196.6 km
Initial bearing:	096°53′44″
Final bearing:	098°39′05″
Midpoint:	45°03′48″N, 092°37′50″W

As the crow flies is less distance (which makes sense).

I even used the JS function on http://www.movable-type.co.uk/scripts/latlong.html:

function toRad(a) {
    return (a*Math.PI/180);
};

function hsin(lat1,lon1,lat2,lon2) {
var R = 6371; // km
var dLat = toRad(lat2-lat1);
var dLon = toRad(lon2-lon1); 
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
        Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * 
        Math.sin(dLon/2) * Math.sin(dLon/2); 
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
var d = R * c;
return d;
};

As a Javascript function - while looping through the results. Since I cannot find a way to
output the distance automagically from the XML coming back from SOLR.

<script>document.write(hsin(lat,lon,solr.lat,solr.lom));</script>

I kept playing with d=<km> to see when the filter is not longer showing on the results
at while value.

&sort=dist(2,store,vector(44.9369054,-91.3929348)) asc 

d=285 shows.
d=284 does not show.





  
> Spatial filter is not accurate
> ------------------------------
>
>                 Key: SOLR-2125
>                 URL: https://issues.apache.org/jira/browse/SOLR-2125
>             Project: Solr
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 1.5
>            Reporter: Bill Bell
>
> 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 org.apache.solr.search.function.distance.Constants.EARTH_MEAN_RADIUS_KM)
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
kilometers
> 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))
asc 
> 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message