stanford-mods 1.3.0 → 1.3.1
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/.rubocop.yml +3 -0
- data/lib/stanford-mods/geo_spatial.rb +8 -3
- data/lib/stanford-mods/version.rb +1 -1
- data/spec/geo_spatial_spec.rb +17 -0
- 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: 78de4ef412a944f30348ca304d532bc275806ee4
|
4
|
+
data.tar.gz: 3127f3b4e900620d2a130292733957bdb63a685a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d65a7dc751eaff5edc2238935a469c32d1c25d5e3965464e4c56c7019a3f865c4103025188a767e56fd58c01b772a6485945c07e81a6ceeff4b133e1878d4d0
|
7
|
+
data.tar.gz: abf7f4068718169e8afcc61accb4d652c90b18ec8caa1eb7bf0f08740386b39dbbb14a962e00831bbb14a1b211e1eba05b18fb03e804d1ab0be887aec788b086
|
data/.rubocop.yml
CHANGED
@@ -23,16 +23,21 @@ module Stanford
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def coord_to_bbox(coord)
|
26
|
-
|
26
|
+
matches = coord.match %r{(?<lat>.+--.+)\s*/\s*(?<lng>.+--.+)}
|
27
|
+
return unless matches
|
28
|
+
|
29
|
+
min_x, max_x = matches['lat'].split('--').map { |x| coord_to_decimal(x) }
|
30
|
+
max_y, min_y = matches['lng'].split('--').map { |y| coord_to_decimal(y) }
|
27
31
|
|
28
|
-
min_x, max_x = lng.split('--').map { |x| coord_to_decimal(x) }
|
29
|
-
max_y, min_y = lat.split('--').map { |y| coord_to_decimal(y) }
|
30
32
|
"#{min_x} #{min_y} #{max_x} #{max_y}"
|
31
33
|
end
|
32
34
|
|
33
35
|
def coord_to_decimal(point)
|
34
36
|
regex = /(?<dir>[NESW])\s*(?<deg>\d+)°(?:(?<sec>\d+)ʹ)?/
|
35
37
|
match = regex.match(point)
|
38
|
+
|
39
|
+
return unless match
|
40
|
+
|
36
41
|
dec = 0
|
37
42
|
|
38
43
|
dec += match['deg'].to_i
|
data/spec/geo_spatial_spec.rb
CHANGED
@@ -29,6 +29,19 @@ describe "Cartographic coordinates" do
|
|
29
29
|
EOF
|
30
30
|
end
|
31
31
|
|
32
|
+
let(:with_bad_data) do
|
33
|
+
<<-EOF
|
34
|
+
<mods xmlns="#{Mods::MODS_NS}">
|
35
|
+
<subject>
|
36
|
+
<cartographics>
|
37
|
+
<scale>Scale 1:500,000</scale>
|
38
|
+
<coordinates>(Unknown).</coordinates>
|
39
|
+
</cartographics>
|
40
|
+
</subject>
|
41
|
+
</mods>
|
42
|
+
EOF
|
43
|
+
end
|
44
|
+
|
32
45
|
context "coordinates" do
|
33
46
|
it "returns empty array if no coordinates in the mods" do
|
34
47
|
smods_rec.from_str(no_coord)
|
@@ -45,6 +58,10 @@ describe "Cartographic coordinates" do
|
|
45
58
|
smods_rec.from_str(no_coord)
|
46
59
|
expect(smods_rec.point_bbox).to eq([])
|
47
60
|
end
|
61
|
+
it "returns empty array if bad data is in the mods" do
|
62
|
+
smods_rec.from_str(with_bad_data)
|
63
|
+
expect(smods_rec.point_bbox).to eq([])
|
64
|
+
end
|
48
65
|
it "returns decimal representation of latitude and longitude" do
|
49
66
|
smods_rec.from_str(with_coords)
|
50
67
|
expect(smods_rec.point_bbox).to eq(["-16.0 -15.0 28.0 13.0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stanford-mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mods
|