swissgrid 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +34 -3
- data/lib/swissgrid.rb +12 -1
- data/lib/swissgrid/ch1903.rb +50 -20
- data/lib/swissgrid/version.rb +1 -1
- data/lib/swissgrid/wgs84.rb +22 -5
- data/spec/swissgrid_spec.rb +148 -16
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzNhYTA1MDZlMmZkZDg0NzI0OWI3YTRmYjU3YmMxNzZiMDFjYWI5NQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d90a1c3df85723960dc4bd5e3f2d3f7004ff9218
|
4
|
+
data.tar.gz: 9614ca7c3e477e9711ba47d975c55f4e2c662fb4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NGRmNzVlY2M1YWQ2OWNlMGY0ZDdjOTU2ZWQwZTBiYWQxNzhkM2YxY2I3Y2M2
|
11
|
-
NTNkZWI2NzAxNTgxODBiOGI2NDk1OGM1NGIzZDA3NWIyYTMyZjM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjVkNzA4MmUwMzNjNzc1NTIyNDlkN2IzYWY3NTMxMTZlZWMzZGRjMjQwNDFk
|
14
|
-
NDM0MWZiMzFkMmM1MTRkMjc1ZmY3NWI1YTUxYTgyMDAwNWRiNjFlNTQ1NDZm
|
15
|
-
NGFlZDNmY2Y1ZGQ2OGIzNTE0MDhhYjVhMDMyOTE5OWE5OGEyNzI=
|
6
|
+
metadata.gz: f4480b2a45b6d3687870e4aa660e4d2ce9de59bbbdad8f46d003382e480a2ff70e82dc2c8f840ed7f4d43637e747427f74ae1d4d59fd6941f342fe7731530f76
|
7
|
+
data.tar.gz: 65350e51fe8b301e4169798a97b8f27325fd4f554b8eb8bd471158aed440d1b5a790aa672ef0203b503677aa0a29ee24dd6393baabdc8bc0e21a842679db97e8
|
data/README.md
CHANGED
@@ -25,15 +25,42 @@ Require the swissgrid library as follows:
|
|
25
25
|
```ruby
|
26
26
|
require 'swissgrid'
|
27
27
|
```
|
28
|
+
|
29
|
+
###Swissgrid
|
30
|
+
The swissgird library has currently two modules:
|
31
|
+
|
32
|
+
* CH1903 - responsible for CH1903 conversions
|
33
|
+
* WGS84 - responsible for WGS84 conversions
|
34
|
+
|
35
|
+
If other conversions are needed just create an issue or make a pull request :-).
|
36
|
+
|
28
37
|
###From WGS84(GPS) to CH1903
|
38
|
+
A WGS84 point can easily be converted to a CH1903 point as follows:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
wgs84_point = [46.951082877, 7.438632495] # [lat, lon] Bern, The building of exact sciences.
|
42
|
+
ch1903_coord = Swissgrid::CH1903.from_wgs84(wgs84_point)
|
43
|
+
```
|
44
|
+
|
45
|
+
Or just use the following shortcut:
|
29
46
|
|
30
47
|
```ruby
|
31
|
-
|
32
|
-
|
48
|
+
wgs84_point = [46.951082877, 7.438632495] # [lat, lon] Bern, The building of exact sciences.
|
49
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
33
50
|
```
|
34
51
|
###From CH1903 to WGS84(GPS)
|
52
|
+
The same way a CH1903 point can be converted to a WGS84 point:
|
53
|
+
|
54
|
+
```
|
55
|
+
ch1903_point = [600_000, 200_000] # [y, x] Bern, The building of exact sciences.
|
56
|
+
wgs84_coord = Swissgrid::WGS84.from_ch1903(ch1903_point)
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
Or just use the following shortcut:
|
61
|
+
|
35
62
|
```ruby
|
36
|
-
ch1903_point = [
|
63
|
+
ch1903_point = [600_000, 200_000] # [y, x] Bern, The building of exact sciences.
|
37
64
|
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
38
65
|
```
|
39
66
|
|
@@ -49,6 +76,10 @@ require 'swissgrid'
|
|
49
76
|
```
|
50
77
|
|
51
78
|
##Changelog
|
79
|
+
* 0.1.1
|
80
|
+
* Refactor tests and codebase
|
81
|
+
* Update Readme
|
82
|
+
* Add comments
|
52
83
|
* 0.1.0
|
53
84
|
* Fix ch1903 to wgs84 conversion bug. Thanks @christianmeichtry.
|
54
85
|
* 0.0.3
|
data/lib/swissgrid.rb
CHANGED
@@ -4,10 +4,21 @@ require 'swissgrid/wgs84'
|
|
4
4
|
|
5
5
|
module Swissgrid
|
6
6
|
|
7
|
+
|
8
|
+
# Converts a WGS84 point to a CH1903 point.
|
9
|
+
#
|
10
|
+
# @param a_point [List] the WGS84 point to be converted.
|
11
|
+
# @return [List] the converted WGS84 point as CH1903 point.
|
12
|
+
#
|
7
13
|
def self.CH1903(a_point)
|
8
|
-
|
14
|
+
CH1903.from_wgs84(a_point)
|
9
15
|
end
|
10
16
|
|
17
|
+
# Converts a CH1903 point to a WGS84 point.
|
18
|
+
#
|
19
|
+
# @param a_point [List] the CH1903 point to be converted.
|
20
|
+
# @return [List] the converted CH1903 point as WGS84 point.
|
21
|
+
#
|
11
22
|
def self.WGS84(a_point)
|
12
23
|
WGS84.from_ch1903(a_point)
|
13
24
|
end
|
data/lib/swissgrid/ch1903.rb
CHANGED
@@ -1,41 +1,58 @@
|
|
1
1
|
module Swissgrid
|
2
2
|
|
3
|
-
module
|
3
|
+
module CH1903
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# Projection centre Bern
|
6
|
+
PHI_BERN = 169_028.66 # in meters
|
7
|
+
LAMBDA_BERN = 26_782.5 # in meters
|
8
|
+
SCALE = 10_000 # scale to unit 10000"
|
8
9
|
|
10
|
+
|
11
|
+
# Converts a CH1903 point to a WGS84 point.
|
12
|
+
#
|
13
|
+
# @param a_point [List] the CH1903 point to be converted.
|
14
|
+
# @return [List] the converted CH1903 point as WGS84 point.
|
15
|
+
#
|
9
16
|
def self.from_wgs84(a_point)
|
10
17
|
lat, lon, z = a_point
|
11
|
-
phi_sec =
|
12
|
-
lambda_sec =
|
18
|
+
phi_sec = to_arc_seconds(lat)
|
19
|
+
lambda_sec = to_arc_seconds(lon)
|
13
20
|
lambda_prime = (lambda_sec - LAMBDA_BERN) / SCALE.to_f
|
14
21
|
phi_prime = (phi_sec - PHI_BERN) / SCALE.to_f
|
22
|
+
|
23
|
+
# compute WGS84 point
|
15
24
|
convert(lambda_prime, phi_prime, z)
|
16
25
|
end
|
17
26
|
|
27
|
+
|
18
28
|
private
|
19
29
|
|
30
|
+
|
31
|
+
# Computes the WGS84 point by means of the auxiliary parameters lambda', phi' and height h.
|
32
|
+
#
|
33
|
+
# @param lambda_prime [Float] auxiliary parameter lambda'.
|
34
|
+
# @param phi_prime [Float] auxiliary parameter phi'.
|
35
|
+
# @param h [Float] height h.
|
36
|
+
#
|
20
37
|
def self.convert(lambda_prime, phi_prime, h)
|
21
38
|
y = [
|
22
|
-
|
23
|
-
|
24
|
-
-
|
39
|
+
600_072.37,
|
40
|
+
211_455.93 * lambda_prime,
|
41
|
+
-10_938.51 * lambda_prime * phi_prime,
|
25
42
|
-0.36 * lambda_prime * (phi_prime ** 2),
|
26
43
|
-44.54 * (lambda_prime ** 3)
|
27
44
|
].reduce(:+)
|
28
45
|
|
29
46
|
x = [
|
30
|
-
|
31
|
-
|
32
|
-
|
47
|
+
200_147.07,
|
48
|
+
308_807.95 * phi_prime,
|
49
|
+
3_745.25 * (lambda_prime ** 2),
|
33
50
|
76.63 * (phi_prime ** 2),
|
34
51
|
-194.56 * (lambda_prime ** 2) * phi_prime,
|
35
52
|
119.79 * (phi_prime ** 3)
|
36
53
|
].reduce(:+)
|
37
54
|
|
38
|
-
z = if h.nil?
|
55
|
+
z = if h.nil? # if nil do nothing
|
39
56
|
h
|
40
57
|
else
|
41
58
|
[
|
@@ -45,22 +62,35 @@ module Swissgrid
|
|
45
62
|
].reduce(:+)
|
46
63
|
end
|
47
64
|
|
48
|
-
z.nil? ? [y, x] : [y, x, z]
|
65
|
+
z.nil? ? [y, x] : [y, x, z] # if z is nil, remove z component
|
49
66
|
end
|
50
67
|
|
51
68
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
69
|
+
# Converts decimal degrees to a DMS triple that consists of the parts degree, minutes and seconds.
|
70
|
+
#
|
71
|
+
# @param dec_degrees [Float] decimal degrees to be converted.
|
72
|
+
# @return [List] a triple [degree, minutes, seconds].
|
73
|
+
#
|
74
|
+
def self.to_dms_triple(dec_degrees)
|
75
|
+
degrees = dec_degrees.to_i
|
76
|
+
minutes = (60*(dec_degrees - degrees)).to_i
|
77
|
+
seconds = (60*(dec_degrees - degrees) - minutes) * 60
|
56
78
|
[degrees, minutes, seconds]
|
57
79
|
end
|
58
80
|
|
59
|
-
|
60
|
-
|
81
|
+
|
82
|
+
# Converts decimal degrees to arc seconds.
|
83
|
+
#
|
84
|
+
# @param dec_degrees [Float] decimal degrees to be converted.
|
85
|
+
# @return [Float] arc seconds.
|
86
|
+
#
|
87
|
+
def self.to_arc_seconds(dec_degrees)
|
88
|
+
degree, minutes, seconds = to_dms_triple(dec_degrees)
|
61
89
|
degree * 3600 + minutes * 60 + seconds
|
62
90
|
end
|
63
91
|
|
64
92
|
end
|
65
93
|
|
94
|
+
Ch1903 = CH1903 # to be compatible to previous versions
|
95
|
+
|
66
96
|
end
|
data/lib/swissgrid/version.rb
CHANGED
data/lib/swissgrid/wgs84.rb
CHANGED
@@ -2,19 +2,36 @@ module Swissgrid
|
|
2
2
|
|
3
3
|
module WGS84
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# Projection centre Bern
|
6
|
+
Y_BERN = 600_000 # in meters
|
7
|
+
X_BERN = 200_000 # in meters
|
8
|
+
SCALE = 1_000_000 # scale to unit 1000km
|
8
9
|
|
10
|
+
|
11
|
+
# Converts a WGS84 point to a CH1903 point.
|
12
|
+
#
|
13
|
+
# @param a_point [List] the WGS84 point to be converted.
|
14
|
+
# @return [List] the converted WGS84 point as CH1903 point.
|
15
|
+
#
|
9
16
|
def self.from_ch1903(a_point)
|
10
17
|
y, x , z = a_point
|
11
18
|
y_prime = (y - Y_BERN) / SCALE.to_f
|
12
19
|
x_prime = (x - X_BERN) / SCALE.to_f
|
20
|
+
|
21
|
+
# compute CH1903 point
|
13
22
|
convert(y_prime, x_prime, z)
|
14
23
|
end
|
15
24
|
|
25
|
+
|
16
26
|
private
|
17
27
|
|
28
|
+
|
29
|
+
# Computes the CH1903 point by means of the auxiliary parameters y', x' and height h'.
|
30
|
+
#
|
31
|
+
# @param y_prime [Float] auxiliary parameter y'.
|
32
|
+
# @param x_prime [Float] auxiliary parameter x'.
|
33
|
+
# @param h_prime [Float] height h.
|
34
|
+
#
|
18
35
|
def self.convert(y_prime, x_prime, h_prime)
|
19
36
|
lambda_prime = [
|
20
37
|
2.6779094,
|
@@ -33,7 +50,7 @@ module Swissgrid
|
|
33
50
|
-0.0140 * (x_prime ** 3)
|
34
51
|
].reduce(:+)
|
35
52
|
|
36
|
-
z = if h_prime.nil?
|
53
|
+
z = if h_prime.nil? # if nil do nothing
|
37
54
|
h_prime
|
38
55
|
else
|
39
56
|
[
|
@@ -44,7 +61,7 @@ module Swissgrid
|
|
44
61
|
end
|
45
62
|
|
46
63
|
lat, lon = [phi_prime, lambda_prime].map { |v| v * 100/36.to_f }
|
47
|
-
z.nil? ? [lat, lon] : [lat, lon, z]
|
64
|
+
z.nil? ? [lat, lon] : [lat, lon, z] # if z is nil, remove z component
|
48
65
|
end
|
49
66
|
|
50
67
|
end
|
data/spec/swissgrid_spec.rb
CHANGED
@@ -2,32 +2,164 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Swissgrid
|
4
4
|
|
5
|
+
PRECISION_CH1903_TO_WGS84 = 0.1/3600 # Precision in the order of 0.1"
|
6
|
+
PRECISION_WGS84_TO_CH1903 = 1.5 # Precision in the order of 1.5 metre
|
7
|
+
|
5
8
|
describe Swissgrid do
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
#
|
11
|
+
# Test conversion methods directly.
|
12
|
+
#
|
13
|
+
|
14
|
+
describe CH1903 do
|
15
|
+
it "tests from_wgs84" do
|
16
|
+
wgs84_point = [46.881908, 7.471829]
|
17
|
+
expected_ch1903_point = [602_530.221, 192_310.331]
|
18
|
+
ch1903_coord = Swissgrid::CH1903.from_wgs84(wgs84_point)
|
19
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
20
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe WGS84 do
|
25
|
+
it "tests from_ch903" do
|
26
|
+
ch1903_point = [602_530.221, 192_310.331]
|
27
|
+
expected_wgs84_point = [46.881908, 7.471829]
|
28
|
+
wgs84_coord = Swissgrid::WGS84.from_ch1903(ch1903_point)
|
29
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[0])
|
30
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[1])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Test conversion: Zimmerwald CH1903 [602_530.221, 192_310.331] <=> WGS84 [46.881908, 7.471829]
|
36
|
+
#
|
37
|
+
|
38
|
+
it "tests conversion from Zimmerwald wgs84 point to ch1903 point" do
|
39
|
+
wgs84_point = [46.881908, 7.471829]
|
40
|
+
expected_ch1903_point = [602_530.221, 192_310.331]
|
41
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
42
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
43
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it "tests conversion from Zimmerwald ch1903 point to wgs84 point" do
|
48
|
+
ch1903_point = [602_530.221, 192_310.331]
|
49
|
+
expected_wgs84_point = [46.881908, 7.471829]
|
50
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
51
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[0])
|
52
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[1])
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
#
|
57
|
+
# Test conversion: Zuerich CH1903 [683_082.039, 247_793.250] <=> WGS84 [47.375736, 8.538750]
|
58
|
+
#
|
59
|
+
|
60
|
+
it "tests conversion from Zuerich wgs84 point to ch1903 point" do
|
61
|
+
wgs84_point = [47.375736, 8.538750]
|
62
|
+
expected_ch1903_point = [683_082.039, 247_793.250]
|
63
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
64
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
65
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it "tests conversion from Zuerich ch1903 point to wgs84 point" do
|
70
|
+
ch1903_point = [683_082.039, 247_793.250]
|
71
|
+
expected_wgs84_point = [47.375736, 8.538750]
|
72
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
73
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[0])
|
74
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[1])
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
#
|
79
|
+
# Test conversion: Bern CH1903 [600_000, 200_000] <=> WGS84 [46.951082877, 7.438632495]
|
80
|
+
#
|
81
|
+
|
82
|
+
it "tests conversion from Bern wgs84 point to ch1903 point" do
|
83
|
+
wgs84_point = [46.951082877, 7.438632495]
|
84
|
+
expected_ch1903_point = [600_000, 200_000]
|
85
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
86
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
87
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
13
88
|
end
|
14
89
|
|
15
90
|
|
16
|
-
it "tests conversion from ch1903 to wgs84" do
|
91
|
+
it "tests conversion from Bern ch1903 point to wgs84 point" do
|
17
92
|
ch1903_point = [600_000, 200_000]
|
18
|
-
|
19
|
-
|
20
|
-
expect(wgs84_coord[
|
21
|
-
|
93
|
+
expected_wgs84_point = [46.951082877, 7.438632495]
|
94
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
95
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[0])
|
96
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[1])
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
#
|
101
|
+
# Test conversion: Lugano CH1903 [717_665.373, 95_957.362] <=> WGS84 [46.951082877, 7.438632495]
|
102
|
+
#
|
103
|
+
|
104
|
+
it "tests conversion from Lugano wgs84 point to ch1903 point" do
|
105
|
+
wgs84_point = [46.004914, 8.957646]
|
106
|
+
expected_ch1903_point = [717_665.373, 95_957.362]
|
107
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
108
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
109
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
it "tests conversion from Lugano ch1903 point to wgs84 point" do
|
114
|
+
ch1903_point = [717_665.373, 95_957.362]
|
115
|
+
expected_wgs84_point = [46.004914, 8.957646]
|
116
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
117
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[0])
|
118
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs84_point[1])
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
#
|
123
|
+
# Test conversion: Geneva CH1903 [501_000.723, 118_136.350] <=> WGS84 [46.207383, 6.155882]
|
124
|
+
#
|
125
|
+
|
126
|
+
it "tests conversion from Geneva wgs84 point to ch1903 point" do
|
127
|
+
wgs84_point = [46.207383, 6.155882]
|
128
|
+
expected_ch1903_point = [501_000.723, 118_136.350]
|
129
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
130
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
131
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
it "tests conversion from Geneva ch1903 point to wgs84 point" do
|
136
|
+
ch1903_point = [501_000.723, 118_136.350]
|
137
|
+
expected_wgs_point = [46.207383, 6.155882]
|
138
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
139
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs_point[0])
|
140
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs_point[1])
|
22
141
|
end
|
23
142
|
|
24
|
-
|
143
|
+
|
144
|
+
#
|
145
|
+
# Test conversion: Thun CH1903 [611_202, 177_630] <=> WGS84 [46.7497613025, 7.58523830611]
|
146
|
+
#
|
147
|
+
|
148
|
+
it "tests conversion from Thun wgs84 point to ch1903 point" do
|
149
|
+
wgs84_point = [46.7497613025, 7.58523830611]
|
150
|
+
expected_ch1903_point = [611_202, 177_630]
|
151
|
+
ch1903_coord = Swissgrid::CH1903(wgs84_point)
|
152
|
+
expect(ch1903_coord[0]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[0])
|
153
|
+
expect(ch1903_coord[1]).to be_within(PRECISION_WGS84_TO_CH1903).of(expected_ch1903_point[1])
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
it "tests conversion from Thun ch1903 point to wgs84 point" do
|
25
158
|
ch1903_point = [611_202, 177_630]
|
26
159
|
expected_wgs_point = [46.7497613025, 7.58523830611]
|
27
|
-
wgs84_coord =
|
28
|
-
expect(wgs84_coord[0]).to be_within(
|
29
|
-
expect(wgs84_coord[1]).to be_within(
|
30
|
-
pp wgs84_coord
|
160
|
+
wgs84_coord = Swissgrid::WGS84(ch1903_point)
|
161
|
+
expect(wgs84_coord[0]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs_point[0])
|
162
|
+
expect(wgs84_coord[1]).to be_within(PRECISION_CH1903_TO_WGS84).of(expected_wgs_point[1])
|
31
163
|
end
|
32
164
|
|
33
165
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swissgrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Rueedlinger
|
@@ -14,56 +14,56 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-core
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Swissgrid is a library to convert gps points into the Swiss coordinate
|
@@ -74,7 +74,7 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
77
|
+
- ".gitignore"
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
@@ -96,12 +96,12 @@ require_paths:
|
|
96
96
|
- lib
|
97
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
@@ -113,3 +113,4 @@ summary: A library to convert gps points into the Swiss coordinate system (CH190
|
|
113
113
|
test_files:
|
114
114
|
- spec/spec_helper.rb
|
115
115
|
- spec/swissgrid_spec.rb
|
116
|
+
has_rdoc:
|