Class: RGeo::CoordSys::SRSDatabase::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/rgeo/coord_sys/srs_database/interface.rb

Overview

An entry in a spatial reference system database. Every entry has an identifier, but all the other attributes are optional and may or may not be present depending on the database.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ident_, data_ = {}) ⇒ Entry

Create an entry. You must provide an identifier, which may be numeric or a string. The data hash should contain any other attributes, keyed by symbol.

Some attribute inputs have special behaviors:

:coord_sys

You can pass a CS coordinate system object, or a string in WKT format.

:proj4

You can pass a Proj4 object, or a proj4-format string.

:name

If the name is not provided directly, it is taken from the coord_sys.

:authority

If the authority name is not provided directly, it is taken from the coord_sys.

:authority_code

If the authority code is not provided directly, it is taken from the coord_sys.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 67

def initialize(ident_, data_ = {})
  @identifier = ident_
  @authority = data_[:authority]
  @authority_code = data_[:authority_code]
  @name = data_[:name]
  @description = data_[:description]
  @coord_sys = data_[:coord_sys]
  if @coord_sys.is_a?(::String)
    @coord_sys = CS.create_from_wkt(@coord_sys)
  end
  @proj4 = data_[:proj4]
  if Proj4.supported?
    if @proj4.is_a?(::String) || @proj4.is_a?(::Hash)
      @proj4 = Proj4.create(@proj4)
    end
  else
    @proj4 = nil
  end
  if @coord_sys
    @name = @coord_sys.name unless @name
    @authority = @coord_sys.authority unless @authority
    @authority_code = @coord_sys.authority unless @authority_code
  end
end

Instance Attribute Details

#authorityObject (readonly)

The authority name, if present. Example: “epsg”.



96
97
98
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 96

def authority
  @authority
end

#authority_codeObject (readonly)

The authority code, e.g. an EPSG code.



99
100
101
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 99

def authority_code
  @authority_code
end

#coord_sysObject (readonly)

The CS::CoordinateSystem object.



108
109
110
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 108

def coord_sys
  @coord_sys
end

#descriptionObject (readonly)

A human-readable description for this coordinate system.



105
106
107
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 105

def description
  @description
end

#identifierObject (readonly)

The database key or identifier.



93
94
95
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 93

def identifier
  @identifier
end

#nameObject (readonly)

A human-readable name for this coordinate system.



102
103
104
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 102

def name
  @name
end

#proj4Object (readonly)

The Proj4 object.



111
112
113
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 111

def proj4
  @proj4
end