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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12d54845568c88b7000830b89f9cf22dc0dd869f
4
- data.tar.gz: 3724276fae454400abc143894458372ae74f012a
3
+ metadata.gz: 33f03aae748ea34533802aec1d29da649b90e627
4
+ data.tar.gz: 4cb4d085108ec682ee4100d3619dace122676f98
5
5
  SHA512:
6
- metadata.gz: a89ed1be4cc0d2651a61ba9a1cba8bbc5ccf2b83bdf2fec3f2071f29b9ea44c2a0cd172a673a0c05da8645d2370146a0ff9e53d9dfc94ac78124405bf83828e6
7
- data.tar.gz: 2b2fe98324f2e80b6550d5459c63120bebb0a3ed46ac334f10ff0fc9b11689c9a35673c028bafb78679dc159ac4bc833a87598b377c361cdd6650d1056d9720f
6
+ metadata.gz: 9d5d63cb4e0ad3eb0bc35e0a599eb1d1098152016c00209f714dba475593b1e127adc3323d177d6f8f43c1521e0e415a85316b2a891b57f1c39709b3ca793e5c
7
+ data.tar.gz: 86a8f5b31c0551689685de669d490344d5c2fef6cd23ba0a07ae27fa6c8c2f9508352a8c57ca3e0244d14bf9ac0e1e1972291f39dcea40f2b7f4b039cc4902e5
@@ -62,11 +62,11 @@ module OsMapRef
62
62
  end
63
63
 
64
64
  def northing_from_map_reference
65
- northing_easting_from_map_reference[0].to_s + map_reference_parts[2]
65
+ prefix_coordinates[0].to_s + map_reference_parts[2]
66
66
  end
67
67
 
68
68
  def easting_from_map_reference
69
- northing_easting_from_map_reference[1].to_s + map_reference_parts[1]
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 gird element
79
- # matching the map reference start. So 'ST 58901 71053' will return [1, 3]
80
- def northing_easting_from_map_reference
81
- @northing_easting_from_map_reference ||= matrix.index map_reference_parts[0]
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 OI OJ],
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 TI TJ],
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]
@@ -1,3 +1,3 @@
1
1
  module OsMapRef
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler