Class: CloudMade::Point
Instance Attribute Summary collapse
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lon ⇒ Object
Returns the value of attribute lon.
Instance Method Summary collapse
- #==(point) ⇒ Object
-
#initialize(*args) ⇒ Point
constructor
Posible initializers are Point.new(1, -1) Point.new([1, -1]).
- #to_latlon ⇒ Object
- #to_s ⇒ Object
- #to_wkt ⇒ Object
- #wkt_helper ⇒ Object
Methods inherited from Geometry
Constructor Details
#initialize(*args) ⇒ Point
Posible initializers are Point.new(1, -1) Point.new([1, -1])
46 47 48 49 50 51 52 53 54 |
# File 'lib/cloudmade/geometry.rb', line 46 def initialize(*args) if args.size == 1 @lat = args[0][0] @lon = args[0][1] elsif args.size == 2 @lat = args[0] @lon = args[1] end end |
Instance Attribute Details
#lat ⇒ Object
Returns the value of attribute lat.
40 41 42 |
# File 'lib/cloudmade/geometry.rb', line 40 def lat @lat end |
#lon ⇒ Object
Returns the value of attribute lon.
41 42 43 |
# File 'lib/cloudmade/geometry.rb', line 41 def lon @lon end |
Instance Method Details
#==(point) ⇒ Object
56 57 58 |
# File 'lib/cloudmade/geometry.rb', line 56 def ==(point) return (point.lat == @lat and point.lon == @lon) end |
#to_latlon ⇒ Object
64 65 66 |
# File 'lib/cloudmade/geometry.rb', line 64 def to_latlon "#{@lat},#{@lon}" end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/cloudmade/geometry.rb', line 60 def to_s "Point(#{@lat},#{@lon})" end |
#to_wkt ⇒ Object
68 69 70 |
# File 'lib/cloudmade/geometry.rb', line 68 def to_wkt "POINT (#{wkt_helper})" end |
#wkt_helper ⇒ Object
72 73 74 |
# File 'lib/cloudmade/geometry.rb', line 72 def wkt_helper "#{@lat} #{@lon}" end |