etrstm35fin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +7 -0
- data/etrstm35fin.gemspec +22 -0
- data/lib/etrstm35fin.rb +60 -0
- data/lib/etrstm35fin/version.rb +3 -0
- data/test/etrstm35fin_test.rb +12 -0
- data/test/test_helper.rb +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d02cce8c25217b5dcf05fbedf3b410d59d55f4d5
|
4
|
+
data.tar.gz: 786732f4733b4a6251c0792ed6438ad404137193
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18126b5c3d76123682f96d86b97e021cefbbcccd82ff01d65401aaeae1ebacd0c5e3d1701d0e14ded7bbacb269e4943c3079b43389937a6fdf2d63a427054088
|
7
|
+
data.tar.gz: a9d989f6b7ecdc13f71cdf782809775103da4eed97b65087de854d5b3fe316e6548ddb986773d34304851964104eee81da59c70e246c16e6b41f1c4b065c798a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 kakoni
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Karri Niemelä
|
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,34 @@
|
|
1
|
+
# Etrstm35fin
|
2
|
+
|
3
|
+
Converters coordinates from Finnish ETRS-TM35FIN coordinate system into WGS84.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'etrstm35fin'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install etrstm35fin
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
For given north and east coordinates return latitude and longitude.
|
23
|
+
|
24
|
+
``` ruby
|
25
|
+
Etrstm35fin.to_wgs84(6711804, 240724)
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/[my-github-username]/etrstm35fin/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/etrstm35fin.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'etrstm35fin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "etrstm35fin"
|
8
|
+
spec.version = Etrstm35fin::VERSION
|
9
|
+
spec.authors = ["Karri Niemelä"]
|
10
|
+
spec.email = ["kakoni@gmail.com"]
|
11
|
+
spec.summary = %q{ETRS-TM35FIN to WGS84 coordinates conversion.}
|
12
|
+
spec.homepage = "https://github.com/kakoni/etrstm35fin"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
data/lib/etrstm35fin.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'etrstm35fin/version'
|
2
|
+
require 'cmath'
|
3
|
+
|
4
|
+
module Etrstm35fin
|
5
|
+
WGS84_MAJOR = 6378137.0
|
6
|
+
WGS84_MINOR = 6356752.314245
|
7
|
+
FLATTENING = 1.0 / 298.257223563
|
8
|
+
SCALE_FACTOR = 0.9996
|
9
|
+
FALSE_EASTING = 500000.0
|
10
|
+
FALSE_NORTHING = 0.0
|
11
|
+
CENTRAL_MERIDIAN = 27.0
|
12
|
+
|
13
|
+
def self.to_wgs84(north_coordinate, east_coordinate)
|
14
|
+
central_meridian = to_radians(CENTRAL_MERIDIAN)
|
15
|
+
|
16
|
+
n = FLATTENING / (2.0 - FLATTENING)
|
17
|
+
a1 = WGS84_MAJOR / (1.0 + n) * (1.0 + (n**2.0) / 4.0 + (n**4.0) / 64.0)
|
18
|
+
e = Math.sqrt(2.0 * FLATTENING - (FLATTENING**2.0))
|
19
|
+
h1 = 1.0 / 2.0 * n - 2.0 / 3.0 * (n**2.0) + 37.0/96.0 * (n**3.0) - 1.0/360.0 * (n**4.0)
|
20
|
+
h2 = 1.0 / 48.0 * (n**2.0) + 1.0/15.0 * (n**3.0) - 437.0/1440.0 * (n**4.0)
|
21
|
+
h3 = 17.0 / 480.0 * (n**3.0) - 37.0 / 840.0 * (n**4.0)
|
22
|
+
h4 = 4397.0 / 161280.0 * (n**4.0)
|
23
|
+
|
24
|
+
ee = north_coordinate / (a1 * SCALE_FACTOR)
|
25
|
+
nn = (east_coordinate - FALSE_EASTING) / (a1 * SCALE_FACTOR)
|
26
|
+
|
27
|
+
e1p = h1 * Math.sin(2.0 * ee) * Math.cosh(2.0 * nn)
|
28
|
+
e2p = h2 * Math.sin(4.0 * ee) * Math.cosh(4.0 * nn)
|
29
|
+
e3p = h3 * Math.sin(6.0 * ee) * Math.cosh(6.0 * nn)
|
30
|
+
e4p = h4 * Math.sin(8.0 * ee) * Math.cosh(8.0 * nn)
|
31
|
+
|
32
|
+
nn1p = h1 * Math.cos(2.0 * ee) * Math.sinh(2.0 * nn)
|
33
|
+
nn2p = h2 * Math.cos(4.0 * ee) * Math.sinh(4.0 * nn)
|
34
|
+
nn3p = h3 * Math.cos(6.0 * ee) * Math.sinh(6.0 * nn)
|
35
|
+
nn4p = h4 * Math.cos(8.0 * ee) * Math.sinh(8.0 * nn)
|
36
|
+
|
37
|
+
ep = ee - e1p - e2p - e3p - e4p
|
38
|
+
|
39
|
+
nnp = nn - nn1p - nn2p - nn3p - nn4p
|
40
|
+
be = Math.asin(Math.sin(ep) / Math.cosh(nnp))
|
41
|
+
|
42
|
+
q = CMath.asinh(Math.tan(be))
|
43
|
+
qp = q + e * CMath.atanh(e * Math.tanh(q))
|
44
|
+
qp = q + e * CMath.atanh(e * Math.tanh(qp))
|
45
|
+
qp = q + e * CMath.atanh(e * Math.tanh(qp))
|
46
|
+
qp = q + e * CMath.atanh(e * Math.tanh(qp))
|
47
|
+
|
48
|
+
lat = to_degrees(Math.atan(Math.sinh(qp)))
|
49
|
+
lon = to_degrees(central_meridian + Math.asin(Math.tanh(nnp) / Math.cos(be)))
|
50
|
+
[lat, lon]
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.to_degrees(val)
|
54
|
+
(val * 180.0) / Math::PI
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.to_radians(degree)
|
58
|
+
degree * (Math::PI / 180)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Etrstm35fin do
|
4
|
+
it 'version must be defined' do
|
5
|
+
Etrstm35fin::VERSION.wont_be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should do conversion' do
|
9
|
+
Etrstm35fin.to_wgs84(6711804, 240724).must_equal [60.458829651406916, 22.28345319220464]
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: etrstm35fin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karri Niemelä
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-25 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
|
+
description:
|
42
|
+
email:
|
43
|
+
- kakoni@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- etrstm35fin.gemspec
|
55
|
+
- lib/etrstm35fin.rb
|
56
|
+
- lib/etrstm35fin/version.rb
|
57
|
+
- test/etrstm35fin_test.rb
|
58
|
+
- test/test_helper.rb
|
59
|
+
homepage: https://github.com/kakoni/etrstm35fin
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: ETRS-TM35FIN to WGS84 coordinates conversion.
|
83
|
+
test_files:
|
84
|
+
- test/etrstm35fin_test.rb
|
85
|
+
- test/test_helper.rb
|