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

:nodoc:


608
609
610
611
612
613
614
615
# 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

#axisunitObject (readonly)

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


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

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.


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

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.


636
637
638
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 636

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.


619
620
621
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 619

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.


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

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.


654
655
656
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 654

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.


664
665
666
667
668
669
670
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 664

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.


678
679
680
681
682
683
684
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 678

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


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

def wkt_typename
  "SPHEROID"
end