# Class: Proj::Coordinate

Inherits:
Object
• Object
show all
Defined in:
lib/proj/coordinate.rb

## Overview

A four dimensional coordinate of double values.

For most geographic CRSes, the units will be in degrees.

## Instance Method Summary collapse

• Returns a1 coordinate.

• Returns a2 coordinate.

• Returns e coordinate.

• constructor

Creates a new coordinate.

• Returns k coordinate.

• Returns lam coordinate.

• Returns latitude coordinate.

• Returns longitude coordinate.

• Returns n coordinate.

• Returns o coordinate.

• Returns p coordinate.

• Returns phi coordinate.

• Returns s coordinate.

• Returns t coordinate.

• Returns nice printout of coordinate contents.

• Returns u coordinate.

• Returns v coordinate.

• Returns w coordinate.

• Returns x coordinate.

• Returns y coordinate.

• Returns z coordinate.

## Constructor Details

### #initialize(x: nil, y: nil, z: nil, t: nil, u: nil, v: nil, w: nil, lam: nil, phi: nil, lat: nil, lon: nil, s: nil, a1: nil, a2: nil, o: nil, p: nil, k: nil, e: nil, n: nil) ⇒ Coordinate

Creates a new coordinate.

Examples:

``````
coord = Proj::Coordinate.new(:x => 1, :y => 2, :z => 3, :t => 4)
coord = Proj::Coordinate.new(:u => 5, :v => 6, :w => 7, :t => 8)
coord = Proj::Coordinate.new(:lam => 9, :phi => 10, :z => 11, :t => 12)
coord = Proj::Coordinate.new(:lon => 9, :lat => 10, :z => 11, :t => 12)
coord = Proj::Coordinate.new(:s => 13, :a1 => 14, :a2 => 15)
coord = Proj::Coordinate.new(:o => 16, :p => 17, :k => 18)
coord = Proj::Coordinate.new(:e => 19, :n => 20, :u => 21)``````
 ``` 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74``` ```# File 'lib/proj/coordinate.rb', line 26 def initialize(x: nil, y: nil, z: nil, t: nil, u: nil, v: nil, w: nil, # t: nil lam: nil, phi: nil, # z: nil, t: nil, lat: nil, lon: nil, # z: nil, t: nil, s: nil, a1: nil, a2: nil, o: nil, p: nil, k: nil, e: nil, n: nil) #u: nil @coord = Api::PJ_COORD.new keys = if x && y && z && t [:x, :y, :z, :t] elsif x && y && z [:x, :y, :z] elsif x && y [:x, :y] elsif u && v && w && t [:u, :v, :w, :t] elsif u && v && w [:u, :v, :w] elsif u && v [:u, :v] elsif lam && phi && z && t [:lam, :phi, :z, :t] elsif lam && phi && z [:lam, :phi, :z] elsif lam && phi [:lam, :phi] elsif lon && lat && z && t [:lon, :lat, :z, :t] elsif lon && lat && z [:lon, :lat, :z] elsif lon && lat [:lon, :lat] elsif s && a1 && a2 [:s, :a1, :a2] elsif e && n && u [:e, :n, :u] elsif o && p && k [:o, :p, :k] else [] end coord_struct = @coord[:v] keys.each_with_index do |key, index| coord_struct[index] = binding.local_variable_get(key) end end```

## Class Method Details

### .from_coord(pj_coord) ⇒ Object

 ``` 8 9 10 11 12``` ```# File 'lib/proj/coordinate.rb', line 8 def self.from_coord(pj_coord) result = self.allocate result.instance_variable_set(:@coord, pj_coord) result end```

## Instance Method Details

### #==(other) ⇒ Object

 ``` 88 89 90``` ```# File 'lib/proj/coordinate.rb', line 88 def ==(other) @coord.eql?(other.instance_variable_get(:@coord)) end```

### #a1 ⇒ Float

Returns a1 coordinate

Returns:

• (Float)
 ``` 263 264 265``` ```# File 'lib/proj/coordinate.rb', line 263 def a1 @coord[:v][1] end```

### #a2 ⇒ Float

Returns a2 coordinate

Returns:

• (Float)
 ``` 270 271 272``` ```# File 'lib/proj/coordinate.rb', line 270 def a2 @coord[:v][2] end```

### #e ⇒ Float

Returns e coordinate

Returns:

• (Float)
 ``` 242 243 244``` ```# File 'lib/proj/coordinate.rb', line 242 def e @coord[:v][0] end```

### #enu ⇒ Object

 ``` 92 93 94``` ```# File 'lib/proj/coordinate.rb', line 92 def enu @coord[:enu] end```

### #eql?(other) ⇒ Boolean

Returns:

• (Boolean)
 ``` 84 85 86``` ```# File 'lib/proj/coordinate.rb', line 84 def eql?(other) @coord == other.instance_variable_get(:@coord) end```

### #geod ⇒ Object

 ``` 96 97 98``` ```# File 'lib/proj/coordinate.rb', line 96 def geod @coord[:geod] end```

### #k ⇒ Float

Returns k coordinate

Returns:

• (Float)
 ``` 235 236 237``` ```# File 'lib/proj/coordinate.rb', line 235 def k @coord[:v][3] end```

### #lam ⇒ Float

Returns lam coordinate

Returns:

• (Float)
 ``` 207 208 209``` ```# File 'lib/proj/coordinate.rb', line 207 def lam @coord[:v][0] end```

### #lat ⇒ Float

Returns latitude coordinate

Returns:

• (Float)
 ``` 200 201 202``` ```# File 'lib/proj/coordinate.rb', line 200 def lat @coord[:v][1] end```

### #lon ⇒ Float

Returns longitude coordinate

Returns:

• (Float)
 ``` 193 194 195``` ```# File 'lib/proj/coordinate.rb', line 193 def lon @coord[:v][0] end```

### #lp ⇒ Object

 ``` 100 101 102``` ```# File 'lib/proj/coordinate.rb', line 100 def lp @coord[:lp] end```

### #lpz ⇒ Object

 ``` 104 105 106``` ```# File 'lib/proj/coordinate.rb', line 104 def lpz @coord[:lpz] end```

### #lpzt ⇒ Object

 ``` 108 109 110``` ```# File 'lib/proj/coordinate.rb', line 108 def lpzt @coord[:lpzt] end```

### #n ⇒ Float

Returns n coordinate

Returns:

• (Float)
 ``` 249 250 251``` ```# File 'lib/proj/coordinate.rb', line 249 def n @coord[:v][1] end```

### #o ⇒ Float

Returns o coordinate

Returns:

• (Float)
 ``` 221 222 223``` ```# File 'lib/proj/coordinate.rb', line 221 def o @coord[:v][0] end```

### #opk ⇒ Object

 ``` 112 113 114``` ```# File 'lib/proj/coordinate.rb', line 112 def opk @coord[:opk] end```

### #p ⇒ Float

Returns p coordinate

Returns:

• (Float)
 ``` 228 229 230``` ```# File 'lib/proj/coordinate.rb', line 228 def p @coord[:v][1] end```

### #phi ⇒ Float

Returns phi coordinate

Returns:

• (Float)
 ``` 214 215 216``` ```# File 'lib/proj/coordinate.rb', line 214 def phi @coord[:v][1] end```

### #pj_coord ⇒ Object

 ``` 80 81 82``` ```# File 'lib/proj/coordinate.rb', line 80 def pj_coord @coord end```

### #s ⇒ Float

Returns s coordinate

Returns:

• (Float)
 ``` 256 257 258``` ```# File 'lib/proj/coordinate.rb', line 256 def s @coord[:v][0] end```

### #t ⇒ Float

Returns t coordinate

Returns:

• (Float)
 ``` 164 165 166``` ```# File 'lib/proj/coordinate.rb', line 164 def t @coord[:v][3] end```

### #to_ptr ⇒ Object

 ``` 76 77 78``` ```# File 'lib/proj/coordinate.rb', line 76 def to_ptr @coord.to_ptr end```

### #to_s ⇒ String

Returns nice printout of coordinate contents

Returns:

• (String)
 ``` 277 278 279``` ```# File 'lib/proj/coordinate.rb', line 277 def to_s "v0: #{self.x}, v1: #{self.y}, v2: #{self.z}, v3: #{self.t}" end```

### #u ⇒ Float

Returns u coordinate

TODO - This could be u in uvw or enu. Going to ignore that

Returns:

• (Float)
 ``` 172 173 174``` ```# File 'lib/proj/coordinate.rb', line 172 def u @coord[:v][0] end```

### #uv ⇒ Object

 ``` 116 117 118``` ```# File 'lib/proj/coordinate.rb', line 116 def uv @coord[:uv] end```

### #uvw ⇒ Object

 ``` 120 121 122``` ```# File 'lib/proj/coordinate.rb', line 120 def uvw @coord[:uvw] end```

### #uvwt ⇒ Object

 ``` 124 125 126``` ```# File 'lib/proj/coordinate.rb', line 124 def uvwt @coord[:uvwt] end```

### #v ⇒ Float

Returns v coordinate

Returns:

• (Float)
 ``` 179 180 181``` ```# File 'lib/proj/coordinate.rb', line 179 def v @coord[:v][1] end```

### #w ⇒ Float

Returns w coordinate

Returns:

• (Float)
 ``` 186 187 188``` ```# File 'lib/proj/coordinate.rb', line 186 def w @coord[:v][2] end```

### #x ⇒ Float

Returns x coordinate

Returns:

• (Float)
 ``` 143 144 145``` ```# File 'lib/proj/coordinate.rb', line 143 def x @coord[:v][0] end```

### #xy ⇒ Object

 ``` 128 129 130``` ```# File 'lib/proj/coordinate.rb', line 128 def xy @coord[:xy] end```

### #xyz ⇒ Object

 ``` 132 133 134``` ```# File 'lib/proj/coordinate.rb', line 132 def xyz @coord[:xyz] end```

### #xyzt ⇒ Object

 ``` 136 137 138``` ```# File 'lib/proj/coordinate.rb', line 136 def xyzt @coord[:xyzt] end```

### #y ⇒ Float

Returns y coordinate

Returns:

• (Float)
 ``` 150 151 152``` ```# File 'lib/proj/coordinate.rb', line 150 def y @coord[:v][1] end```

### #z ⇒ Float

Returns z coordinate

Returns:

• (Float)
 ``` 157 158 159``` ```# File 'lib/proj/coordinate.rb', line 157 def z @coord[:v][2] end```