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.


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 110

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.kind_of?(::String)
    @coord_sys = CS.create_from_wkt(@coord_sys)
  end
  @proj4 = data_[:proj4]
  if Proj4.supported?
    if @proj4.kind_of?(::String) || @proj4.kind_of?(::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”.


140
141
142
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 140

def authority
  @authority
end

#authority_codeObject (readonly)

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


143
144
145
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 143

def authority_code
  @authority_code
end

#coord_sysObject (readonly)

The CS::CoordinateSystem object.


152
153
154
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 152

def coord_sys
  @coord_sys
end

#descriptionObject (readonly)

A human-readable description for this coordinate system.


149
150
151
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 149

def description
  @description
end

#identifierObject (readonly)

The database key or identifier.


137
138
139
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 137

def identifier
  @identifier
end

#nameObject (readonly)

A human-readable name for this coordinate system.


146
147
148
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 146

def name
  @name
end

#proj4Object (readonly)

The Proj4 object.


155
156
157
# File 'lib/rgeo/coord_sys/srs_database/interface.rb', line 155

def proj4
  @proj4
end