geodesic_wgs84 1.32.15 → 1.32.16
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/README.md +4 -0
- data/ext/geodesic_wgs84/geodesic_wgs84.c +38 -0
- data/lib/geodesic_wgs84/version.rb +1 -1
- data/spec/geodesic_wgs84_spec.rb +11 -3
- 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: 484164f90bf349f74e8cce75167b362e751eca85
|
|
4
|
+
data.tar.gz: ec55ae2fe7c28b685d61e1ed0407718f2fad92b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46b492042cc3dc9ffe58af012cba41953b121adc1ff66a029e0b07132a6b0c8875659e0a0d97b0737e1e0a331a76b3cdf8d6b550d71e6a87bf9e3653ec5e517d
|
|
7
|
+
data.tar.gz: a31750e62e7f7eb299c3e4e8b32ce0a408b061f751a52020564290169ab7a33585cfc8de199a1acfaee02d0b8e5fb61b7959936c7c8372cd776cb999b82fc667
|
data/README.md
CHANGED
|
@@ -93,6 +93,42 @@ wgs84_as_dms(VALUE klass, VALUE arg)
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
static VALUE
|
|
97
|
+
wgs84_as_dms_a(VALUE klass, VALUE arg)
|
|
98
|
+
{
|
|
99
|
+
double val;
|
|
100
|
+
char buf[64], *ptr;
|
|
101
|
+
|
|
102
|
+
val = wgs84_get_value(arg);
|
|
103
|
+
memset(buf, 0, sizeof(buf));
|
|
104
|
+
sprintf(buf, "%2d ", (int) trunc(val));
|
|
105
|
+
ptr = buf + strlen(buf);
|
|
106
|
+
sprintf(ptr, "%2d ", (int) fmod(trunc(fabs(val) * 60.0), 60.0));
|
|
107
|
+
ptr = buf + strlen(buf);
|
|
108
|
+
sprintf(ptr, "%4.1lf", fmod(fabs(val) * 3600.0, 60.0));
|
|
109
|
+
|
|
110
|
+
return rb_str_new2(buf);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
static VALUE
|
|
115
|
+
wgs84_as_dms_z(VALUE klass, VALUE arg)
|
|
116
|
+
{
|
|
117
|
+
double val;
|
|
118
|
+
char buf[64], *ptr;
|
|
119
|
+
|
|
120
|
+
val = wgs84_get_value(arg);
|
|
121
|
+
memset(buf, 0, sizeof(buf));
|
|
122
|
+
sprintf(buf, "%02d ", (int) trunc(val));
|
|
123
|
+
ptr = buf + strlen(buf);
|
|
124
|
+
sprintf(ptr, "%02d ", (int) fmod(trunc(fabs(val) * 60.0), 60.0));
|
|
125
|
+
ptr = buf + strlen(buf);
|
|
126
|
+
sprintf(ptr, "%04.1lf", fmod(fabs(val) * 3600.0, 60.0));
|
|
127
|
+
|
|
128
|
+
return rb_str_new2(buf);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
96
132
|
static VALUE
|
|
97
133
|
wgs84_as_bigdec(VALUE klass, VALUE arg)
|
|
98
134
|
{
|
|
@@ -271,6 +307,8 @@ Init_geodesic_wgs84(void)
|
|
|
271
307
|
rb_define_method(cWGS84, "initialize", wgs84_init, 0);
|
|
272
308
|
rb_define_method(cWGS84, "as_deg", wgs84_as_deg, 1);
|
|
273
309
|
rb_define_method(cWGS84, "as_dms", wgs84_as_dms, 1);
|
|
310
|
+
rb_define_method(cWGS84, "as_dms_a", wgs84_as_dms_a, 1);
|
|
311
|
+
rb_define_method(cWGS84, "as_dms_z", wgs84_as_dms_z, 1);
|
|
274
312
|
rb_define_method(cWGS84, "as_bigdec", wgs84_as_bigdec, 1);
|
|
275
313
|
rb_define_method(cWGS84, "lat_lon", wgs84_lat_lon, -1);
|
|
276
314
|
rb_define_method(cWGS84, "distance", wgs84_distance, -1);
|
data/spec/geodesic_wgs84_spec.rb
CHANGED
|
@@ -41,18 +41,26 @@ class TestGeodesicWgs84 < MiniTest::Test
|
|
|
41
41
|
assert_equal 50.833833, @wgs84.as_deg(50.833833)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def
|
|
44
|
+
def test_dms_as_deg
|
|
45
45
|
assert_equal 50.833833, @wgs84.as_deg("50 50 01.8")
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
def
|
|
48
|
+
def test_deg_as_dms
|
|
49
49
|
assert_equal "50 50 1.8", @wgs84.as_dms(50.833833)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def test_dms_as_dms
|
|
53
53
|
assert_equal "50 50 1.8", @wgs84.as_dms("50 50 01.8")
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
def test_deg_as_dms_a
|
|
57
|
+
assert_equal " 9 1 9.2", @wgs84.as_dms_a(9.019222)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_deg_as_dms_z
|
|
61
|
+
assert_equal "09 01 09.2", @wgs84.as_dms_z(9.019222)
|
|
62
|
+
end
|
|
63
|
+
|
|
56
64
|
def test_lat_lon_two_doubles
|
|
57
65
|
assert_equal [50.833833, 8.769333], @wgs84.lat_lon(50.833833, 8.769333)
|
|
58
66
|
end
|