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

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



612
613
614
615
616
617
618
619
620
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 612

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

#axisunitObject (readonly)

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



645
646
647
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 645

def axisunit
  @axisunit
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.



634
635
636
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 634

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.



641
642
643
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 641

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.



624
625
626
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 624

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.



628
629
630
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 628

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.



659
660
661
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 659

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.



669
670
671
672
673
674
675
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 669

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.



683
684
685
686
687
688
689
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 683

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_typenameObject



647
648
649
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 647

def wkt_typename
  "SPHEROID"
end