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

Inherits:
Object
  • Object
show all
Defined in:
lib/rgeo/coord_sys/srs_database/entry.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.


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 61

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 && CoordSys.check!(:proj4)
    if @proj4.is_a?(String) || @proj4.is_a?(Hash)
      @proj4 = Proj4.create(@proj4)
    end
  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”.


88
89
90
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 88

def authority
  @authority
end

#authority_codeObject (readonly)

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


91
92
93
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 91

def authority_code
  @authority_code
end

#coord_sysObject (readonly)

The CS::CoordinateSystem object.


100
101
102
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 100

def coord_sys
  @coord_sys
end

#descriptionObject (readonly)

A human-readable description for this coordinate system.


97
98
99
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 97

def description
  @description
end

#identifierObject (readonly)

The database key or identifier.


85
86
87
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 85

def identifier
  @identifier
end

#nameObject (readonly)

A human-readable name for this coordinate system.


94
95
96
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 94

def name
  @name
end

#proj4Object (readonly)

The Proj4 object.


103
104
105
# File 'lib/rgeo/coord_sys/srs_database/entry.rb', line 103

def proj4
  @proj4
end