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

Units option to within method doesn't seems to properly work #121

Open
rmagnum2002 opened this issue Apr 15, 2017 · 0 comments
Open

Units option to within method doesn't seems to properly work #121

rmagnum2002 opened this issue Apr 15, 2017 · 0 comments

Comments

@rmagnum2002
Copy link

rmagnum2002 commented Apr 15, 2017

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.

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