Class: CloudMade::Point

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

parse

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

#latObject

Returns the value of attribute lat.



40
41
42
# File 'lib/cloudmade/geometry.rb', line 40

def lat
  @lat
end

#lonObject

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_latlonObject



64
65
66
# File 'lib/cloudmade/geometry.rb', line 64

def to_latlon
  "#{@lat},#{@lon}"
end

#to_sObject



60
61
62
# File 'lib/cloudmade/geometry.rb', line 60

def to_s
  "Point(#{@lat},#{@lon})"
end

#to_wktObject



68
69
70
# File 'lib/cloudmade/geometry.rb', line 68

def to_wkt
  "POINT (#{wkt_helper})"
end

#wkt_helperObject



72
73
74
# File 'lib/cloudmade/geometry.rb', line 72

def wkt_helper
  "#{@lat} #{@lon}"
end