stanford-mods 1.3.2 → 1.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a21780e0eb52230a1237022dbe52133a6ffcfb3e
4
- data.tar.gz: 46e8908da12e2fb68a00410a5b634d2f63752249
3
+ metadata.gz: 821295322c2777baac42e0142a690a24b44cf931
4
+ data.tar.gz: 0134f68110a263ddedf3fb9fec7439bedbbad6dd
5
5
  SHA512:
6
- metadata.gz: 73883c77e8c2dde788468eafa93c55e8e9aa19f4bfd61d259439fb08592b180ebc870fe706075fb0722e8970769101ac397ec4740c31bc3a45c54a6aa19585e5
7
- data.tar.gz: 59afb90817a8252a3e9a1d696f7d289dc1874ab3d7ad89bd9fb4cb9800ffc5a4f614e8ed72258cd50edea8fab436d6096931b18b73207688d2c943608496cc16
6
+ metadata.gz: d9976025d220435fc45c4f97901bba4ef506b5e0f3c503b3fb377f3a6a10f4bb74239802abf66fb407c23a121b4339451511485ca94cd06fa620ddec8223fa92
7
+ data.tar.gz: 758b2840f7bb52959d4bf5ffceb0e9d281325ff5adcf848176535aa9b2a81f98386bfdfbcc03374c8b1622b99b3bb01184e38cb66ef460c95187a8272c9ff0cf
@@ -25,20 +25,20 @@ module Stanford
25
25
  private
26
26
 
27
27
  def coord_to_bbox(coord)
28
- matches = coord.match %r{\A(?<lat>[EW].+--.+)\s*/\s*(?<lng>[NS].+--.+)\Z}
28
+ matches = coord.match %r{\A(?<lat>[EW].+-+.+)\s*/\s*(?<lng>[NS].+-+.+)\Z}
29
29
  return unless matches
30
30
 
31
- min_x, max_x = matches['lat'].split('--').map { |x| coord_to_decimal(x) }
32
- max_y, min_y = matches['lng'].split('--').map { |y| coord_to_decimal(y) }
31
+ min_x, max_x = matches['lat'].split(/-+/).map { |x| coord_to_decimal(x) }.minmax
32
+ min_y, max_y = matches['lng'].split(/-+/).map { |y| coord_to_decimal(y) }.minmax
33
33
 
34
- "#{min_x} #{min_y} #{max_x} #{max_y}" if valid_bbox?(min_x, max_x, max_y, min_y)
34
+ "#{min_x} #{min_y} #{max_x} #{max_y}" if valid_bbox?(min_x, max_x, min_y, max_y)
35
35
  end
36
36
 
37
37
  def coord_to_decimal(point)
38
- regex = /(?<dir>[NESW])\s*(?<deg>\d+)°(?:(?<min>\d+)[ʹ'])?(?:(?<sec>\d+)[ʺ"])?/
38
+ regex = /(?<dir>[NESW])\s*(?<deg>\d+)[°⁰º](?:(?<min>\d+)[ʹ'])?(?:(?<sec>\d+)[ʺ"])?/
39
39
  match = regex.match(point)
40
40
 
41
- return Float::NAN unless match
41
+ return Float::INFINITY unless match
42
42
 
43
43
  dec = match['deg'].to_i
44
44
  dec += match['min'].to_f / 60
@@ -48,7 +48,7 @@ module Stanford
48
48
  dec
49
49
  end
50
50
 
51
- def valid_bbox?(min_x, max_x, max_y, min_y)
51
+ def valid_bbox?(min_x, max_x, min_y, max_y)
52
52
  range_x = -180.0..180.0
53
53
  range_y = -90.0..90.0
54
54
 
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  end
6
6
  end
@@ -72,8 +72,16 @@ describe "Cartographic coordinates" do
72
72
  ['-123.38777777777779 38.29805555555556 -122.52277777777778 39.399166666666666'],
73
73
  %(E 10°03'00"--E 12°58'00"/N 45°00'00"--N 41°46'00") =>
74
74
  ['10.05 41.766666666666666 12.966666666666667 45.0'],
75
+ %(E 8°41'-E 12°21'/N 46°04'-N 44°23') =>
76
+ ['8.683333333333334 44.38333333333333 12.35 46.06666666666667'],
77
+ %((E17°--E11°/N14°--N18°).) =>
78
+ ['11.0 14.0 17.0 18.0'], # coordinates need to be reordered
79
+ %((W 170⁰--E 55⁰/N 40⁰--S 36⁰).) =>
80
+ ['-170.0 -36.0 55.0 40.0'], # superscript 0 is almost a degree character..
75
81
  %(W80°--E100°/N487°--S42°) =>
76
82
  [], # N487 is out of bounds for the bounding box
83
+ %((W 0°-W 0°/S 90°---S 90°)) =>
84
+ ['-0.0 -90.0 -0.0 -90.0'], # one dash, two dashes, three dashes.. what's the difference?
77
85
  %(W 650--W 100/N 700--N 550) =>
78
86
  [] # missing degree character, and all coordinates are out of bounds.
79
87
  }.each do |value, expected|
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.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay