Class: Geokit::Bounds

Inherits:
Object
  • Object
show all
Defined in:
lib/ttc-gps/models.rb

Instance Method Summary collapse

Instance Method Details

#expand_by_radius(units) ⇒ Object



4
5
6
7
8
# File 'lib/ttc-gps/models.rb', line 4

def expand_by_radius units
  ret = Bounds.new LatLng.new(@sw.lat,@sw.lng), LatLng.new(@ne.lat, @ne.lng)
  ret.expand_by_radius! units
  ret
end

#expand_by_radius!(amount) ⇒ Object



10
11
12
13
14
# File 'lib/ttc-gps/models.rb', line 10

def expand_by_radius! amount
  hyp = (amount*amount * 2)**0.5
  sw = sw.endpoint 225, hyp
  ne = ne.endpoint 45, hyp
end

#to_json(*args) ⇒ Object



16
17
18
19
20
21
# File 'lib/ttc-gps/models.rb', line 16

def to_json *args
  {
    'sw' => @sw,
    'ne' => @ne
  }.to_json(*args)
end