Class: RGeo::CoordSys::CS::CoordinateSystem

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

Overview

OGC spec description

Base interface for all coordinate systems.

A coordinate system is a mathematical space, where the elements of the space are called positions. Each position is described by a list of numbers. The length of the list corresponds to the dimension of the coordinate system. So in a 2D coordinate system each position is described by a list containing 2 numbers.

However, in a coordinate system, not all lists of numbers correspond to a position – some lists may be outside the domain of the coordinate system. For example, in a 2D Lat/Lon coordinate system, the list (91,91) does not correspond to a position.

Some coordinate systems also have a mapping from the mathematical space into locations in the real world. So in a Lat/Lon coordinate system, the mathematical position (lat, long) corresponds to a location on the surface of the Earth. This mapping from the mathematical space into real-world locations is called a Datum.

Notes

This is a non-instantiable abstract class. You must instantiate one of the subclasses GeocentricCoordinateSystem, GeographicCoordinateSystem, ProjectedCoordinateSystem, VerticalCoordinateSystem, LocalCoordinateSystem, or CompoundCoordinateSystem.

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, dimension, *optional) ⇒ CoordinateSystem

:nodoc:



912
913
914
915
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 912

def initialize(name, dimension, *optional) # :nodoc:
  super(name, *optional)
  @dimension = dimension.to_i
end

Instance Attribute Details

#dimensionObject (readonly)

Dimension of the coordinate system



918
919
920
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 918

def dimension
  @dimension
end

Class Method Details

.create(defn, dimension = 2, *optional) ⇒ Object



954
955
956
957
958
959
960
961
962
963
964
965
966
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 954

def create(defn, dimension = 2, *optional)
  # Need this so we can maintain consistency with actual
  # CoordinateSystem implementations

  if defn.is_a?(Integer)
    # not technically correct but we can use cartesian as a placeholder
    # to form valid wkt
    defn_string = "Cartesian"
    new(defn_string, dimension, "EPSG", defn, *optional)
  else
    new(defn, dimension, *optional)
  end
end

.create_from_wkt(str) ⇒ Object



968
969
970
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 968

def create_from_wkt(str)
  CS.create_from_wkt(str)
end

Instance Method Details

#geographic?Boolean

Returns:

  • (Boolean)


934
935
936
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 934

def geographic?
  false
end

#get_axis(_dimension) ⇒ Object

Gets axis details for dimension within coordinate system. Each dimension in the coordinate system has a corresponding axis.



923
924
925
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 923

def get_axis(_dimension)
  nil
end

#get_units(_dimension) ⇒ Object

Gets units for dimension within coordinate system. Each dimension in the coordinate system has corresponding units.



930
931
932
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 930

def get_units(_dimension)
  nil
end

#projected?Boolean

Returns:

  • (Boolean)


938
939
940
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 938

def projected?
  false
end

#transform_coords(target_cs, x, y, z = nil) ⇒ Object

Not an OGC method, but useful for being able to transform directly from a CoordinateSystem object.



948
949
950
951
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 948

def transform_coords(target_cs, x, y, z = nil)
  ct = CoordinateTransform.create(self, target_cs)
  ct.transform_coords(x, y, z)
end

#wkt_typenameObject



942
943
944
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 942

def wkt_typename
  "CS"
end