class Geomodel::Types::Point

A two-dimensional point in the [-90,90] x [-180,180] lat/lon space.

Attributes:

lat: A float in the range [-90,90] indicating the point's latitude.
lon: A float in the range [-180,180] indicating the point's longitude.

Attributes

lat[RW]
latitude[RW]
lon[RW]
longitude[RW]

Public Class Methods

new(latitude, longitude) click to toggle source
# File lib/geomodel/geotypes.rb, line 16
def initialize(latitude, longitude)
  if -90 > latitude || latitude > 90
    raise ArgumentError.new("Latitude must be in [-90, 90]") 
  else
    @latitude = latitude
  end 
  
  if -180 > longitude || longitude > 180
    raise ArgumentError.new("Longitude must be in [-180, 180]") 
  else
    @longitude = longitude
  end        
end

Public Instance Methods

==(point) click to toggle source
# File lib/geomodel/geotypes.rb, line 30
def ==(point)
  (@latitude === point.latitude) && (@longitude === point.longitude)
end
to_s() click to toggle source
# File lib/geomodel/geotypes.rb, line 34
def to_s
  "(#{@latitude}, #{@longitude})"
end