coordinates_transformations 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +39 -0
- data/Rakefile +28 -0
- data/coordinates_transformations.gemspec +28 -0
- data/lib/coordinates_transformations.rb +22 -0
- data/lib/coordinates_transformations/bounds.rb +18 -0
- data/lib/coordinates_transformations/lat_lng.rb +18 -0
- data/lib/coordinates_transformations/version.rb +3 -0
- data/test/bounds_test.rb +25 -0
- data/test/lat_lng_test.rb +21 -0
- data/test/test_helper.rb +8 -0
- metadata +180 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2011 Marc Essindi <marc.essindi@dunkelbraun.com>
|
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.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= Coordinates Transformations -- Point and UTM transformations for GeoKit.
|
2
|
+
|
3
|
+
With Coordinates Transformations you can transform GeoKit::LatLng and GeoKit::Bounds into point and utm coordinates.
|
4
|
+
|
5
|
+
== Download and installation
|
6
|
+
|
7
|
+
The latest version of Coordinates Transformations can be installed with Rubygems:
|
8
|
+
% [sudo] gem install coordinates_transformations
|
9
|
+
|
10
|
+
Include the gem in your Gemfile:
|
11
|
+
gem 'coordinates_transformations'
|
12
|
+
|
13
|
+
Source code can be downloaded from Github:
|
14
|
+
|
15
|
+
* http://github.com/dunkelbraun/coordinates_transformations
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
A GeoKit::LatLng object has two new methods available: to_utm, and to_point
|
20
|
+
|
21
|
+
new_york = GeoKit::LatLng.new(40.714353, -74.005973)
|
22
|
+
new_york.to_utm
|
23
|
+
new_york.to_point
|
24
|
+
|
25
|
+
The UTM transformation returns a GeoUtm::UTM
|
26
|
+
The point transformation returns GeoRuby::SimpleFeatures::Point
|
27
|
+
|
28
|
+
A GeoKit::Bounds object has two new methods available: to_utm, and to_point
|
29
|
+
area = GeoKit::Bounds.from_point_and_radius(new_york, 20, {:units => :kms})
|
30
|
+
area.to_utm
|
31
|
+
area.to_multipoint
|
32
|
+
|
33
|
+
The UTM transformation returns an array of GeoUtm::UTM [sw utm,ne utm]
|
34
|
+
The multipoint returns a GeoRuby::SimpleFeatures::MultiPoint
|
35
|
+
|
36
|
+
|
37
|
+
== License
|
38
|
+
|
39
|
+
Coordinates Transformations is released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rdoc/task'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc 'Test the coordinates_transformations gem.'
|
10
|
+
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.libs << 'test'
|
13
|
+
t.test_files = FileList['test/*_test.rb']
|
14
|
+
t.loader = :direct
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the coordinates_transformations gem.'
|
19
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'coordinates_transformations'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README.rdoc')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "coordinates_transformations/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "coordinates_transformations"
|
7
|
+
s.version = CoordinatesTransformations::VERSION
|
8
|
+
s.authors = "Marc Essindi"
|
9
|
+
s.email = "marc.essindi@dunkelbraun.com"
|
10
|
+
s.homepage = "https://github.com/dunkelbraun/coordinates_transformations"
|
11
|
+
s.summary = "Point and UTM transformations for GeoKit."
|
12
|
+
|
13
|
+
# s.rubyforge_project = "coordinates_transformations"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency "json"
|
20
|
+
s.add_dependency "geokit"
|
21
|
+
s.add_dependency "georuby"
|
22
|
+
s.add_dependency "geoutm"
|
23
|
+
|
24
|
+
s.add_development_dependency "shoulda", '>= 3.0.0.beta'
|
25
|
+
s.add_development_dependency "mocha"
|
26
|
+
s.add_development_dependency "active_support", '>= 3.0'
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'geokit'
|
2
|
+
require 'geo_ruby'
|
3
|
+
require 'geoutm'
|
4
|
+
|
5
|
+
require "coordinates_transformations/version"
|
6
|
+
require "coordinates_transformations/lat_lng"
|
7
|
+
require "coordinates_transformations/bounds"
|
8
|
+
|
9
|
+
|
10
|
+
module GeoKit # :nodoc:
|
11
|
+
|
12
|
+
class LatLng # :nodoc:
|
13
|
+
include CoordinatesTransformations::LatLng
|
14
|
+
end
|
15
|
+
|
16
|
+
class Bounds # :nodoc:
|
17
|
+
include CoordinatesTransformations::Bounds
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CoordinatesTransformations
|
2
|
+
|
3
|
+
module Bounds
|
4
|
+
|
5
|
+
# Converts self into an array of southwest and northeast GeoUtm::UTM
|
6
|
+
def to_utm
|
7
|
+
[self.sw.to_utm, self.ne.to_utm]
|
8
|
+
end
|
9
|
+
|
10
|
+
# Converts self into a GeoRuby::SimpleFeatures::MultiPoint
|
11
|
+
def to_multipoint
|
12
|
+
point1, point2 = self.to_utm
|
13
|
+
GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([ [ point1.e, point1.n ], [ point2.e, point2.n ] ])
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CoordinatesTransformations
|
2
|
+
|
3
|
+
module LatLng
|
4
|
+
|
5
|
+
# Transforms self into a GeoUtm::UTM
|
6
|
+
def to_utm
|
7
|
+
GeoUtm::LatLon.new(self.lat, self.lng).to_utm
|
8
|
+
end
|
9
|
+
|
10
|
+
# Transforms self into a GeoRuby::SimpleFeatures::Point
|
11
|
+
def to_point
|
12
|
+
utm_position = self.to_utm
|
13
|
+
GeoRuby::SimpleFeatures::Point.from_x_y(utm_position.e, utm_position.n)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/bounds_test.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GeoKitAdditionsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@region = GeoKit::Bounds.from_point_and_radius(GeoKit::LatLng.new(41.38676, 1.93205), 20, {:units => :kms})
|
7
|
+
end
|
8
|
+
|
9
|
+
test "region to utm transformation" do
|
10
|
+
utm_region = @region.to_utm
|
11
|
+
assert_in_delta 390383.574244734, utm_region[0].e, 0.00001
|
12
|
+
assert_in_delta 4562566.95145292, utm_region[0].n, 0.00001
|
13
|
+
assert_in_delta 430927.142061895, utm_region[1].e, 0.00001
|
14
|
+
assert_in_delta 4601974.09517355, utm_region[1].n, 0.00001
|
15
|
+
end
|
16
|
+
|
17
|
+
test "region to multipoint transformation" do
|
18
|
+
multipoint = @region.to_multipoint
|
19
|
+
assert_in_delta 390383.574244734, multipoint.geometries[0].x, 0.00001
|
20
|
+
assert_in_delta 4562566.95145292, multipoint.geometries[0].y, 0.00001
|
21
|
+
assert_in_delta 430927.142061895, multipoint.geometries[1].x, 0.00001
|
22
|
+
assert_in_delta 4601974.09517355, multipoint.geometries[1].y, 0.00001
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LatLngTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@location = GeoKit::LatLng.new(41.38676, 1.93205)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "latlng to utm location transformation" do
|
10
|
+
utm_location = @location.to_utm
|
11
|
+
assert_in_delta 410710.177361338, utm_location.e, 0.001
|
12
|
+
assert_in_delta 4582242.73580142, utm_location.n, 0.001
|
13
|
+
end
|
14
|
+
|
15
|
+
test "latlng to point transformation" do
|
16
|
+
point = @location.to_point
|
17
|
+
assert_in_delta 410710.177361338, point.x, 0.001
|
18
|
+
assert_in_delta 4582242.73580142, point.y, 0.001
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coordinates_transformations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Marc Essindi
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-31 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: geokit
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: georuby
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: geoutm
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: shoulda
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 31098225
|
85
|
+
segments:
|
86
|
+
- 3
|
87
|
+
- 0
|
88
|
+
- 0
|
89
|
+
- beta
|
90
|
+
version: 3.0.0.beta
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id005
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: mocha
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
type: :development
|
106
|
+
version_requirements: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: active_support
|
109
|
+
prerelease: false
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 7
|
116
|
+
segments:
|
117
|
+
- 3
|
118
|
+
- 0
|
119
|
+
version: "3.0"
|
120
|
+
type: :development
|
121
|
+
version_requirements: *id007
|
122
|
+
description:
|
123
|
+
email: marc.essindi@dunkelbraun.com
|
124
|
+
executables: []
|
125
|
+
|
126
|
+
extensions: []
|
127
|
+
|
128
|
+
extra_rdoc_files: []
|
129
|
+
|
130
|
+
files:
|
131
|
+
- .gitignore
|
132
|
+
- Gemfile
|
133
|
+
- MIT-LICENSE
|
134
|
+
- README.rdoc
|
135
|
+
- Rakefile
|
136
|
+
- coordinates_transformations.gemspec
|
137
|
+
- lib/coordinates_transformations.rb
|
138
|
+
- lib/coordinates_transformations/bounds.rb
|
139
|
+
- lib/coordinates_transformations/lat_lng.rb
|
140
|
+
- lib/coordinates_transformations/version.rb
|
141
|
+
- test/bounds_test.rb
|
142
|
+
- test/lat_lng_test.rb
|
143
|
+
- test/test_helper.rb
|
144
|
+
homepage: https://github.com/dunkelbraun/coordinates_transformations
|
145
|
+
licenses: []
|
146
|
+
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
hash: 3
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
version: "0"
|
170
|
+
requirements: []
|
171
|
+
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 1.8.10
|
174
|
+
signing_key:
|
175
|
+
specification_version: 3
|
176
|
+
summary: Point and UTM transformations for GeoKit.
|
177
|
+
test_files:
|
178
|
+
- test/bounds_test.rb
|
179
|
+
- test/lat_lng_test.rb
|
180
|
+
- test/test_helper.rb
|