Class: RGeo::CoordSys::CS::Ellipsoid
- Defined in:
- lib/rgeo/coord_sys/cs/entities.rb
Overview
OGC spec description
An approximation of the Earth’s surface as a squashed sphere.
Instance Attribute Summary collapse
-
#axisunit ⇒ Object
readonly
Returns the LinearUnit.
-
#inverse_flattening ⇒ Object
readonly
Returns the value of the inverse of the flattening constant.
-
#ivf_definitive ⇒ Object
readonly
Is the Inverse Flattening definitive for this ellipsoid? Some ellipsoids use the IVF as the defining value, and calculate the polar radius whenever asked.
-
#semi_major_axis ⇒ Object
readonly
Gets the equatorial radius.
-
#semi_minor_axis ⇒ Object
readonly
Gets the polar radius.
Attributes inherited from Info
#abbreviation, #alias, #authority, #authority_code, #name, #remarks
Class Method Summary collapse
-
.create(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major and semi-minor axes, the inverse flattening, a boolean indicating whether the inverse flattening is definitive, and the LinearUnit indicating the axis units.
-
.create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major and semi-minor axes, and the LinearUnit indicating the axis units.
-
.create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major axis, inverse flattening, and the LinearUnit indicating the axis units.
Instance Method Summary collapse
-
#initialize(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) ⇒ Ellipsoid
constructor
A new instance of Ellipsoid.
- #wkt_typename ⇒ Object
Methods inherited from Info
Methods inherited from Base
#encode_with, #eql?, #hash, #init_with, #inspect, #marshal_dump, #marshal_load, #to_s, #to_wkt
Constructor Details
#initialize(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) ⇒ Ellipsoid
Returns a new instance of Ellipsoid.
608 609 610 611 612 613 614 615 616 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 608 def initialize(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) # :nodoc: super(name, *optional) @semi_major_axis = semi_major_axis.to_f @semi_minor_axis = semi_minor_axis.to_f @inverse_flattening = inverse_flattening.to_f @ivf_definitive = ivf_definitive ? true : false @linear_unit = linear_unit end |
Instance Attribute Details
#axisunit ⇒ Object (readonly)
Returns the LinearUnit. The units of the semi-major and semi-minor axis values.
641 642 643 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 641 def axisunit @axisunit end |
#inverse_flattening ⇒ Object (readonly)
Returns the value of the inverse of the flattening constant. The inverse flattening is related to the equatorial/polar radius by the formula ivf=re/(re-rp). For perfect spheres, this formula breaks down, and a special IVF value of zero is used.
630 631 632 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 630 def inverse_flattening @inverse_flattening end |
#ivf_definitive ⇒ Object (readonly)
Is the Inverse Flattening definitive for this ellipsoid? Some ellipsoids use the IVF as the defining value, and calculate the polar radius whenever asked. Other ellipsoids use the polar radius to calculate the IVF whenever asked. This distinction can be important to avoid floating-point rounding errors.
637 638 639 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 637 def ivf_definitive @ivf_definitive end |
#semi_major_axis ⇒ Object (readonly)
Gets the equatorial radius. The returned length is expressed in this object’s axis units.
620 621 622 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 620 def semi_major_axis @semi_major_axis end |
#semi_minor_axis ⇒ Object (readonly)
Gets the polar radius. The returned length is expressed in this object’s axis units.
624 625 626 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 624 def semi_minor_axis @semi_minor_axis end |
Class Method Details
.create(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major and semi-minor axes, the inverse flattening, a boolean indicating whether the inverse flattening is definitive, and the LinearUnit indicating the axis units. The LinearUnit is optional and may be set to nil. You may also provide the optional parameters specified by the Info interface.
655 656 657 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 655 def create(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) new(name, semi_major_axis, semi_minor_axis, inverse_flattening, ivf_definitive, linear_unit, *optional) end |
.create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major and semi-minor axes, and the LinearUnit indicating the axis units. In the resulting ellipsoid, the inverse flattening is not definitive. The LinearUnit is optional and may be set to nil. You may also provide the optional parameters specified by the Info interface.
665 666 667 668 669 670 671 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 665 def create_ellipsoid(name, semi_major_axis, semi_minor_axis, linear_unit, *optional) semi_major_axis = semi_major_axis.to_f semi_minor_axis = semi_minor_axis.to_f inverse_flattening = semi_major_axis / (semi_major_axis - semi_minor_axis) inverse_flattening = 0.0 if inverse_flattening.infinite? new(name, semi_major_axis, semi_minor_axis, inverse_flattening, false, linear_unit, *optional) end |
.create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit, *optional) ⇒ Object
Create an Ellipsoid given a name, semi-major axis, inverse flattening, and the LinearUnit indicating the axis units. In the resulting ellipsoid, the inverse flattening is definitive. The LinearUnit is optional and may be set to nil. You may also provide the optional parameters specified by the Info interface.
679 680 681 682 683 684 685 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 679 def create_flattened_sphere(name, semi_major_axis, inverse_flattening, linear_unit, *optional) semi_major_axis = semi_major_axis.to_f inverse_flattening = inverse_flattening.to_f semi_minor_axis = semi_major_axis - semi_major_axis / inverse_flattening semi_minor_axis = semi_major_axis if semi_minor_axis.infinite? new(name, semi_major_axis, semi_minor_axis, inverse_flattening, true, linear_unit, *optional) end |
Instance Method Details
#wkt_typename ⇒ Object
643 644 645 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 643 def wkt_typename "SPHEROID" end |