module

PolygonContains

Determines if a point (lon, lat in degrees) lies within a spherical polygon.

Constants

DEG_TO_RAD = PI / 180.0
EPSILON = 1e-6

Small epsilon value for floating-point comparisons

HALF_PI = PI / 2.0
PI = Math::PI

Mathematical constants

TAU = 2.0 * PI
VERSION = {{ (`shards version /tmp/tmp.nHLANk/src/src`).chomp.stringify }}

Class methods

contains?(polygon : Array(Array(Point)), point : Point) : Bool

Public entry point

polygon - Array of rings (each ring is Array of Point tuples {lon, lat} in degrees) point - Point tuple {lon, lat} in degrees

Example:

polygon = [
  [{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}],
]
point = {0.5, 0.5}
PolygonContains.contains?(polygon, point) # => true
Source

Nested types