Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URGENT* Within method ignores the units option and uses miles as units. #122

Open
Apane opened this issue Apr 19, 2017 · 0 comments
Open

Comments

@Apane
Copy link

Apane commented Apr 19, 2017

I have a production app and this doesn't seem to be working as expected, need help ASAP! I am trying to find objects in range of 4 kms, so I am using this example in docs:

Location.within(5, :units => :kms, :origin => @somewhere)

it will get the records within 5 kilometers instead of 5 miles

in my case it will be:

venues = Venue.within(4, units: :kms, origin: [44.1133355, -79.376071])

Also, to make sure it shows proper results, I am using this route as reference:
https://www.google.com/maps/dir/44.088102,-79.3346276/19619+McCowan+Rd,+Mount+Albert,+ON+L0G+1M0,+Canada/@44.1132739,-79.3760709,13z/data=!3m1!4b1!4m8!4m7!1m0!1m5!1m1!1s0x89d534903b40df85:0x3a15c399937141ab!2m2!1d-79.3473307!2d44.1384912
it shows 5.7 km from origin to destination.

Now, the above venue should not be listed, as it is not in range of 4 km from origin, but actually it is listed. I've tried to narrow the distance to see at what point this venue will not be listed, and I got to:

venues = Venue.within(3.6, units: :kms, origin: [44.1133355, -79.376071]) 

Now, 3.6 miles to kms = 5.79364... and venue is not listed. This makes me think that within method ignores the units option and uses miles as units.

My setup:

  acts_as_mappable default_units: :kms,
                   lat_column_name: :latitude,
                   lng_column_name: :longitude,
                   default_formula: :sphere

Thank you.

@Apane Apane changed the title Within method ignores the units option and uses miles as units. URGENT* Within method ignores the units option and uses miles as units. Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant