isnet93 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7cd115b1d0a3faa6b07f53b0d4837b42e978d243
4
+ data.tar.gz: beb3036ae21548325208089a01d358d05941cb8c
5
+ SHA512:
6
+ metadata.gz: 8bdf2db66bc9e4c2e76fd77fe7e8df222abb64a857677e574995c6c8e6169dc8e52c32a327fd0cb5e59fedc6824f00b432f01dd1eaf4d68a3ddc572fb2561eec
7
+ data.tar.gz: d326509565ed5c08371e61f30c1e6842cbb756d8d51471d74e1e68a479abaf7814cfc7789eca52c357a8f43e02118a9f41efcd86dfc5de8e7fe13e89b9520dcd
Binary file
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in isnet93.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Aitor García
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.
@@ -0,0 +1,49 @@
1
+ # ISNET93
2
+
3
+ ![](https://upload.wikimedia.org/wikipedia/commons/3/36/Isnet93.png)
4
+
5
+ In 1993 some few Icelandic institutions in collaboration with IfAG and IfE in Germany measured a new geodetic reference system in Iceland with GPS technology. This survey campaign was named ISNET93 and the criterion was named ISN93. It's the basis for all geosurveys in Iceland and therefore the base for digital cartography, geographical information systems and construction projects. You can learn more about reasons for its creation [here](http://geoforum.no/lokalavdelinger/sognOgFjordane/filer/foredrag-fra-lokale-plan-og-kartdagar-2011/geodtic-problems-in-iceland/at_download/file).
6
+
7
+ Because of Iceland’s position on the North Atlantic ridge it’s difficult to maintain accurate surveying network for Iceland. The country drifts about 1 cm apart in each direction annually and also earthquakes and volcanic eruptions can cause local distortion on the geodetic reference system. In order to maintain the accuracy of the geodetic reference system, the [NLSI](http://www.lmi.is/en/) regularly re-measure the system.
8
+
9
+ This ruby gem manages **conversion of coordinates between ISNET93 and WGS84**, the standard geodetic system used internationally in cartography, geodesy, and navigation.
10
+
11
+ http://venus.lmi.is/cocodati/cocodati-manual.pdf
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'isnet93'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install isnet93
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ $ irb
32
+ > require "isnet93"
33
+ true
34
+ > Isnet93.to_wgs84(387994, 477755)
35
+ [64.78173836, -21.35577008]
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( http://github.com/linkingpaths/isnet93/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
45
+
46
+
47
+ ## Kudos
48
+
49
+ This library was extracted from the work made by [Linking Paths](http://www.linkingpaths.com) during the first hackathon organized by [Open Knowledge Foundation Iceland](https://www.facebook.com/OKFNis). Documentation on the actual calculations for this conversion was researched via [Cocodati project documentation](http://venus.lmi.is/cocodati/cocodati-manual.pdf) and previous work on the python library [fasteignamat-functions](https://github.com/pallih/fasteignamat-functions) was checked as reference.
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'isnet93/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "isnet93"
8
+ spec.version = Isnet93::VERSION
9
+ spec.authors = ["Aitor García"]
10
+ spec.email = ["aitor@linkingpaths.com"]
11
+ spec.summary = %q{ISNET93 -> WGS84 coordinates conversion.}
12
+ spec.homepage = ""
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.5"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rspec-autotest"
24
+ end
@@ -0,0 +1,58 @@
1
+ require "isnet93/version"
2
+
3
+ module Isnet93
4
+ EARTH_RADIUS = 6378137.0
5
+ FLATTENING = 1/298.257222101
6
+ # According to http://cocodati.lmi.is/cocodati/cocodati-manual.pdf
7
+ LAMBERT_LOWER_PARALLEL = 64.25 # should be 64.15 ¿?
8
+ LAMBERT_UPPER_PARALLEL = 65.75 # should be 65.45 ¿?
9
+ CENTRAL_MERIDIAN_LAT = 65.00
10
+ CENTRAL_MERIDIAN_LNG = 19.00
11
+
12
+ FALSE_NORTHING = 500000.0
13
+ FALSE_EASTING = 500000.0
14
+ EPS = 0.00000000001
15
+
16
+ FIRST_ECCENTRICITY = Math.sqrt(FLATTENING * (2 - FLATTENING))
17
+ RHO = 45/Math.atan2(1.0, 1.0)
18
+
19
+ def self.to_wgs84(east_coordinate, north_coordinate)
20
+ dum = isometric(Math.sin(LAMBERT_LOWER_PARALLEL/RHO)) - isometric(Math.sin(LAMBERT_UPPER_PARALLEL/RHO))
21
+ sint = 2 * (Math.log(fx(LAMBERT_LOWER_PARALLEL)) - Math.log(fx(LAMBERT_UPPER_PARALLEL))) / dum
22
+ f2sin1 = isometric(Math.sin(LAMBERT_LOWER_PARALLEL / RHO))
23
+ pol1 = fx(LAMBERT_LOWER_PARALLEL) / sint
24
+ polc = f3(CENTRAL_MERIDIAN_LAT, pol1, f2sin1, sint) + FALSE_NORTHING
25
+ peq = EARTH_RADIUS * Math.cos(CENTRAL_MERIDIAN_LAT/RHO) / (sint * Math.exp(sint*Math.log((45-CENTRAL_MERIDIAN_LAT/2)/RHO)))
26
+ pol = Math.sqrt(((east_coordinate - FALSE_NORTHING)**2) + ((polc - north_coordinate)**2))
27
+ lat = 90 - 2*RHO*Math.atan(Math.exp(Math.log(pol/peq)/sint))
28
+ fact = RHO * Math.cos(lat/RHO) / sint / pol
29
+ delta = 1.0
30
+ while delta.abs > EPS
31
+ delta = (f3(lat, pol1, f2sin1, sint) - pol) * fact
32
+ lat += delta
33
+ end
34
+ lon = -(CENTRAL_MERIDIAN_LNG + RHO*Math.atan((FALSE_EASTING - east_coordinate)/(polc - north_coordinate))/sint)
35
+
36
+ # http://gis.stackexchange.com/questions/8650/how-to-measure-the-accuracy-of-latitude-and-longitude
37
+ # The eighth decimal place is worth up to 1.1 mm: this is good for charting motions of tectonic
38
+ # plates and movements of volcanoes. Permanent, corrected, constantly-running GPS base stations
39
+ # might be able to achieve this level of accuracy.
40
+ # Max. estimated accuracy of any surveying device.
41
+ [lat.round(8), lon.round(8)]
42
+ end
43
+
44
+ protected
45
+ def self.fx(point)
46
+ EARTH_RADIUS * Math.cos(point/RHO) / Math.sqrt(1-((FIRST_ECCENTRICITY * Math.sin(point/RHO))**2))
47
+ end
48
+ def self.f1(point)
49
+ Math.log((1 - point) / (1 + point))
50
+ end
51
+ def self.isometric(point)
52
+ return f1(point) - FIRST_ECCENTRICITY*f1(FIRST_ECCENTRICITY*point)
53
+ end
54
+ def self.f3(point, pol1, f2sin1, sint)
55
+ iso = isometric(Math.sin(point/RHO))
56
+ pol1 * Math.exp((iso - f2sin1)*sint/2)
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module Isnet93
2
+ VERSION = "0.0.1"
3
+ end
Binary file
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Isnet93 do
4
+ it 'should have a version number' do
5
+ Isnet93::VERSION.should_not be_nil
6
+ end
7
+
8
+ it "should convert to WSG84" do
9
+ Isnet93.to_wgs84(387994, 477755).should == [64.78173836, -21.35577008]
10
+ end
11
+
12
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'isnet93'
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isnet93
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aitor García
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-28 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-autotest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - aitor@linkingpaths.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".DS_Store"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - isnet93.gemspec
84
+ - lib/isnet93.rb
85
+ - lib/isnet93/version.rb
86
+ - spec/.DS_Store
87
+ - spec/isnet93_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.0
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: ISNET93 -> WGS84 coordinates conversion.
113
+ test_files:
114
+ - spec/.DS_Store
115
+ - spec/isnet93_spec.rb
116
+ - spec/spec_helper.rb