Ruby on Rails Friday, August 17, 2018

On Fri, Aug 17, 2018 at 12:59 PM, tom <tomabroad@gmail.com> wrote:

> does anyone know how to calculate that w/o using geo-api calls?

https://stackoverflow.com/questions/12966638/how-to-calculate-the-distance-between-two-gps-coordinates-without-using-google-m

1. Do the math yourself, or
2. Use the "geokit" gem <= that'd be my choice :-)

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

--
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/CACmC4yBFps9wfXqiRTVXgxLBdwyo6WK7%3DO6vAVNgJpeMem-nbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Aug 17, 2018, at 12:59 PM, tom <tomabroad@gmail.com> wrote:
>
> hi,
>
> i have a Task model with and address plus radius in miles (adress is being translated to lat/lng via geo-api-call).
>
> Now i have a person at location x and i want to know if that person is within that circle of the TaskModel's location plus radius.
>
>
> does anyone know how to calculate that w/o using geo-api calls?
>
>
> thx
> tom


That's called the great-circle distance. It's not overly complex to implement by hand (I've done it in SQL and in app code in the past):

https://en.wikipedia.org/wiki/Great-circle_distance

You might need to be careful about using floats, as they aren't perfectly accurate (funny rounding stuff can happen which could cause exceptions). Maybe use BigDecimal if doing your calculation with your own ruby code.

Hope that helps.


Phil

--
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/EC5E7899-D1EF-431F-B7D0-17A55B63784C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Thu, Aug 16, 2018 at 10:55 AM, Stephanie_Snowflake
<spicychemist@gmail.com> wrote:
> I'm looking for a way to split a group of data (ex. Sales Orders)
>
> Currently split (In Progress, On Hold, Shipped, Cancelled)
>
> I would like to split Shipped into two
>
> Shipped (before 1 year)
> Archive Shipped (after 1 year)

As far as I can tell, nothing in the model you show has anything to
do with *setting* a status.

You can add ':archive_shipped' to this (and presumably to the DB
schema),

> enum status: [ :in_progress, :on_hold, :cancelled, :shipped ]

but where is the status set to start with?

Also, in passing, "before one year" and "after one year" probably
leaves a day in the middle ("exactly one year") when things will be
at the least indeterminate. FWIW.

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

--
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/CACmC4yCHy48iVQeCGxy8c67x6HUhomnyCL7KWHbG_R1HwXOaBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.