
123

Spatial filter is not accurate

Key: SOLR2125
URL: https://issues.apache.org/jira/browse/SOLR2125 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912785#action_12912785 ]
Yonik Seeley commented on SOLR2125:

Just in time Bill!
I just started looking at spatial stuff today since I'm planning on putting some of it in my Lucene Revolution presentation. I've seen some tweets about people having difficulties, and I've had some problems when I tried stuff myself.
Anyway, I'm going to try and clean up some of this stuff over the next few days and make the wiki a bit more user oriented  an extra pair of eyeballs would be welcome!
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912799#action_12912799 ]
Yonik Seeley commented on SOLR2125:

Hmmm, well, I just corrected one bug that hardcoded the distance in miles, but it was just a check to see if we crossed the poles.
I don't think that change alone will fix your issue.
Earlier today, I switched around some fields/fieldtypes in the example schema, so "store" is now of latlon type, and it's the only location type (having multiple is just confusing).
So just looking at the bounding box now, here's the URL from your example:
http://localhost:8983/solr/select?fl=*,score&start=0&rows=10&q={!sfilt%20fl=store}&qt=standard&pt=44.9369054,91.3929348&d=280&debugQuery=true
And I can see that the generated bounding box is:
+store_0_coordinate:[43.129843715965166 TO 46.688683890119314] +store_1_coordinate:[93.83266208454557 TO 88.79716545231159]
Which just misses the longitude of the point on the document of 93.87341.
Can anyone point to an webapp for checking arbitrary distances between two lat/lon points?
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912808#action_12912808 ]
Yonik Seeley commented on SOLR2125:

Bill, I found two online distance calculators that both give the distance between the points you provided as 196km.
http://www.movabletype.co.uk/scripts/latlong.htmlhttp://www.es.flinders.edu.au/~mattom/Utilities/distance.htmlNow... the distance of 280km you provided should certainly still encompass that, so we still have a bug anyway.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912820#action_12912820 ]
Bill Bell commented on SOLR2125:

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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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 should be less distance.
I even used the JS function on http://www.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912820#action_12912820 ]
Bill Bell edited comment on SOLR2125 at 9/20/10 11:16 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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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.
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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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 should be less distance.
I even used the JS function on http://www.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912820#action_12912820 ]
Bill Bell edited comment on SOLR2125 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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912820#action_12912820 ]
Bill Bell edited comment on SOLR2125 at 9/20/10 11:19 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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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.movabletype.co.uk/scripts/latlong.html
See on map: http://www.movabletype.co.uk/scripts/latlongmap.html?lat1=45.176140&long1=93.873410&lat2=44.936905&long2=91.392935Distance: 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.movabletype.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(lat2lat1);
var dLon = toRad(lon2lon1);
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(1a));
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.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912822#action_12912822 ]
Chris Male commented on SOLR2125:

The sorting won't be the issue though surely? The bug seems to be in the bounding box generation that Yonik pointed out. There will be some rounding issues at different places I can imagine, but nothing that would generate such a discrepancy.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912823#action_12912823 ]
Chris A. Mattmann commented on SOLR2125:

Distance using the Haversine function is extremely sensitive to what spatial reference system the data was recorded in. WGS84 isn't particular great with long distances. The PostGIS in Action book has a really good explanation of this.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912827#action_12912827 ]
Yonik Seeley commented on SOLR2125:

bq. Distance using the Haversine function is extremely sensitive to what spatial reference system the data was recorded in. WGS84 isn't particular great with long distances.
I know nothing on this topic, but an error of 45% at 200 km? I'm pretty certain that there is a bug not having to do with the accuracy of spatial reference systems here.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912830#action_12912830 ]
Chris A. Mattmann commented on SOLR2125:

Umm well if you know nothing then how are you pretty sure? And yes, the error bars are fairly high for the Great Circle distance.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912833#action_12912833 ]
Bill Bell commented on SOLR2125:

The calculation using hsin Javascript is more accurate than our algorithm ? Chris a few percentage points maybe  but not 45%.
I will look into it some more tonight. It can't be that complicated.
Bill
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912835#action_12912835 ]
Chris A. Mattmann commented on SOLR2125:

Hey Bill:
Interesting. usually these types of errors are due to errors in the coordinate reference system of the input data, but if you were able to successfully implement this in JS, then yep, it's likely some bug in the existing Solr implementation rather than the input data.
Cheers,
Chris
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912883#action_12912883 ]
Bill Bell commented on SOLR2125:

