Class: Opencellid::BBox

Inherits:
Object
  • Object
show all
Defined in:
lib/opencellid/bbox.rb

Overview

A class to simplify the setting the coordinates of a bounding box while calling methods on the OpenCellId API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latmin, lonmin, latmax, lonmax) ⇒ BBox

Returns a new instance of BBox.

Parameters:

  • latmin (Float)

    latmin the latitude of the SW corner of the box

  • lonmin (Float)

    lonmin the longitude of the SW corner of the box

  • latmax (Float)

    latmax the latitude of the NE corner of the box

  • lonmax (Float)

    lonmax the longitude of the NE corner of the box

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
# File 'lib/opencellid/bbox.rb', line 13

def initialize(latmin, lonmin, latmax, lonmax)
  raise ArgumentError, 'latmin must not be nil' unless latmin
  raise ArgumentError, 'lonmin must not be nil' unless lonmin
  raise ArgumentError, 'latmax must not be nil' unless latmax
  raise ArgumentError, 'lonmax must not be nil' unless lonmax
  @latmin = latmin
  @lonmin = lonmin
  @latmax = latmax
  @lonmax = lonmax
end

Instance Attribute Details

#latmaxObject

Returns the value of attribute latmax.



7
8
9
# File 'lib/opencellid/bbox.rb', line 7

def latmax
  @latmax
end

#latminObject

Returns the value of attribute latmin.



7
8
9
# File 'lib/opencellid/bbox.rb', line 7

def latmin
  @latmin
end

#lonmaxObject

Returns the value of attribute lonmax.



7
8
9
# File 'lib/opencellid/bbox.rb', line 7

def lonmax
  @lonmax
end

#lonminObject

Returns the value of attribute lonmin.



7
8
9
# File 'lib/opencellid/bbox.rb', line 7

def lonmin
  @lonmin
end

Instance Method Details

#to_sString

Transforms the coordinates of this bounding box in a format suitable for the OpenCellId API

Returns:

  • (String)

    the coordinates of the bbox is a format compatible with the OpenCellId API



26
27
28
# File 'lib/opencellid/bbox.rb', line 26

def to_s
  "#{latmin},#{lonmin},#{latmax},#{lonmax}"
end