Class: GeoAPI::Point

Inherits:
Geometry show all
Defined in:
lib/geoapi/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

#coordinates, from_hash, from_json, new_from_class_name, #to_json, #type

Constructor Details

#initialize(*args) ⇒ Point

Returns a new instance of Point.



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/geoapi/geometry.rb', line 94

def initialize *args
  
  params = args.extract_options!
  params = params == {} ? nil : params
  
  puts "GEOAPI::Point.new #{params.to_json}"
  
  #raise ArgumentError, ":lat (latitude) must be sent as a parameter to the GeoAPI::Point constructor" unless params.has_key?(:lat)
  #raise ArgumentError, ":lng (longitude) must be sent as a parameter to the GeoAPI::Point constructor" unless params.has_key?(:lng)
  
  self.coords = [params[:lng].to_f, params[:lat].to_f] unless params.blank? || params[:lat].blank?
  super args
end

Instance Attribute Details

#coordsObject

Returns the value of attribute coords.



84
85
86
# File 'lib/geoapi/geometry.rb', line 84

def coords
  @coords
end

#geometry_typeObject

Returns the value of attribute geometry_type.



84
85
86
# File 'lib/geoapi/geometry.rb', line 84

def geometry_type
  @geometry_type
end

Instance Method Details

#latitudeObject



86
87
88
# File 'lib/geoapi/geometry.rb', line 86

def latitude
  coords[0]
end

#longitudeObject



90
91
92
# File 'lib/geoapi/geometry.rb', line 90

def longitude
  coords[1]
end