Skip to content

ecin/in_US

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Is a point in the US?

This short experiment tries to answer whether or not a given point forms part of the (lower 48) US.

How it works

For any given latitude on the globe, there is only a range of values that the longitude can take in order to still be considered part of the US. The problem becomes finding the edges that form the range for each latitude in which the US owns land.

Right now we’ve calculated (some, not all) ranges for every 0.01 latitude degrees, which means we’re accurate to a 0.69 mile radius.

How we test

The probability that a random point on the globe is within the (lower 48) US is 1.5832%, if we divide the area that the (lower 48) US takes up and divide it by the area of the entire world*. Thus, given enough random points, we can test how accurate our algorithm is. Thus far, we’re hovering somewhere around 80% accuracy.

  • Area information taken from Wikipedia. A simpler solution to the problem might be to simply edit those values on Wikipedia. It’s all about truthiness, right?

Why bother?

Done correctly, we should be able to calculate whether a given point falls in the (lower 48) US in O(1) time.

Example

  
    require 'point'

    Point.new # without arguments, it generates a random latitude/longitude pair     
    point = Point.new -45.23, -1.09

    point.in_US? # => false
  

About

Is a point part of the (lower 48) US?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages