mercator 1.0.0
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 +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +15 -0
- data/bin/sweref99tm +26 -0
- data/lib/mercator/datum.rb +37 -0
- data/lib/mercator/projection.rb +111 -0
- data/lib/mercator/version.rb +3 -0
- data/lib/mercator.rb +91 -0
- data/mercator.gemspec +26 -0
- data/test/mercator_test.rb +71 -0
- data/test/test_helper.rb +2 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6cca620d720fe01a33df60ad7be336c101d6bf20
|
4
|
+
data.tar.gz: 58d92e6603f0924c73e8021da333cfde51999bae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e2f8c94e81762e2955b6eb5ac96b30db451b8e4c3062bb8e1c0c806cfa049d4e4852a435196b0d421e831ab5ba66159fc015988a2c71d5a54068872c8152ab0
|
7
|
+
data.tar.gz: e83e145f2b7eae6b125c28afe37e0dd5d2eeb99712074e014fdc1098f2e01be37d0a5b86f9c5be66a2da480ebd31a7daa2ceef809e3fde3d8e375f339bd57633
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Martin Bergek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Mercator
|
2
|
+
|
3
|
+
This gem include methods to convert between spherical and grid coordinates. It was designed to handle conversions for the Swedish SWEREF99 projection but can be used for any projection based on Gauss conformal projection (transverse Mercator).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mercator'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mercator
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Consider the following code:
|
24
|
+
|
25
|
+
```require 'mercator'
|
26
|
+
datum = Mercator::WGS84.new
|
27
|
+
projection = Mercator::Sweref99TM.new
|
28
|
+
Mercator.grid_to_spherical(6097106.672, 356083.438, datum, projection)
|
29
|
+
```
|
30
|
+
|
31
|
+
Available datums:
|
32
|
+
|
33
|
+
* GRS80
|
34
|
+
* WGS84
|
35
|
+
|
36
|
+
Available projections:
|
37
|
+
|
38
|
+
* SWEREF 99 TM
|
39
|
+
* SWEREF 99 12 00
|
40
|
+
* SWEREF 99 13 30
|
41
|
+
* SWEREF 99 15 00
|
42
|
+
* SWEREF 99 16 30
|
43
|
+
* SWEREF 99 18 00
|
44
|
+
* SWEREF 99 14 15
|
45
|
+
* SWEREF 99 15 45
|
46
|
+
* SWEREF 99 17 15
|
47
|
+
* SWEREF 99 18 45
|
48
|
+
* SWEREF 99 20 15
|
49
|
+
* SWEREF 99 21 45
|
50
|
+
* SWEREF 99 23 15
|
51
|
+
|
52
|
+
To use other datums and projections, instantiate Mercator::Datum and Mercator::Projection objects and assign suitable parameters, e.g. (for SWEREF 99 TM above):
|
53
|
+
|
54
|
+
```datum = Mercator::Datum.new
|
55
|
+
datum.semi_major_axis = 6378137.0
|
56
|
+
datum.inverse_flattening = 298.257223563
|
57
|
+
|
58
|
+
projection = Mercator::Projection.new
|
59
|
+
projection.central_meridian = 15.0
|
60
|
+
projection.scale = 0.9996
|
61
|
+
projection.false_northing = 0.0
|
62
|
+
projection.false_easting = 500000.0
|
63
|
+
```
|
64
|
+
|
65
|
+
For information about the calculations used: http://www.lantmateriet.se/sv/Kartor-och-geografisk-information/GPS-och-geodetisk-matning/Om-geodesi/Kartprojektioner/
|
66
|
+
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it ( https://github.com/mbergek/mercator/fork )
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
# Test
|
4
|
+
require 'rake/testtask'
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.libs << 'test'
|
7
|
+
t.pattern = "test/*_test.rb"
|
8
|
+
t.verbose = true
|
9
|
+
end
|
10
|
+
|
11
|
+
# Console
|
12
|
+
desc "Open an irb session preloaded with this library"
|
13
|
+
task :console do
|
14
|
+
sh "irb -rubygems -I lib -r mercator.rb"
|
15
|
+
end
|
data/bin/sweref99tm
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'mercator'
|
4
|
+
|
5
|
+
if ARGV.length < 2
|
6
|
+
puts <<-END.gsub(/^ {4}/, '')
|
7
|
+
Usage:
|
8
|
+
|
9
|
+
sweref99tm x y
|
10
|
+
|
11
|
+
Where x and y are the grid coordinates using SWEREF 99 TM. This will
|
12
|
+
output the latitude and longitude of the coordinates supplied. No
|
13
|
+
checks will be made as to whether the supplied coordinates are valid
|
14
|
+
or not.
|
15
|
+
|
16
|
+
Example:
|
17
|
+
|
18
|
+
sweref99tm 6097106.672 356083.438
|
19
|
+
|
20
|
+
END
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
datum = Mercator::WGS84.new
|
25
|
+
projection = Mercator::Sweref99TM.new
|
26
|
+
p Mercator.grid_to_spherical(ARGV[0].to_f, ARGV[1].to_f, datum, projection)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Mercator
|
2
|
+
|
3
|
+
# Base datum class. Do not use this class in calculations, instead
|
4
|
+
# use one of the subclasses defined below.
|
5
|
+
|
6
|
+
class Datum
|
7
|
+
attr_accessor :semi_major_axis
|
8
|
+
attr_accessor :semi_minor_axis
|
9
|
+
attr_accessor :inverse_flattening
|
10
|
+
|
11
|
+
def flattening
|
12
|
+
1 / self.inverse_flattening
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# The GRS80 datum, or the Geodetic Reference System 1980.
|
17
|
+
|
18
|
+
class GRS80 < Datum
|
19
|
+
def initialize
|
20
|
+
self.semi_major_axis = 6378137.0
|
21
|
+
self.semi_minor_axis = 6356752.314140
|
22
|
+
self.inverse_flattening = 298.257222100882
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# The WGS84 datum, World Geodetic System 1984
|
27
|
+
|
28
|
+
class WGS84 < Datum
|
29
|
+
def initialize
|
30
|
+
self.semi_major_axis = 6378137.0
|
31
|
+
self.semi_minor_axis = 6356752.314245
|
32
|
+
self.inverse_flattening = 298.257223563
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Mercator
|
2
|
+
|
3
|
+
# Base projection class. Normally you would not use this class in calculations,
|
4
|
+
# instead use one of the subclasses defined below.
|
5
|
+
|
6
|
+
class Projection
|
7
|
+
attr_accessor :central_meridian
|
8
|
+
attr_accessor :scale
|
9
|
+
attr_accessor :false_easting
|
10
|
+
attr_accessor :false_northing
|
11
|
+
end
|
12
|
+
|
13
|
+
# Base SWEREF 99 class that sets some common SWEREF 99 properties.
|
14
|
+
|
15
|
+
class Sweref99 < Projection
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
self.scale = 1.0
|
19
|
+
self.false_northing = 0.0
|
20
|
+
self.false_easting = 150000.0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# SWEREF 99 TM class, one of the most common projection used by
|
25
|
+
# Swedish applications.
|
26
|
+
|
27
|
+
class Sweref99TM < Sweref99
|
28
|
+
def initialize
|
29
|
+
super
|
30
|
+
self.central_meridian = 15.0
|
31
|
+
self.scale = 0.9996
|
32
|
+
self.false_easting = 500000.0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Various regional SWEREF classes for Sweden
|
37
|
+
|
38
|
+
class Sweref991200 < Sweref99
|
39
|
+
def initialize
|
40
|
+
super
|
41
|
+
self.central_meridian = 12.00
|
42
|
+
end
|
43
|
+
end
|
44
|
+
class Sweref991330 < Sweref99
|
45
|
+
def initialize
|
46
|
+
super
|
47
|
+
self.central_meridian = 13.50
|
48
|
+
end
|
49
|
+
end
|
50
|
+
class Sweref991500 < Sweref99
|
51
|
+
def initialize
|
52
|
+
super
|
53
|
+
self.central_meridian = 15.00
|
54
|
+
end
|
55
|
+
end
|
56
|
+
class Sweref991630 < Sweref99
|
57
|
+
def initialize
|
58
|
+
super
|
59
|
+
self.central_meridian = 16.50
|
60
|
+
end
|
61
|
+
end
|
62
|
+
class Sweref991800 < Sweref99
|
63
|
+
def initialize
|
64
|
+
super
|
65
|
+
self.central_meridian = 18.00
|
66
|
+
end
|
67
|
+
end
|
68
|
+
class Sweref991415 < Sweref99
|
69
|
+
def initialize
|
70
|
+
super
|
71
|
+
self.central_meridian = 14.25
|
72
|
+
end
|
73
|
+
end
|
74
|
+
class Sweref991545 < Sweref99
|
75
|
+
def initialize
|
76
|
+
super
|
77
|
+
self.central_meridian = 15.75
|
78
|
+
end
|
79
|
+
end
|
80
|
+
class Sweref991715 < Sweref99
|
81
|
+
def initialize
|
82
|
+
super
|
83
|
+
self.central_meridian = 17.25
|
84
|
+
end
|
85
|
+
end
|
86
|
+
class Sweref991845 < Sweref99
|
87
|
+
def initialize
|
88
|
+
super
|
89
|
+
self.central_meridian = 18.75
|
90
|
+
end
|
91
|
+
end
|
92
|
+
class Sweref992015 < Sweref99
|
93
|
+
def initialize
|
94
|
+
super
|
95
|
+
self.central_meridian = 20.25
|
96
|
+
end
|
97
|
+
end
|
98
|
+
class Sweref992145 < Sweref99
|
99
|
+
def initialize
|
100
|
+
super
|
101
|
+
self.central_meridian = 21.75
|
102
|
+
end
|
103
|
+
end
|
104
|
+
class Sweref992315 < Sweref99
|
105
|
+
def initialize
|
106
|
+
super
|
107
|
+
self.central_meridian = 23.25
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
data/lib/mercator.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require "mercator/version"
|
2
|
+
require "mercator/datum"
|
3
|
+
require "mercator/projection"
|
4
|
+
|
5
|
+
include Math
|
6
|
+
|
7
|
+
|
8
|
+
# The module contains methods to convert between grid
|
9
|
+
# and spherical coordinates. For information about the calculations
|
10
|
+
# used: http://bit.ly/1HGZduL
|
11
|
+
#
|
12
|
+
# Author:: Martin Bergek (mailto:contact@spotwise.com)
|
13
|
+
# Copyright:: Copyright (c) 2015 Martin Bergek
|
14
|
+
# License:: MIT License
|
15
|
+
|
16
|
+
|
17
|
+
module Mercator
|
18
|
+
|
19
|
+
# Convert from spherical coordinates to grid coordinates using the
|
20
|
+
# specified datum and projection.
|
21
|
+
|
22
|
+
def self.spherical_to_grid(latitude, longitude, datum, projection)
|
23
|
+
φ = latitude * PI / 180.0
|
24
|
+
λ = longitude * PI / 180.0
|
25
|
+
λ₀ = projection.central_meridian.to_rad
|
26
|
+
|
27
|
+
e² = datum.flattening * (2 - datum.flattening)
|
28
|
+
n = datum.flattening / (2 - datum.flattening)
|
29
|
+
â = datum.semi_major_axis/(1+n) * (1 + n**2/4 + n**4/64)
|
30
|
+
|
31
|
+
a = e²
|
32
|
+
b = (5*e²**2 - e²**3)/6
|
33
|
+
c = (104*e²**3 - 45*e²**4)/120
|
34
|
+
d = 1237*e²**4/1260
|
35
|
+
|
36
|
+
φ′ = φ - sin(φ)*cos(φ)*(a + b*sin(φ)**2 + c*sin(φ)**4 + d*sin(φ)**6)
|
37
|
+
δ = λ - λ₀
|
38
|
+
|
39
|
+
ξ = atan(tan(φ′) / cos(δ))
|
40
|
+
η = atanh(cos(φ′) * sin(δ))
|
41
|
+
|
42
|
+
β₁ = n/2 - 2*n**2/3 + 5*n**3/16 + 41*n**4/180
|
43
|
+
β₂ = 13*n**2/48 - 3*n**3/5 + 557*n**4/1440
|
44
|
+
β₃ = 61*n**3/240 - 103*n**4/180
|
45
|
+
β₄ = 49561*n**4/161280
|
46
|
+
|
47
|
+
x = projection.scale * â * (ξ + β₁*sin(2*ξ)*cosh(2*η) + β₂*sin(4*ξ)*cosh(4*η) +
|
48
|
+
β₃*sin(6*ξ)*cosh(6*η) + β₄*sin(8*ξ)*cosh(8*η) ) + projection.false_northing
|
49
|
+
y = projection.scale * â * (η + β₁*cos(2*ξ)*sinh(2*η) + β₂*cos(4*ξ)*sinh(4*η) +
|
50
|
+
β₃*cos(6*ξ)*sinh(6*η) + β₄*cos(8*ξ)*sinh(8*η) ) + projection.false_easting
|
51
|
+
|
52
|
+
return [x, y]
|
53
|
+
end
|
54
|
+
|
55
|
+
# Convert from grid coordinates to spherical coordinates using the
|
56
|
+
# specified datum and projection.
|
57
|
+
|
58
|
+
def self.grid_to_spherical(north, east, datum, projection)
|
59
|
+
e² = datum.flattening * (2 - datum.flattening)
|
60
|
+
n = datum.flattening / (2 - datum.flattening)
|
61
|
+
â = datum.semi_major_axis/(1+n) * (1 + n**2/4 + n**4/64)
|
62
|
+
λ₀ = projection.central_meridian * PI / 180.0
|
63
|
+
|
64
|
+
ξ = (north - projection.false_northing) / projection.scale / â
|
65
|
+
η = (east - projection.false_easting) / projection.scale / â
|
66
|
+
|
67
|
+
δ₁ = n/2 - 2*n**2/3 + 37*n**3/96 - n**4/360
|
68
|
+
δ₂ = n**2/48 + n**3/15 - 437*n**4/1440
|
69
|
+
δ₃ = 17*n**3/480 - 37*n**4/840
|
70
|
+
δ₄ = 4397*n**4/161280
|
71
|
+
|
72
|
+
ξ′ = ξ - δ₁*sin(2*ξ)*cosh(2*η) - δ₂*sin(4*ξ)*cosh(4*η) -
|
73
|
+
δ₃*sin(6*ξ)*cosh(6*η) - δ₄*sin(8*ξ)*cosh(8*η)
|
74
|
+
η′ = η - δ₁*cos(2*ξ)*sinh(2*η) - δ₂*cos(4*ξ)*sinh(4*η) -
|
75
|
+
δ₃*cos(6*ξ)*sinh(6*η) - δ₄*cos(8*ξ)*sinh(8*η)
|
76
|
+
|
77
|
+
φ⋆ = asin(sin(ξ′) / cosh(η′))
|
78
|
+
δ = atan(sinh(η′) / cos(ξ′))
|
79
|
+
|
80
|
+
a⋆ = e² + e²**2 + e²**3 + e²**4
|
81
|
+
b⋆ = -1.0/6*(7*e²**2 + 17*e²**3 + 30*e²**4)
|
82
|
+
c⋆ = (224*e²**3 + 889*e²**4)/120
|
83
|
+
d⋆ = -1.0/1260*4279*e²**4
|
84
|
+
|
85
|
+
λ = λ₀ + δ
|
86
|
+
φ = φ⋆ + sin(φ⋆)*cos(φ⋆) * (a⋆ + b⋆*sin(φ⋆)**2 + c⋆*sin(φ⋆)**4 + d⋆*sin(φ⋆)**6)
|
87
|
+
|
88
|
+
return [λ * 180.0 / PI, φ * 180.0 / PI]
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
data/mercator.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mercator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mercator"
|
8
|
+
spec.version = Mercator::VERSION
|
9
|
+
spec.authors = ["Martin Bergek"]
|
10
|
+
spec.email = ["contact@spotwise.com"]
|
11
|
+
spec.summary = %q{Tools to manage spherical to grid conversions}
|
12
|
+
spec.description = %q{This library provides classes and methods to perform conversions between spherical and grid coordinates.}
|
13
|
+
spec.homepage = "https://github.com/mbergek/mercator"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'minitest', '~> 4.7', '>= 4.7.3'
|
24
|
+
spec.add_runtime_dependency 'tilt', '~> 1.4', '>= 1.4.1'
|
25
|
+
spec.add_runtime_dependency 'redcarpet', '~> 3.3', '>= 3.3.2'
|
26
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# http://bit.ly/1HGXANA
|
4
|
+
|
5
|
+
module MiniTest::Assertions
|
6
|
+
def assert_almost_equal(exp, act)
|
7
|
+
if exp.kind_of?(Array) && act.kind_of?(Array)
|
8
|
+
exp.zip(act).each do |obj|
|
9
|
+
assert_in_delta(obj[0], obj[1])
|
10
|
+
end
|
11
|
+
else
|
12
|
+
assert_in_delta(exp, act)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class MercatorTest < Minitest::Unit::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@datum = Mercator::WGS84.new
|
21
|
+
@projection = Mercator::Sweref99TM.new
|
22
|
+
end
|
23
|
+
|
24
|
+
# These are the control points for SWEREF 99 TM as defined on the web page http://bit.ly/1HGXANA
|
25
|
+
def test_grid_to_spherical_55_00_12_45
|
26
|
+
assert_almost_equal [12.75, 55.00], Mercator.grid_to_spherical(6097106.672, 356083.438, @datum, @projection)
|
27
|
+
end
|
28
|
+
def test_grid_to_spherical_55_00_14_15
|
29
|
+
assert_almost_equal [14.25, 55.00], Mercator.grid_to_spherical(6095048.642, 452024.069, @datum, @projection)
|
30
|
+
end
|
31
|
+
def test_grid_to_spherical_57_00_12_45
|
32
|
+
assert_almost_equal [12.75, 57.00], Mercator.grid_to_spherical(6319636.937, 363331.554, @datum, @projection)
|
33
|
+
end
|
34
|
+
def test_grid_to_spherical_57_00_19_30
|
35
|
+
assert_almost_equal [19.50, 57.00], Mercator.grid_to_spherical(6326392.707, 773251.054, @datum, @projection)
|
36
|
+
end
|
37
|
+
def test_grid_to_spherical_59_00_11_15
|
38
|
+
assert_almost_equal [11.25, 59.00], Mercator.grid_to_spherical(6546096.724, 284626.066, @datum, @projection)
|
39
|
+
end
|
40
|
+
def test_grid_to_spherical_59_00_19_30
|
41
|
+
assert_almost_equal [19.50, 59.00], Mercator.grid_to_spherical(6548757.206, 758410.519, @datum, @projection)
|
42
|
+
end
|
43
|
+
def test_grid_to_spherical_61_00_12_45
|
44
|
+
assert_almost_equal [12.75, 61.00], Mercator.grid_to_spherical(6764877.311, 378323.440, @datum, @projection)
|
45
|
+
end
|
46
|
+
def test_grid_to_spherical_61_00_18_45
|
47
|
+
assert_almost_equal [18.75, 61.00], Mercator.grid_to_spherical(6768593.345, 702745.127, @datum, @projection)
|
48
|
+
end
|
49
|
+
def test_grid_to_spherical_63_00_12_00
|
50
|
+
assert_almost_equal [12.00, 63.00], Mercator.grid_to_spherical(6989134.048, 348083.148, @datum, @projection)
|
51
|
+
end
|
52
|
+
def test_grid_to_spherical_63_00_19_30
|
53
|
+
assert_almost_equal [19.50, 63.00], Mercator.grid_to_spherical(6993565.630, 727798.671, @datum, @projection)
|
54
|
+
end
|
55
|
+
def test_grid_to_spherical_65_00_13_30
|
56
|
+
assert_almost_equal [13.50, 65.00], Mercator.grid_to_spherical(7209293.753, 429270.201, @datum, @projection)
|
57
|
+
end
|
58
|
+
def test_grid_to_spherical_65_00_21_45
|
59
|
+
assert_almost_equal [21.75, 65.00], Mercator.grid_to_spherical(7225449.115, 817833.405, @datum, @projection)
|
60
|
+
end
|
61
|
+
def test_grid_to_spherical_67_00_16_30
|
62
|
+
assert_almost_equal [16.50, 67.00], Mercator.grid_to_spherical(7432168.174, 565398.458, @datum, @projection)
|
63
|
+
end
|
64
|
+
def test_grid_to_spherical_67_00_24_00
|
65
|
+
assert_almost_equal [24.00, 67.00], Mercator.grid_to_spherical(7459745.672, 891298.142, @datum, @projection)
|
66
|
+
end
|
67
|
+
def test_grid_to_spherical_69_00_21_00
|
68
|
+
assert_almost_equal [21.00, 69.00], Mercator.grid_to_spherical(7666089.698, 739639.195, @datum, @projection)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mercator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Bergek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.7'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 4.7.3
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '4.7'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 4.7.3
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: tilt
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.4'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.4.1
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.4'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.4.1
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: redcarpet
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '3.3'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.3.2
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.3'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 3.3.2
|
101
|
+
description: This library provides classes and methods to perform conversions between
|
102
|
+
spherical and grid coordinates.
|
103
|
+
email:
|
104
|
+
- contact@spotwise.com
|
105
|
+
executables:
|
106
|
+
- sweref99tm
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/sweref99tm
|
116
|
+
- lib/mercator.rb
|
117
|
+
- lib/mercator/datum.rb
|
118
|
+
- lib/mercator/projection.rb
|
119
|
+
- lib/mercator/version.rb
|
120
|
+
- mercator.gemspec
|
121
|
+
- test/mercator_test.rb
|
122
|
+
- test/test_helper.rb
|
123
|
+
homepage: https://github.com/mbergek/mercator
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.4.5
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Tools to manage spherical to grid conversions
|
147
|
+
test_files:
|
148
|
+
- test/mercator_test.rb
|
149
|
+
- test/test_helper.rb
|