# Class: Proj::Coordinate

Inherits:
Object
• Object
show all
Defined in:
lib/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 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, 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(: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)``````
 ``` 25 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``` ```# File 'lib/coordinate.rb', line 25 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, 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 s && a1 && a2 [:s, :a1, :a2] elsif e && n && u [:e, :n, :u] elsif o && p && k [:o, :p, :k] 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/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

### #a1 ⇒ Float

Returns a1 coordinate

Returns:

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

### #a2 ⇒ Float

Returns a2 coordinate

Returns:

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

### #e ⇒ Float

Returns e coordinate

Returns:

• (Float)
 ``` 158 159 160``` ```# File 'lib/coordinate.rb', line 158 def e @coord[:v][0] end```

### #k ⇒ Float

Returns k coordinate

Returns:

• (Float)
 ``` 151 152 153``` ```# File 'lib/coordinate.rb', line 151 def k @coord[:v][3] end```

### #lam ⇒ Float

Returns lam coordinate

Returns:

• (Float)
 ``` 123 124 125``` ```# File 'lib/coordinate.rb', line 123 def lam @coord[:v][0] end```

### #n ⇒ Float

Returns n coordinate

Returns:

• (Float)
 ``` 165 166 167``` ```# File 'lib/coordinate.rb', line 165 def n @coord[:v][1] end```

### #o ⇒ Float

Returns o coordinate

Returns:

• (Float)
 ``` 137 138 139``` ```# File 'lib/coordinate.rb', line 137 def o @coord[:v][0] end```

### #p ⇒ Float

Returns p coordinate

Returns:

• (Float)
 ``` 144 145 146``` ```# File 'lib/coordinate.rb', line 144 def p @coord[:v][1] end```

### #phi ⇒ Float

Returns phi coordinate

Returns:

• (Float)
 ``` 130 131 132``` ```# File 'lib/coordinate.rb', line 130 def phi @coord[:v][1] end```

### #s ⇒ Float

Returns s coordinate

Returns:

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

### #t ⇒ Float

Returns t coordinate

Returns:

• (Float)
 ``` 94 95 96``` ```# File 'lib/coordinate.rb', line 94 def t @coord[:v][3] end```

### #to_ptr ⇒ Object

 ``` 66 67 68``` ```# File 'lib/coordinate.rb', line 66 def to_ptr @coord.to_ptr end```

### #to_s ⇒ String

Returns nice printout of coordinate contents

Returns:

• (String)
 ``` 193 194 195``` ```# File 'lib/coordinate.rb', line 193 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)
 ``` 102 103 104``` ```# File 'lib/coordinate.rb', line 102 def u @coord[:v][0] end```

### #v ⇒ Float

Returns v coordinate

Returns:

• (Float)
 ``` 109 110 111``` ```# File 'lib/coordinate.rb', line 109 def v @coord[:v][1] end```

### #w ⇒ Float

Returns w coordinate

Returns:

• (Float)
 ``` 116 117 118``` ```# File 'lib/coordinate.rb', line 116 def w @coord[:v][2] end```

### #x ⇒ Float

Returns x coordinate

Returns:

• (Float)
 ``` 73 74 75``` ```# File 'lib/coordinate.rb', line 73 def x @coord[:v][0] end```

### #y ⇒ Float

Returns y coordinate

Returns:

• (Float)
 ``` 80 81 82``` ```# File 'lib/coordinate.rb', line 80 def y @coord[:v][1] end```

### #z ⇒ Float

Returns z coordinate

Returns:

• (Float)
 ``` 87 88 89``` ```# File 'lib/coordinate.rb', line 87 def z @coord[:v][2] end```