CUTM 0.1.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 +123 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +16 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cutm.gemspec +36 -0
- data/ext/cutm/extconf.rb +2 -0
- data/ext/cutm/glue.c +33 -0
- data/ext/cutm/utm.c +122 -0
- data/lib/cutm/version.rb +3 -0
- data/lib/cutm.rb +5 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bb9c185d8daa9d7b72a101a58ae609d3928274b40202da306fb5a3bf82d73c4e
|
|
4
|
+
data.tar.gz: faaa7b9221834868db216ea5a99e92c338043d851606f9ba2664b27c613937c4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e43bd147a6b41f4d3a26365dd49c54eadaef81f5385c04537796f1d1cf45742e3792e7f7db39f55da3425fdf1129f2c01bfeaa58f50e01d239b9ad0ae3b4207d
|
|
7
|
+
data.tar.gz: 769ea8379e4b05b7fd45b6dad71e2df912edd496941fe3b48e5161c62b1e5f2b6d7da12b27c55e151079540b28baf4318ec326f748bb37f0f16bcd44116392a9
|
data/.gitignore
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Gemfile.lock
|
|
2
|
+
|
|
3
|
+
/ext/cutm/Makefile
|
|
4
|
+
|
|
5
|
+
/.bundle/
|
|
6
|
+
/.yardoc
|
|
7
|
+
/_yardoc/
|
|
8
|
+
/coverage/
|
|
9
|
+
/doc/
|
|
10
|
+
/pkg/
|
|
11
|
+
/spec/reports/
|
|
12
|
+
/tmp/
|
|
13
|
+
|
|
14
|
+
### https://raw.github.com/github/gitignore/9e018473e80cf262d25841facbbd69e7f1a4ef41/C.gitignore
|
|
15
|
+
|
|
16
|
+
# Prerequisites
|
|
17
|
+
*.d
|
|
18
|
+
|
|
19
|
+
# Object files
|
|
20
|
+
*.o
|
|
21
|
+
*.ko
|
|
22
|
+
*.obj
|
|
23
|
+
*.elf
|
|
24
|
+
|
|
25
|
+
# Linker output
|
|
26
|
+
*.ilk
|
|
27
|
+
*.map
|
|
28
|
+
*.exp
|
|
29
|
+
|
|
30
|
+
# Precompiled Headers
|
|
31
|
+
*.gch
|
|
32
|
+
*.pch
|
|
33
|
+
|
|
34
|
+
# Libraries
|
|
35
|
+
*.lib
|
|
36
|
+
*.a
|
|
37
|
+
*.la
|
|
38
|
+
*.lo
|
|
39
|
+
|
|
40
|
+
# Shared objects (inc. Windows DLLs)
|
|
41
|
+
*.dll
|
|
42
|
+
*.so
|
|
43
|
+
*.so.*
|
|
44
|
+
*.dylib
|
|
45
|
+
|
|
46
|
+
# Executables
|
|
47
|
+
*.exe
|
|
48
|
+
*.out
|
|
49
|
+
*.app
|
|
50
|
+
*.i*86
|
|
51
|
+
*.x86_64
|
|
52
|
+
*.hex
|
|
53
|
+
|
|
54
|
+
# Debug files
|
|
55
|
+
*.dSYM/
|
|
56
|
+
*.su
|
|
57
|
+
*.idb
|
|
58
|
+
*.pdb
|
|
59
|
+
|
|
60
|
+
# Kernel Module Compile Results
|
|
61
|
+
*.mod*
|
|
62
|
+
*.cmd
|
|
63
|
+
.tmp_versions/
|
|
64
|
+
modules.order
|
|
65
|
+
Module.symvers
|
|
66
|
+
Mkfile.old
|
|
67
|
+
dkms.conf
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### https://raw.github.com/github/gitignore/9e018473e80cf262d25841facbbd69e7f1a4ef41/Ruby.gitignore
|
|
71
|
+
|
|
72
|
+
*.gem
|
|
73
|
+
*.rbc
|
|
74
|
+
/.config
|
|
75
|
+
/coverage/
|
|
76
|
+
/InstalledFiles
|
|
77
|
+
/pkg/
|
|
78
|
+
/spec/reports/
|
|
79
|
+
/spec/examples.txt
|
|
80
|
+
/test/tmp/
|
|
81
|
+
/test/version_tmp/
|
|
82
|
+
/tmp/
|
|
83
|
+
|
|
84
|
+
# Used by dotenv library to load environment variables.
|
|
85
|
+
# .env
|
|
86
|
+
|
|
87
|
+
## Specific to RubyMotion:
|
|
88
|
+
.dat*
|
|
89
|
+
.repl_history
|
|
90
|
+
build/
|
|
91
|
+
*.bridgesupport
|
|
92
|
+
build-iPhoneOS/
|
|
93
|
+
build-iPhoneSimulator/
|
|
94
|
+
|
|
95
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
96
|
+
#
|
|
97
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
98
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
99
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
100
|
+
#
|
|
101
|
+
# vendor/Pods/
|
|
102
|
+
|
|
103
|
+
## Documentation cache and generated files:
|
|
104
|
+
/.yardoc/
|
|
105
|
+
/_yardoc/
|
|
106
|
+
/doc/
|
|
107
|
+
/rdoc/
|
|
108
|
+
|
|
109
|
+
## Environment normalization:
|
|
110
|
+
/.bundle/
|
|
111
|
+
/vendor/bundle
|
|
112
|
+
/lib/bundler/man/
|
|
113
|
+
|
|
114
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
115
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
116
|
+
# Gemfile.lock
|
|
117
|
+
# .ruby-version
|
|
118
|
+
# .ruby-gemset
|
|
119
|
+
|
|
120
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
121
|
+
.rvmrc
|
|
122
|
+
|
|
123
|
+
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at yamaguchi@vic.co.jp. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Takafumi Yamaguchi, Kazufusa Ishibashi, Visible Information Center, inc.
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
CUTM
|
|
2
|
+
====
|
|
3
|
+
|
|
4
|
+
緯度/経度とUTM(zone: 54)の距離座標値の相互変換機能を提供する Ruby ライブラリ.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Example
|
|
9
|
+
----
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'cutm'
|
|
13
|
+
|
|
14
|
+
lat = 137.553733
|
|
15
|
+
lon = 36.10673
|
|
16
|
+
|
|
17
|
+
x, y = CUTM.conv2UTM(lat, lon)
|
|
18
|
+
#=> [0] 189757.60553051817,
|
|
19
|
+
# [1] 4001288.6214147597
|
|
20
|
+
|
|
21
|
+
lat2, lon2 = CUTM.conv2DEG(x, y)
|
|
22
|
+
#=> [0] 137.55373300007014,
|
|
23
|
+
# [1] 36.10673000180303
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Build extention
|
|
28
|
+
----
|
|
29
|
+
|
|
30
|
+
手動でC拡張をビルドする方法(`CUTM.so` が得られる):
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
$ cd ext/cutm
|
|
34
|
+
$ ruby extconf.rb
|
|
35
|
+
$ make
|
|
36
|
+
```
|
|
37
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
require "rake/extensiontask"
|
|
4
|
+
|
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
|
6
|
+
t.libs << "test"
|
|
7
|
+
t.libs << "lib"
|
|
8
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
task :default => :test
|
|
12
|
+
|
|
13
|
+
Rake::ExtensionTask.new "CUTM" do |ext|
|
|
14
|
+
ext.ext_dir = "ext/cutm"
|
|
15
|
+
ext.lib_dir = "lib/cutm"
|
|
16
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "cutm"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/cutm.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "cutm/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "CUTM"
|
|
7
|
+
spec.version = CUTM::VERSION
|
|
8
|
+
spec.authors = ["Kazufusa Ishibashi", "Takafumi Yamaguchi"]
|
|
9
|
+
spec.email = ["tkfm.yamaguchi@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{Converts Lon/Lat to UTM(54) coordinates, vise versa.}
|
|
12
|
+
spec.description = %q{Provides convertion functions between Lon/Lat and UTM(54) coordinates}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.extensions = %w[ext/cutm/extconf.rb]
|
|
16
|
+
|
|
17
|
+
# # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# # to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
# "public gem pushes."
|
|
24
|
+
# end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
# spec.bindir = "exe"
|
|
30
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
36
|
+
end
|
data/ext/cutm/extconf.rb
ADDED
data/ext/cutm/glue.c
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#include <ruby.h>
|
|
2
|
+
|
|
3
|
+
double latlon2xy(double latlon[], double xy[]);
|
|
4
|
+
double xy2latlon(double xy[], double latlon[]);
|
|
5
|
+
|
|
6
|
+
VALUE wrap_latlon2xy(VALUE self, VALUE lon, VALUE lat){
|
|
7
|
+
double latlon[2] = {NUM2DBL(lat), NUM2DBL(lon)};
|
|
8
|
+
double xy[2];
|
|
9
|
+
VALUE result;
|
|
10
|
+
|
|
11
|
+
latlon2xy(latlon, xy);
|
|
12
|
+
|
|
13
|
+
result = rb_ary_new3(2, rb_float_new(xy[0]), rb_float_new(xy[1]));
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
VALUE wrap_xy2latlon(VALUE self, VALUE x, VALUE y){
|
|
18
|
+
double xy[2] = {NUM2DBL(x), NUM2DBL(y)};
|
|
19
|
+
double latlon[2];
|
|
20
|
+
VALUE result;
|
|
21
|
+
|
|
22
|
+
xy2latlon(xy, latlon);
|
|
23
|
+
|
|
24
|
+
result = rb_ary_new3(2, rb_float_new(latlon[1]), rb_float_new(latlon[0]));
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void Init_CUTM(){
|
|
29
|
+
VALUE module;
|
|
30
|
+
module = rb_define_module("CUTM");
|
|
31
|
+
rb_define_module_function(module, "conv2UTM", wrap_latlon2xy, 2);
|
|
32
|
+
rb_define_module_function(module, "conv2DEG", wrap_xy2latlon, 2);
|
|
33
|
+
}
|
data/ext/cutm/utm.c
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#define __USE_MISC
|
|
2
|
+
#include <math.h>
|
|
3
|
+
#include <stdio.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
#define zone (54)
|
|
7
|
+
|
|
8
|
+
#define DEG2RAD (1.0 / 180.0 * M_PI)
|
|
9
|
+
|
|
10
|
+
// UTMゾーン中央の子午線の経度[rd]
|
|
11
|
+
#define LON0 ((zone * 6 - 183.0) * DEG2RAD)
|
|
12
|
+
|
|
13
|
+
// UTM座標原点のオフセット(X)[m]
|
|
14
|
+
#define N0 (0.0)
|
|
15
|
+
|
|
16
|
+
// UTM座標原点のオフセット(Y)[m]
|
|
17
|
+
#define E0 (500000.0)
|
|
18
|
+
|
|
19
|
+
// UTM縮尺係数
|
|
20
|
+
#define K0 (0.9996)
|
|
21
|
+
|
|
22
|
+
// 地球楕円体の長半径[m] (GRS80)
|
|
23
|
+
#define EEA (6378137.0)
|
|
24
|
+
|
|
25
|
+
// 扁平率 (GRS80)
|
|
26
|
+
#define EEF (1.0 / 298.257222101)
|
|
27
|
+
|
|
28
|
+
// 第三扁平率
|
|
29
|
+
#define n (EEF / (2.0 - EEF))
|
|
30
|
+
|
|
31
|
+
#define N1 (n)
|
|
32
|
+
#define N2 (n * n)
|
|
33
|
+
#define N3 (n * n * n)
|
|
34
|
+
#define N4 (n * n * n * n)
|
|
35
|
+
#define A (EEA / (1.0 + N1) * (1.0 + N2 / 4.0 + N4 / 64.0))
|
|
36
|
+
#define A1 ((1.0 / 2.0) * N1 - (2.0 / 3.0) * N2 + (5.0 / 16.0) * N3)
|
|
37
|
+
#define A2 ((13.0 / 48.0) * N2 - (3.0 / 5.0) * N3)
|
|
38
|
+
#define A3 ((61.0 / 240.0) * N3)
|
|
39
|
+
#define B1 ((1.0 / 2.0) * N1 - (2.0 / 3.0) * N2 + (37.0 / 96.0) * N3)
|
|
40
|
+
#define B2 ((1.0 / 48.0) * N2 + (1.0 / 15.0) * N3)
|
|
41
|
+
#define B3 ((17.0 / 480.0) * N3)
|
|
42
|
+
#define D1 (2.0 * N1 - (2.0 / 3.0) * N2 - 2.0 * N3)
|
|
43
|
+
#define D2 ((7.0 / 3.0) * N2 - (8.0 / 5.0) * N3)
|
|
44
|
+
#define D3 ((56.0 / 15.0) * N3)
|
|
45
|
+
|
|
46
|
+
void latlon2xy(const double latlon[], double xy[]){
|
|
47
|
+
double lon = latlon[1] * DEG2RAD;
|
|
48
|
+
double lat = latlon[0] * DEG2RAD;
|
|
49
|
+
|
|
50
|
+
double t = sinh(atanh(sin(lat)) - 2 * sqrt(N1) / (1 + N1) * atanh(2 * sqrt(N1) / (1 + N1) * sin(lat)));
|
|
51
|
+
|
|
52
|
+
double xx = atan(t / cos(lon - LON0));
|
|
53
|
+
double yy = atanh(sin(lon - LON0) / sqrt(1 + t * t));
|
|
54
|
+
|
|
55
|
+
xy[0] = E0 + K0 * A * (
|
|
56
|
+
yy
|
|
57
|
+
+ A1 * cos(2 * 1 * xx) * sinh(2 * 1 * yy)
|
|
58
|
+
+ A2 * cos(2 * 2 * xx) * sinh(2 * 2 * yy)
|
|
59
|
+
+ A3 * cos(2 * 3 * xx) * sinh(2 * 3 * yy)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
xy[1] = N0 + K0 * A * (
|
|
63
|
+
xx
|
|
64
|
+
+ A1 * sin(2 * 1 * xx) * cosh(2 * 1 * yy)
|
|
65
|
+
+ A2 * sin(2 * 2 * xx) * cosh(2 * 2 * yy)
|
|
66
|
+
+ A3 * sin(2 * 3 * xx) * cosh(2 * 3 * yy)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void xy2latlon(const double xy[], double latlon[]){
|
|
71
|
+
double x = (xy[1] - N0) / (K0 * A);
|
|
72
|
+
double y = (xy[0] - E0) / (K0 * A);
|
|
73
|
+
|
|
74
|
+
double xx = x - (
|
|
75
|
+
B1 * sin(2 * 1 * x) * cosh(2 * 1 * y)
|
|
76
|
+
+ B2 * sin(2 * 2 * x) * cosh(2 * 2 * y)
|
|
77
|
+
+ B3 * sin( 2 * 3 * x) * cosh(2 * 3 * y)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
double yy = y - (
|
|
81
|
+
B1 * cos( 2 * 1 * x) * sinh(2 * 1 * y)
|
|
82
|
+
+ B2 * cos(2 * 2 * x) * sinh(2 * 2 * y)
|
|
83
|
+
+ B3 * cos(2 * 3 * x) * sinh(2 * 3 * y)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
double kai = asin(sin(xx) / cosh(yy));
|
|
87
|
+
latlon[0] = kai+(D1 * sin(2 * 1 * kai) + D2 * sin(2 * 2 * kai) + D3 * sin(2 * 3 * kai));
|
|
88
|
+
latlon[1] = LON0 + atan(sinh(yy) / cos(xx));
|
|
89
|
+
latlon[0] = latlon[0] / DEG2RAD;
|
|
90
|
+
latlon[1] = latlon[1] / DEG2RAD;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
int main(int argc, char const * argv[])
|
|
94
|
+
{
|
|
95
|
+
double latlon[] = {38., 140.};
|
|
96
|
+
double xy[2];
|
|
97
|
+
|
|
98
|
+
double threshold = 1E-10;
|
|
99
|
+
|
|
100
|
+
/* Calculated by UTMApproximation */
|
|
101
|
+
double expected_xy[2] = {412201.5821667329, 4206286.757906346};
|
|
102
|
+
double expected_latlon[2] = {38.00000000088939, 140.00000000001884};
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
latlon2xy(latlon, xy);
|
|
106
|
+
if (fabs(expected_xy[0] - xy[0]) >= threshold || fabs(expected_xy[1] - xy[1]) >= threshold) {
|
|
107
|
+
fprintf(stderr, "Failed latlon2xy from (lat: %.6f, lon: %.6f)\n", latlon[0], latlon[1]);
|
|
108
|
+
fprintf(stderr, " expected (x: %.10f, y: %.10f)\n", expected_xy[0], expected_xy[1]);
|
|
109
|
+
fprintf(stderr, " get (x: %.10f, y: %.10f)\n", xy[0], xy[1]);
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
xy2latlon(expected_xy, latlon);
|
|
114
|
+
if (fabs(latlon[0] - expected_latlon[0]) >= threshold || fabs(latlon[1] - expected_latlon[1]) >= threshold) {
|
|
115
|
+
fprintf(stderr, "Failed xy2latlon from (x: %.11f, y: %.10f)\n", expected_xy[0], expected_xy[1]);
|
|
116
|
+
fprintf(stderr, " expected (x: %.10f, y: %.10f)\n", expected_latlon[0], expected_latlon[1]);
|
|
117
|
+
fprintf(stderr, " get (x: %.10f, y: %.10f)\n", latlon[0], latlon[1]);
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
data/lib/cutm/version.rb
ADDED
data/lib/cutm.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: CUTM
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kazufusa Ishibashi
|
|
8
|
+
- Takafumi Yamaguchi
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '1.16'
|
|
21
|
+
type: :development
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.16'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rake
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '10.0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '10.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: minitest
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '5.0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '5.0'
|
|
56
|
+
description: Provides convertion functions between Lon/Lat and UTM(54) coordinates
|
|
57
|
+
email:
|
|
58
|
+
- tkfm.yamaguchi@gmail.com
|
|
59
|
+
executables: []
|
|
60
|
+
extensions:
|
|
61
|
+
- ext/cutm/extconf.rb
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- ".gitignore"
|
|
65
|
+
- ".travis.yml"
|
|
66
|
+
- CODE_OF_CONDUCT.md
|
|
67
|
+
- Gemfile
|
|
68
|
+
- LICENSE.txt
|
|
69
|
+
- README.md
|
|
70
|
+
- Rakefile
|
|
71
|
+
- bin/console
|
|
72
|
+
- bin/setup
|
|
73
|
+
- cutm.gemspec
|
|
74
|
+
- ext/cutm/extconf.rb
|
|
75
|
+
- ext/cutm/glue.c
|
|
76
|
+
- ext/cutm/utm.c
|
|
77
|
+
- lib/cutm.rb
|
|
78
|
+
- lib/cutm/version.rb
|
|
79
|
+
homepage: ''
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata: {}
|
|
83
|
+
post_install_message:
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubyforge_project:
|
|
99
|
+
rubygems_version: 2.7.6
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: Converts Lon/Lat to UTM(54) coordinates, vise versa.
|
|
103
|
+
test_files: []
|