Class: RGeo::CoordSys::CS::Unit

Inherits:
Info
  • Object
show all
Defined in:
lib/rgeo/coord_sys/cs/entities.rb

Overview

OGC spec description

Base interface for defining units.

Notes

Normally, you will instantiate one of the subclasses LinearUnit or AngularUnit. However, it is possible to instantiate Unit if it is not clear whether the data refers to a LinearUnit or AngularUnit.

Direct Known Subclasses

AngularUnit, LinearUnit

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 Base

#_to_wkt, #eql?, #inspect, #to_s, #to_wkt

Constructor Details

#initialize(name_, conversion_factor_, *optional_) ⇒ Unit

:nodoc:



503
504
505
506
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 503

def initialize(name_, conversion_factor_, *optional_)  # :nodoc:
  super(name_, *optional_)
  @conversion_factor = conversion_factor_.to_f
end

Instance Attribute Details

#conversion_factor ⇒ Object (readonly)

This field is not part of the OGC CT spec, but is part of the SFS. It is an alias of the appropriate field in the subclass, i.e. LinearUnit#meters_per_unit or AngularUnit#radians_per_unit.



512
513
514
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 512

def conversion_factor
  @conversion_factor
end

Class Method Details

.create(name_, conversion_factor_, *optional_) ⇒ Object

Create a bare Unit that does not specify whether it is a LinearUnit or an AngularUnit, given a unit name and a conversion factor. You may also provide the optional parameters specified by the Info interface.



532
533
534
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 532

def create(name_, conversion_factor_, *optional_)
  new(name_, conversion_factor_, *optional_)
end

Instance Method Details

#_wkt_content(open_, close_) ⇒ Object

:nodoc:



519
520
521
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 519

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

#_wkt_typename ⇒ Object

:nodoc:



515
516
517
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 515

def _wkt_typename  # :nodoc:
  "UNIT"
end