os_map_ref 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/os_map_ref/location.rb +21 -8
- data/lib/os_map_ref/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33f03aae748ea34533802aec1d29da649b90e627
|
4
|
+
data.tar.gz: 4cb4d085108ec682ee4100d3619dace122676f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d5d63cb4e0ad3eb0bc35e0a599eb1d1098152016c00209f714dba475593b1e127adc3323d177d6f8f43c1521e0e415a85316b2a891b57f1c39709b3ca793e5c
|
7
|
+
data.tar.gz: 86a8f5b31c0551689685de669d490344d5c2fef6cd23ba0a07ae27fa6c8c2f9508352a8c57ca3e0244d14bf9ac0e1e1972291f39dcea40f2b7f4b039cc4902e5
|
data/lib/os_map_ref/location.rb
CHANGED
@@ -62,11 +62,11 @@ module OsMapRef
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def northing_from_map_reference
|
65
|
-
|
65
|
+
prefix_coordinates[0].to_s + map_reference_parts[2]
|
66
66
|
end
|
67
67
|
|
68
68
|
def easting_from_map_reference
|
69
|
-
|
69
|
+
prefix_coordinates[1].to_s + map_reference_parts[1]
|
70
70
|
end
|
71
71
|
|
72
72
|
# The parts should be a pair of letters then two sets of numbers
|
@@ -74,11 +74,24 @@ module OsMapRef
|
|
74
74
|
def map_reference_parts
|
75
75
|
@map_reference_parts ||= map_reference.split
|
76
76
|
end
|
77
|
+
|
78
|
+
def prefix
|
79
|
+
map_reference_parts[0]
|
80
|
+
end
|
77
81
|
|
78
|
-
# Returns array of [grid_northing, grid_easting] for the
|
79
|
-
# matching the map reference
|
80
|
-
|
81
|
-
|
82
|
+
# Returns array of [grid_northing, grid_easting] for the grid element
|
83
|
+
# matching the map reference prefix. So 'ST 58901 71053' will return [1, 3]
|
84
|
+
# which are the coordinates of the prefix 'ST' in the grid.
|
85
|
+
def prefix_coordinates
|
86
|
+
@prefix_coordinates ||= get_prefix_coordinates
|
87
|
+
end
|
88
|
+
|
89
|
+
def get_prefix_coordinates
|
90
|
+
matrix.index(prefix) || raise_prefix_error(prefix)
|
91
|
+
end
|
92
|
+
|
93
|
+
def raise_prefix_error(prefix)
|
94
|
+
raise OsMapRef::Error, "Unable to process map reference #{@map_reference}: #{prefix} not found"
|
82
95
|
end
|
83
96
|
|
84
97
|
def matrix
|
@@ -94,12 +107,12 @@ module OsMapRef
|
|
94
107
|
%w[HQ HR HS HT HU JQ JR JS JT JU],
|
95
108
|
%w[HV HW HX HY HZ JV JW JX JY JZ],
|
96
109
|
%w[NA NB NC ND NE OA OB OC OD OE],
|
97
|
-
%w[NF NG NH NJ NK OF OG OH
|
110
|
+
%w[NF NG NH NJ NK OF OG OH OJ OK],
|
98
111
|
%w[NL NM NN NO NP OL OM ON OO OP],
|
99
112
|
%w[NQ NR NS NT NU OQ OR OS OT OU],
|
100
113
|
%w[NV NW NX NY NZ OV OW OX OY OZ],
|
101
114
|
%w[SA SB SC SD SE TA TB TC TD TE],
|
102
|
-
%w[SF SG SH SJ SK TF TG TH
|
115
|
+
%w[SF SG SH SJ SK TF TG TH TJ TK],
|
103
116
|
%w[SL SM SN SO SP TL TM TN TO TP],
|
104
117
|
%w[SQ SR SS ST SU TQ TR TS TT TU],
|
105
118
|
%w[SV SW SX SY SZ TV TW TX TY TZ]
|
data/lib/os_map_ref/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: os_map_ref
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|