Latitude and Longitude check with in range

15 views
Skip to first unread message

honey ruby

unread,
Jun 9, 2018, 3:42:06 AM6/9/18
to Ruby on Rails: Talk
Hi ,

I have city or county Lat and Long and if user inputs of lat and long are with in the city or county which I specify then I should allow him for next page else I need to block him and say we are not serving at that place. Using Geocoder I don't see any method to check lat and long with in range. Can any one help me how can I do this.




Thanks in advance

Hassan Schroeder

unread,
Jun 9, 2018, 9:42:24 AM6/9/18
to rubyonrails-talk
On Sat, Jun 9, 2018 at 12:42 AM, honey ruby <emailtoh...@gmail.com> wrote:

> I have city or county Lat and Long and if user inputs of lat and long are
> with in the city or county which I specify then I should allow him for next
> page else I need to block him and say we are not serving at that place.
> Using Geocoder I don't see any method to check lat and long with in range.

A Range is standard Ruby, nothing Geocoder-specific about it. What
does an example lat/long "range" look like?

Otherwise, is there some reason Thing.near() doesn't work for your
use case?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

David Merrick

unread,
Jun 9, 2018, 4:44:41 PM6/9/18
to rubyonra...@googlegroups.com
Hi Hassan.

You will need to specify a collection of points that define an area.ie County or City




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBUhbx59GFBRKNXEOjAHs_sHv6KO1%2B%3DRNYd-vGj1VNUKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz/

Email merri...@gmail.com

Ph   03 216 2053

Cell 027 3089 169

David Merrick

unread,
Jun 9, 2018, 4:55:28 PM6/9/18
to rubyonra...@googlegroups.com
Define a set of list of points set([lat,long],...) or [ [lat,long],...]

If location in set or list accept

else

block

On Sun, Jun 10, 2018 at 1:41 AM, Hassan Schroeder <hassan.s...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBUhbx59GFBRKNXEOjAHs_sHv6KO1%2B%3DRNYd-vGj1VNUKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hassan Schroeder

unread,
Jun 9, 2018, 5:04:35 PM6/9/18
to rubyonrails-talk
On Sat, Jun 9, 2018 at 1:44 PM, David Merrick <merri...@gmail.com> wrote:
> Hi Hassan.
>
> You will need to

Uh, no, not my question.

Ryan

unread,
Jun 11, 2018, 3:51:35 PM6/11/18
to Ruby on Rails: Talk
Honey,

Geocoding refers to the translation of an address to a lat/lng or vice-versa.
If you're looking to determine if a lat/lng is within a City or County shape, you're probably looking for something like a Point-in-Polygon search - to ensure the lat/lng is within a given boundary.
Rails offers nice `PostGIS` support. https://postgis.net/docs/manual-1.4/ST_Contains.html
There are likely other options as well, depending on where you store your shapefiles.

- Ryan
Reply all
Reply to author
Forward
0 new messages