Class: RGeo::CoordSys::CS::Ellipsoid

Inherits:
Info
  • Object
show all
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

Attributes inherited from Info

#abbreviation, #alias, #authority, #authority_code, #name, #remarks

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Info

#extension

Methods inherited from Base

#_to_wkt, #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

:nodoc:


728
729
730
731
732
733
734
735
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 728

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

#axis_unitObject (readonly)

Returns the LinearUnit. The units of the semi-major and semi-minor axis values.


761
762
763
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 761

def axis_unit
  @axis_unit
end

#inverse_flatteningObject (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.


750
751
752
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 750

def inverse_flattening
  @inverse_flattening
end

#ivf_definitiveObject (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.


757
758
759
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 757

def ivf_definitive
  @ivf_definitive
end

#semi_major_axisObject (readonly)

Gets the equatorial radius. The returned length is expressed in this object's axis units.


740
741
742
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 740

def semi_major_axis
  @semi_major_axis
end

#semi_minor_axisObject (readonly)

Gets the polar radius. The returned length is expressed in this object's axis units.


744
745
746
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 744

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.


783
784
785
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 783

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.


794
795
796
797
798
799
800
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 794

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.


809
810
811
812
813
814
815
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 809

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_content(open_, close_) ⇒ Object

:nodoc:


768
769
770
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 768

def _wkt_content(open_, close_)  # :nodoc:
  [@semi_major_axis, @inverse_flattening]
end

#_wkt_typenameObject

:nodoc:


764
765
766
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 764

def _wkt_typename  # :nodoc:
  "SPHEROID"
end