Class: RGeo::CoordSys::CS::Base
- Inherits:
-
Object
- Object
- RGeo::CoordSys::CS::Base
- Defined in:
- lib/rgeo/coord_sys/cs/entities.rb
Overview
This is a base class for all OGC coordinate system objects. This includes both interfaces and data types from the OGC Coordinate Transformation spec.
This is a non-instantiable abstract class.
Direct Known Subclasses
Instance Method Summary collapse
-
#encode_with(coder) ⇒ Object
Psych support.
-
#eql?(other) ⇒ Boolean
(also: #==)
Tests for equality.
-
#hash ⇒ Object
Standard hash code.
-
#init_with(coder) ⇒ Object
:nodoc:.
-
#inspect ⇒ Object
Standard object inspection output.
-
#marshal_dump ⇒ Object
Marshal support.
-
#marshal_load(data) ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
Returns the default WKT representation.
-
#to_wkt(standard_brackets: false) ⇒ Object
Return the WKT representation.
Instance Method Details
#encode_with(coder) ⇒ Object
Psych support
219 220 221 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 219 def encode_with(coder) # :nodoc: coder["wkt"] = to_wkt end |
#eql?(other) ⇒ Boolean Also known as: ==
Tests for equality. Two objects are defined as equal if they have the same type (class) and the same WKT representation.
160 161 162 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 160 def eql?(other) other.class == self.class && other.to_wkt == to_wkt end |
#hash ⇒ Object
Standard hash code
167 168 169 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 167 def hash @hash ||= to_wkt.hash end |
#init_with(coder) ⇒ Object
:nodoc:
223 224 225 226 227 228 229 230 231 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 223 def init_with(coder) # :nodoc: temp = CS.create_from_wkt(coder.type == :scalar ? coder.scalar : coder["wkt"]) raise TypeError, "Bad YAML data" unless temp.instance_of?(self.class) temp.instance_variables.each do |iv| instance_variable_set(iv, temp.instance_variable_get(iv)) end end |
#inspect ⇒ Object
Standard object inspection output
153 154 155 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 153 def inspect "#<#{self.class}:0x#{object_id.to_s(16)} #{to_wkt}>" end |
#marshal_dump ⇒ Object
Marshal support
202 203 204 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 202 def marshal_dump # :nodoc: to_wkt end |
#marshal_load(data) ⇒ Object
:nodoc:
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 206 def marshal_load(data) # :nodoc: data = data["wkt"] if data.is_a?(Hash) temp = CS.create_from_wkt(data) raise TypeError, "Bad Marshal data" unless temp.instance_of?(self.class) temp.instance_variables.each do |iv| instance_variable_set(iv, temp.instance_variable_get(iv)) end end |
#to_s ⇒ Object
Returns the default WKT representation.
173 174 175 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 173 def to_s to_wkt end |
#to_wkt(standard_brackets: false) ⇒ Object
Return the WKT representation.
:standard_brackets
If true, outputs parentheses rather than square
brackets. Default is false.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 182 def to_wkt(standard_brackets: false) open, close = brackets(standard_brackets) content = wkt_content(standard_brackets).map { |obj| ",#{obj}" }.join = if defined?(@authority) && @authority ",AUTHORITY#{open}#{@authority.inspect},#{@authority_code.inspect}#{close}" else "" end extensions = if defined?(@extensions) && @extensions @extensions.map { |k, v| ",EXTENSION#{open}#{k.inspect},#{v.inspect}#{close}" }.join else "" end "#{wkt_typename}#{open}#{@name.inspect}#{content}#{extensions}#{}#{close}" end |