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 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_, conversion_factor_, *optional_) ⇒ Unit

:nodoc:


570
571
572
573
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 570

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

Instance Attribute Details

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


579
580
581
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 579

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.


599
600
601
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 599

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

Instance Method Details

#_wkt_content(open_, close_) ⇒ Object

:nodoc:


586
587
588
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 586

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

#_wkt_typenameObject

:nodoc:


582
583
584
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 582

def _wkt_typename  # :nodoc:
  "UNIT"
end