/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/DistanceUtils.java  hsin appears to be okay.
Good print:
System.out.println("x1 = " + x1 + "  " + x1*180/Math.PI + ",y1 = " + y1 + "  " + x2*180/Math.PI + ",x2 = " + x2 + "  " + x2*180/Math.PI + ",y2 = " + y2 + "  " + y2*180/Math.PI + ",radius = " + radius + "\n");
System.out.println("result = " + result + " km\n");
Where is the boundary calculated?
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912883#action_12912883 ]
Bill Bell edited comment on SOLR2125 at 9/21/10 5:01 AM:

/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/DistanceUtils.java  hsin appears to be okay.
Good print:
System.out.println("x1 = " + x1 + "  " + x1*180/Math.PI + ",y1 = " + y1 + "  " + x2*180/Math.PI + ",x2 = " + x2 + "  " + x2*180/Math.PI + ",y2 = " + y2 + "  " + y2*180/Math.PI + ",radius = " + radius + "\n");
System.out.println("result = " + result + " km\n");
My guess: "src/java/org/apache/solr/schema/LatLonType.java
{code}
double[] ur;
double[] ll;
if (options.measStr == null  options.measStr.equals("hsin")) {
ur = DistanceUtils.latLonCornerDegs(point[LAT], point[LONG], options.distance, null, true, options.radius);
ll = DistanceUtils.latLonCornerDegs(point[LAT], point[LONG], options.distance, null, false, options.radius);
} else {
ur = DistanceUtils.vectorBoxCorner(point, null, options.distance, true);
ll = DistanceUtils.vectorBoxCorner(point, null, options.distance, false);
}
{code}
was (Author: billnbell):
/lucene/contrib/spatial/src/java/org/apache/lucene/spatial/DistanceUtils.java  hsin appears to be okay.
Good print:
System.out.println("x1 = " + x1 + "  " + x1*180/Math.PI + ",y1 = " + y1 + "  " + x2*180/Math.PI + ",x2 = " + x2 + "  " + x2*180/Math.PI + ",y2 = " + y2 + "  " + y2*180/Math.PI + ",radius = " + radius + "\n");
System.out.println("result = " + result + " km\n");
Where is the boundary calculated?
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912981#action_12912981 ]
Grant Ingersoll commented on SOLR2125:

Hmm, I'm putting in some more exact tests into LatLonType and SpatialFilterTest, trying to work through this.
{code}
clearIndex();
assertU(adoc("id", "14", fieldName, "0,5"));
assertU(adoc("id", "15", fieldName, "0,15"));
//one at the upper right of the box, 3000KM from 0,0, see http://www.movabletype.co.uk/scripts/latlong.html assertU(adoc("id", "16", fieldName, "18.71111,19.79750"));
assertU(commit());
checkHits(fieldName, "0,0", 1000, 1, 14);
checkHits(fieldName, "0,0", 2000, 1, 14);
checkHits(fieldName, "0,0", 3000, 2, 14, 15);
checkHits(fieldName, "0,0", 3001, 3, 14, 15, 16);
checkHits(fieldName, "0,0", 3000.1, 3, 14, 15, 16);
{code}
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:alltabpanel ]
Grant Ingersoll reassigned SOLR2125:

Assignee: Grant Ingersoll
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> Project: Solr
> Issue Type: Bug
> Components: Build
> Affects Versions: 1.5
> Reporter: Bill Bell
> Assignee: Grant Ingersoll
>
> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912983#action_12912983 ]
Grant Ingersoll commented on SOLR2125:

bq. 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
This URL has me a bit stumped. sfilt on a lat_lon is going to use Great Circle to calculate the distance, but then you are sorting using Euclidean distance? Not saying that's a problem, but it strikes me a bit weird.
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> Project: Solr
> Issue Type: Bug
> Components: Build
> Affects Versions: 1.5
> Reporter: Bill Bell
> Assignee: Grant Ingersoll
>
> 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, email: [hidden email]
For additional commands, email: [hidden email]


[ https://issues.apache.org/jira/browse/SOLR2125?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=12912986#action_12912986 ]
Yonik Seeley commented on SOLR2125:

bq. but then you are sorting using Euclidean distance
I imagine it's because of the wiki: http://wiki.apache.org/solr/SpatialSearchThe first example uses "dist" and I imagine many are going to interpret that as geo distance (I made the same mistake trying to follow the wiki).
> Spatial filter is not accurate
> 
>
> Key: SOLR2125
> URL: https://issues.apache.org/jira/browse/SOLR2125> Project: Solr
> Issue Type: Bug
> Components: Build
> Affects Versions: 1.5
> Reporter: Bill Bell
> Assignee: Grant Ingersoll
>
> 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, email: [hidden email]
For additional commands, email: [hidden email]

123
