spherical_mercator 1.1.1 → 1.2.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
  SHA256:
3
- metadata.gz: 665ccb30651f974478815cbfc896ee76d310c99c9bf270378c2078033bb4da0c
4
- data.tar.gz: 8406e7fa6f88d8812e6ccd355a1ccbf67a805fb8a74665ac28a1a0945b0b6eb7
3
+ metadata.gz: 3dbf43b62894c3f78d1428ca447dcbfed50177cd5d0a42c960bbd3083d908990
4
+ data.tar.gz: d0426320d9ad903a88ea1bcac75d799940290766e070a7ae7491cd44a774d193
5
5
  SHA512:
6
- metadata.gz: f3e834ae96fce835a4965040e1dd8696241d7222db5e275c4f61c7eec59b28cbec8e4f7a3a90e73b51e66ab0ca7bb6b1c9fda5396040bb84fa877d4574288cc5
7
- data.tar.gz: 4e7a044bc20704dcf933dcd87ebfc5a1fcac1077fe2ac9ed1812d61d682a81f292d5ef020fe39850ca52a0a76d41fb67855065cd3eb8347c32c86bd792a1cab4
6
+ metadata.gz: 783046478b7cfc59ce43d505da9283b1f179b56b4876a65886658a447f64125f066389a63f0ca322ef7837801cf2fd1f307e616c458a1f8374647000fbb28486
7
+ data.tar.gz: beb53639950ecf4a1a2619bb8d66b1fd34a96e37da1fb0055d7fadc1692343cbde9e91fce02a075e05e290858adc348239098436a59ed7789f4dadcbab37df71
data/.travis.yml CHANGED
@@ -8,11 +8,12 @@ rvm:
8
8
  - 2.6
9
9
  - 2.7
10
10
  - 3.0
11
- - jruby-9.0.5.0
12
11
  - jruby-9.1.5.0
13
12
  - jruby-9.1.6.0
13
+ - truffleruby
14
14
  - ruby-head
15
15
  env: JRUBY_OPTS="$JRUBY_OPTS --debug"
16
16
  matrix:
17
17
  allow_failures:
18
18
  - rvm: ruby-head
19
+ - rvm: truffleruby
@@ -7,9 +7,9 @@ class SphericalMercator
7
7
  # Major version number
8
8
  MAJOR = 1
9
9
  # Minor version number
10
- MINOR = 1
10
+ MINOR = 2
11
11
  # Smallest version number
12
- TINY = 1
12
+ TINY = 0
13
13
 
14
14
  # Full version number
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
@@ -3,7 +3,7 @@ require 'spherical_mercator/version'
3
3
  class SphericalMercator
4
4
 
5
5
  attr_reader :options
6
- attr_accessor :size, :round
6
+ attr_accessor :size, :round, :expansion
7
7
 
8
8
  # Closures including constants and other precalculated values.
9
9
 
@@ -25,6 +25,7 @@ class SphericalMercator
25
25
  @options = opts || {}
26
26
 
27
27
  self.size = (options[:size] || 256).to_f
28
+ self.expansion = (options[:antimeridian] == true) ? 2 : 1
28
29
  # Whether to round output values for integer zoom levels. Defaults to true.
29
30
  self.round = (options[:round].nil?) ? true : options[:round]
30
31
 
@@ -74,7 +75,7 @@ class SphericalMercator
74
75
  f = [[Math.sin(D2R * lon_lat[1]), -0.9999].max, 0.9999].min
75
76
  x = d + lon_lat[0] * bc
76
77
  y = d + 0.5 * Math.log((1 + f) / (1 - f)) * -cc
77
- (x > ac) && (x = ac)
78
+ (x > ac * self.expansion) && (x = ac * self.expansion)
78
79
  (y > ac) && (y = ac)
79
80
  # (x < 0) && (x = 0)
80
81
  # (y < 0) && (y = 0)
@@ -85,7 +86,7 @@ class SphericalMercator
85
86
  f = [[Math.sin(D2R * lon_lat[1]), -0.9999].max, 0.9999].min
86
87
  x = (d + lon_lat[0] * @bc[zoom]).round
87
88
  y = (d + 0.5 * Math.log((1 + f) / (1 - f)) * (-@cc[zoom])).round
88
- (x > @ac[zoom]) && (x = @ac[zoom])
89
+ (x > @ac[zoom] * self.expansion) && (x = @ac[zoom] * self.expansion)
89
90
  (y > @ac[zoom]) && (y = @ac[zoom])
90
91
 
91
92
  # (x < 0) && (x = 0)
@@ -19,6 +19,7 @@ end
19
19
  describe SphericalMercator do
20
20
  let!(:sm) { SphericalMercator.new }
21
21
  let!(:sm_round) { SphericalMercator.new(round: false) }
22
+ let!(:antiM) { SphericalMercator.new(antimeridian: true) }
22
23
 
23
24
  context '#bbox' do
24
25
  it '[0,0,0] converted to proper bbox' do
@@ -122,6 +123,22 @@ describe SphericalMercator do
122
123
  it 'PX with forced rounding' do
123
124
  expect(sm_round.px([-179, 85], 9)).to eq([364.0888888888876, 214.68476683766494])
124
125
  end
126
+
127
+ it 'Clamps PX by default when lon >180' do
128
+ expect(sm.px([250, 3], 4)).to eq([4096, 2014])
129
+ end
130
+
131
+ it 'PX with lon > 180 converts when antimeridian=true' do
132
+ expect(antiM.px([250, 3], 4)).to eq([4892, 2014])
133
+ end
134
+
135
+ it 'PX for lon 360 and antimeridian=true' do
136
+ expect(antiM.px([400, 3], 4)).to eq([6599, 2014])
137
+ end
138
+
139
+ it 'Clamps PX when lon >360 and antimeridian=true' do
140
+ expect(antiM.px([400, 3], 4)).to eq([6599, 2014])
141
+ end
125
142
  end
126
143
 
127
144
  context 'high precision float' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spherical_mercator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -63,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubyforge_project:
67
- rubygems_version: 2.7.9
66
+ rubygems_version: 3.0.8
68
67
  signing_key:
69
68
  specification_version: 4
70
69
  summary: Spherical Mercator math in Ruby