geodesic_wgs84 1.32.7 → 1.32.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +17 -4
- data/ext/geodesic_wgs84/geodesic_wgs84.c +23 -56
- data/lib/geodesic_wgs84/version.rb +1 -1
- data/spec/geodesic_wgs84_spec.rb +57 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a421f900057b282fa125e757054177066471301
|
|
4
|
+
data.tar.gz: a6561306299110ffb927339ddc7ea3a436f80c35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b13512d9ae017bec057487c5af896c57bacf40b660fd44705cc311f9c55ad662596f6ad027f3bb4a918196e8a87047b0fa216d60703a387e6e47ea937256a9fb
|
|
7
|
+
data.tar.gz: 30b88b55a54ae2bf0522194968f57a786b6652a00d8789f9f21d81d32ebc6c64a3a89f64084c993626cbb426be727916a1d39be42e0837ab601be1c6b3813a90
|
data/Makefile
CHANGED
|
@@ -3,11 +3,24 @@
|
|
|
3
3
|
# Makefile for building the Gem
|
|
4
4
|
#
|
|
5
5
|
|
|
6
|
-
all:
|
|
6
|
+
all: build
|
|
7
|
+
git status
|
|
8
|
+
|
|
9
|
+
rel: build
|
|
10
|
+
vim lib/geodesic_wgs84/version.rb
|
|
11
|
+
git commit -a
|
|
12
|
+
sudo gem uninstall geodesic_wgs84 --all
|
|
13
|
+
rake release
|
|
14
|
+
|
|
15
|
+
install: build
|
|
16
|
+
git commit -a
|
|
17
|
+
sudo gem uninstall geodesic_wgs84 --all
|
|
18
|
+
sudo rake install
|
|
19
|
+
sudo rm -rf pkg
|
|
20
|
+
|
|
21
|
+
build:
|
|
7
22
|
rake compile
|
|
8
23
|
git add ext
|
|
9
24
|
git add lib
|
|
10
25
|
git add spec
|
|
11
|
-
|
|
12
|
-
git commit -a
|
|
13
|
-
rake release
|
|
26
|
+
|
|
@@ -44,11 +44,10 @@ wgs84_get_value(VALUE arg)
|
|
|
44
44
|
memcpy(buf, RSTRING_PTR(arg), RSTRING_LEN(arg));
|
|
45
45
|
|
|
46
46
|
if (sscanf(buf, "%d.%d.%d,%d", &dd, &mm, &ss, &ff) == 4) {
|
|
47
|
-
|
|
48
|
-
dbl
|
|
49
|
-
dbl
|
|
50
|
-
|
|
51
|
-
sprintf(buf, "%.6f", dbl);
|
|
47
|
+
ff += (dd * 36000) + (mm * 600) + (ss * 10);
|
|
48
|
+
dbl = (double) ff;
|
|
49
|
+
dbl /= 36000.0;
|
|
50
|
+
sprintf(buf, "%.6lf", dbl);
|
|
52
51
|
} else if (sscanf(buf, "%d,%d", &dd, &ff) == 2) {
|
|
53
52
|
*strchr(buf, ',') = '.';
|
|
54
53
|
}
|
|
@@ -73,55 +72,33 @@ wgs84_lat_lon(int argc, VALUE *argv, VALUE klass)
|
|
|
73
72
|
if (argc == 2) {
|
|
74
73
|
lat = wgs84_get_value(argv[0]);
|
|
75
74
|
lon = wgs84_get_value(argv[1]);
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (argc == 1 && TYPE(*argv) == T_ARRAY && RARRAY_LEN(*argv) == 2) {
|
|
75
|
+
} else if (argc == 1 && TYPE(*argv) == T_ARRAY && RARRAY_LEN(*argv) == 2) {
|
|
80
76
|
lat = wgs84_get_value(rb_ary_entry(*argv, 0));
|
|
81
77
|
lon = wgs84_get_value(rb_ary_entry(*argv, 1));
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (argc == 1 && !NIL_P(tmp = rb_check_array_type(*argv))) {
|
|
78
|
+
} else if (argc == 1 && !NIL_P(tmp = rb_check_array_type(*argv))) {
|
|
86
79
|
lat = wgs84_get_value(rb_ary_entry(tmp, 0));
|
|
87
80
|
lon = wgs84_get_value(rb_ary_entry(tmp, 1));
|
|
88
|
-
|
|
81
|
+
} else {
|
|
82
|
+
rb_raise(rb_eArgError, "wrong number of arguments");
|
|
83
|
+
return Qnil;
|
|
89
84
|
}
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
return Qnil;
|
|
86
|
+
return rb_ary_new3(2L, rb_float_new(lat), rb_float_new(lon));
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
|
|
96
90
|
static void
|
|
97
91
|
wgs84_make_dms(double val, char *buf)
|
|
98
92
|
{
|
|
99
|
-
int tmp;
|
|
100
93
|
char *ptr;
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
tmp = (int) val;
|
|
104
|
-
sprintf(buf, "%02d", tmp);
|
|
105
|
-
val -= (double) tmp;
|
|
95
|
+
sprintf(buf, "%d.", (int) trunc(val));
|
|
106
96
|
ptr = buf + strlen(buf);
|
|
107
|
-
|
|
108
|
-
/* get minutes */
|
|
109
|
-
val *= 60.0;
|
|
110
|
-
tmp = (int) val;
|
|
111
|
-
sprintf(ptr, ".%02d", tmp);
|
|
112
|
-
val -= (double) tmp;
|
|
113
|
-
ptr = buf + strlen(buf);
|
|
114
|
-
|
|
115
|
-
/* get seconds */
|
|
116
|
-
val *= 60.0;
|
|
117
|
-
tmp = (int) val;
|
|
118
|
-
sprintf(ptr, ".%02d", tmp);
|
|
119
|
-
val -= (double) tmp;
|
|
97
|
+
sprintf(ptr, "%d.", (int) fmod(trunc(fabs(val) * 60.0), 60.0));
|
|
120
98
|
ptr = buf + strlen(buf);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
sprintf(ptr, ",%.0f", val);
|
|
99
|
+
sprintf(ptr, "%.1lf", fmod(fabs(val) * 3600.0, 60.0));
|
|
100
|
+
if ((ptr = strchr(ptr, '.')) != NULL)
|
|
101
|
+
*ptr = ',';
|
|
125
102
|
}
|
|
126
103
|
|
|
127
104
|
|
|
@@ -129,36 +106,26 @@ static VALUE
|
|
|
129
106
|
wgs84_lat_lon_dms(int argc, VALUE *argv, VALUE klass)
|
|
130
107
|
{
|
|
131
108
|
double lat, lon;
|
|
132
|
-
int valid = 0;
|
|
133
109
|
char lat_buf[64], lon_buf[64];
|
|
134
110
|
VALUE tmp;
|
|
135
111
|
|
|
136
112
|
if (argc == 2) {
|
|
137
113
|
lat = wgs84_get_value(argv[0]);
|
|
138
114
|
lon = wgs84_get_value(argv[1]);
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (argc == 1 && TYPE(*argv) == T_ARRAY && RARRAY_LEN(*argv) == 2) {
|
|
115
|
+
} else if (argc == 1 && TYPE(*argv) == T_ARRAY && RARRAY_LEN(*argv) == 2) {
|
|
143
116
|
lat = wgs84_get_value(rb_ary_entry(*argv, 0));
|
|
144
117
|
lon = wgs84_get_value(rb_ary_entry(*argv, 1));
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (argc == 1 && !NIL_P(tmp = rb_check_array_type(*argv))) {
|
|
118
|
+
} else if (argc == 1 && !NIL_P(tmp = rb_check_array_type(*argv))) {
|
|
149
119
|
lat = wgs84_get_value(rb_ary_entry(tmp, 0));
|
|
150
120
|
lon = wgs84_get_value(rb_ary_entry(tmp, 1));
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (valid == 1) {
|
|
155
|
-
wgs84_make_dms(lat, lat_buf);
|
|
156
|
-
wgs84_make_dms(lon, lon_buf);
|
|
157
|
-
return rb_ary_new3(2L, rb_str_new2(lat_buf), rb_str_new2(lon_buf));
|
|
121
|
+
} else {
|
|
122
|
+
rb_raise(rb_eArgError, "wrong number of arguments");
|
|
123
|
+
return Qnil;
|
|
158
124
|
}
|
|
159
125
|
|
|
160
|
-
|
|
161
|
-
|
|
126
|
+
wgs84_make_dms(lat, lat_buf);
|
|
127
|
+
wgs84_make_dms(lon, lon_buf);
|
|
128
|
+
return rb_ary_new3(2L, rb_str_new2(lat_buf), rb_str_new2(lon_buf));
|
|
162
129
|
}
|
|
163
130
|
|
|
164
131
|
|
data/spec/geodesic_wgs84_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ class TestGeodesicWgs84 < MiniTest::Test
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def test_lat_lon_two_doubles
|
|
10
|
-
assert_equal [
|
|
10
|
+
assert_equal [50.833833, 8.769333], @wgs84.lat_lon(50.833833, 8.769333)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def test_lat_lon_array_of_doubles
|
|
@@ -21,5 +21,61 @@ class TestGeodesicWgs84 < MiniTest::Test
|
|
|
21
21
|
def test_lat_lon_doubles_with_comma
|
|
22
22
|
assert_equal [1.0, 2.0], @wgs84.lat_lon("1,0", "2,0")
|
|
23
23
|
end
|
|
24
|
+
|
|
25
|
+
def test_lat_lon_dms_string
|
|
26
|
+
assert_equal ["50.50.1,8", "8.46.9,6"], @wgs84.lat_lon_dms("50.50.01,8", "08.46.09,6")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_lat_lon_dms_alsfeld
|
|
30
|
+
assert_equal ["50.45.6,4", "9.15.6,7"], @wgs84.lat_lon_dms(50.751778, 9.251861)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_lat_lon_dms_vilbel
|
|
34
|
+
assert_equal ["50.11.31,3", "8.44.5,0"], @wgs84.lat_lon_dms(50.192028, 8.734722)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_lat_lon_dms_butzbach
|
|
38
|
+
assert_equal ["50.25.38,7", "8.40.48,2"], @wgs84.lat_lon_dms(50.427417, 8.680056)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_lat_lon_dms_gilserberg
|
|
42
|
+
assert_equal ["50.56.46,0", "9.4.15,5"], @wgs84.lat_lon_dms(50.946111, 9.070972)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_lat_lon_dms_gruenberg
|
|
46
|
+
assert_equal ["50.36.34,9", "8.54.15,0"], @wgs84.lat_lon_dms(50.609694, 8.904167)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_lat_lon_dms_haiger
|
|
50
|
+
assert_equal ["50.45.42,5", "8.9.24,6"], @wgs84.lat_lon_dms(50.761806, 8.156833)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_lat_lon_dms_herborn
|
|
54
|
+
assert_equal ["50.40.13,2", "8.15.30,8"], @wgs84.lat_lon_dms(50.670333, 8.258556)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_lat_lon_dms_homberg
|
|
58
|
+
assert_equal ["50.44.37,1", "9.1.9,2"], @wgs84.lat_lon_dms(50.743639, 9.019222)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_lat_lon_dms_limburg
|
|
62
|
+
assert_equal ["50.24.20,8", "8.4.56,0"], @wgs84.lat_lon_dms(50.405778, 8.082222)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_lat_lon_dms_marburg
|
|
66
|
+
assert_equal ["50.50.1,8", "8.46.9,6"], @wgs84.lat_lon_dms(50.833833, 8.769333)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_lat_lon_dms_pohlheim
|
|
70
|
+
assert_equal ["50.32.12,6", "8.42.45,0"], @wgs84.lat_lon_dms(50.536833, 8.7125)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_lat_lon_dms_siegen
|
|
74
|
+
assert_equal ["50.51.10,9", "8.0.2,4"], @wgs84.lat_lon_dms(50.853028, 8.000667)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_lat_lon_dms_wetzlar
|
|
78
|
+
assert_equal ["50.33.13,6", "8.29.32,2"], @wgs84.lat_lon_dms(50.553778, 8.492278)
|
|
79
|
+
end
|
|
24
80
|
end
|
|
25
81
|
|