Method: GPX::Bounds#add
- Defined in:
- lib/gpx/bounds.rb
#add(item) ⇒ Object
Adds an item to itself, expanding its min/max lat/lon as needed to contain the given item. The item can be either another instance of Bounds or a Point.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gpx/bounds.rb', line 37 def add(item) if item.respond_to?(:lat) && item.respond_to?(:lon) @min_lat = item.lat if item.lat < @min_lat @min_lon = item.lon if item.lon < @min_lon @max_lat = item.lat if item.lat > @max_lat @max_lon = item.lon if item.lon > @max_lon else @min_lat = item.min_lat if item.min_lat < @min_lat @min_lon = item.min_lon if item.min_lon < @min_lon @max_lat = item.max_lat if item.max_lat > @max_lat @max_lon = item.max_lon if item.max_lon > @max_lon end end |