proj4rb 0.3.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +9 -0
- data/README +169 -0
- data/data/GL27 +22 -0
- data/data/MD +0 -0
- data/data/TN +0 -0
- data/data/WI +0 -0
- data/data/WO +0 -0
- data/data/conus +0 -0
- data/data/epsg +5443 -0
- data/data/epsg-deprecated +2 -0
- data/data/esri +5937 -0
- data/data/esri.extra +948 -0
- data/data/hawaii +0 -0
- data/data/nad.lst +142 -0
- data/data/nad27 +809 -0
- data/data/nad83 +744 -0
- data/data/ntv1_can.dat +0 -0
- data/data/null +0 -0
- data/data/other.extra +49 -0
- data/data/proj_def.dat +17 -0
- data/data/prvi +0 -0
- data/data/stgeorge +0 -0
- data/data/stlrnc +0 -0
- data/data/stpaul +0 -0
- data/data/world +212 -0
- data/example/basic.rb +18 -0
- data/example/list-datums.rb +17 -0
- data/example/list-ellipsoids.rb +17 -0
- data/example/list-errors.rb +11 -0
- data/example/list-prime-meridians.rb +17 -0
- data/example/list-projection-types.rb +17 -0
- data/example/list-units.rb +17 -0
- data/example/version.rb +8 -0
- data/ext/extconf.rb +8 -0
- data/ext/mingw/rakefile.rb +38 -0
- data/ext/projrb.c +560 -0
- data/ext/vc/proj4_ruby.sln +19 -0
- data/ext/vc/proj4_ruby.vcproj +208 -0
- data/lib/proj4.rb +466 -0
- data/lib/proj4_ruby.so +0 -0
- data/rakefile.rb +130 -0
- data/test/test_constants.rb +20 -0
- data/test/test_create_projection.rb +64 -0
- data/test/test_datums.rb +44 -0
- data/test/test_ellipsoids.rb +45 -0
- data/test/test_errors.rb +70 -0
- data/test/test_init_projection.rb +108 -0
- data/test/test_prime_meridians.rb +44 -0
- data/test/test_projection_type.rb +43 -0
- data/test/test_simple_projection.rb +57 -0
- data/test/test_transform.rb +114 -0
- data/test/test_units.rb +45 -0
- metadata +117 -0
data/rakefile.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/clean'
|
7
|
+
require 'date'
|
8
|
+
require 'ftools'
|
9
|
+
|
10
|
+
CLOBBER.include('pkg/*', 'proj4rb-doc/**/*', 'lib/*.so', 'lib/*.bundle', 'lib/*.dll', 'ext/*.o', 'ext/*.so', 'ext/*.bundle', 'ext/*.dll', 'ext/Makefile', 'ext/mkmf.log')
|
11
|
+
|
12
|
+
desc "Create Makefile"
|
13
|
+
file 'ext/Makefile' => ['ext/extconf.rb'] do
|
14
|
+
sh 'cd ext; ruby extconf.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Build from C library"
|
18
|
+
task :build => ['ext/Makefile', 'ext/projrb.c'] do
|
19
|
+
sh 'cd ext; make'
|
20
|
+
end
|
21
|
+
|
22
|
+
# ------- Default Package ----------
|
23
|
+
FILES = FileList[
|
24
|
+
'rakefile.rb',
|
25
|
+
'README',
|
26
|
+
'MIT-LICENSE',
|
27
|
+
'data/**/*',
|
28
|
+
'doc/**/*',
|
29
|
+
'example/**/*',
|
30
|
+
'ext/*',
|
31
|
+
'ext/mingw/rakefile.rb',
|
32
|
+
'ext/vc/*.sln',
|
33
|
+
'ext/vc/*.vcproj',
|
34
|
+
'lib/**/*.rb'
|
35
|
+
]
|
36
|
+
|
37
|
+
# Default GEM Specification
|
38
|
+
default_spec = Gem::Specification::new do |s|
|
39
|
+
s.name = 'proj4rb'
|
40
|
+
s.version = "0.3.0"
|
41
|
+
s.summary = "Ruby bindings for the Proj.4 Carthographic Projection library"
|
42
|
+
s.description = <<-EOF
|
43
|
+
Proj4rb is a ruby binding for the Proj.4 Carthographic Projection library, that supports conversions between a very large number of geographic coordinate systems and datums.
|
44
|
+
EOF
|
45
|
+
s.author = 'Guilhem Vellut'
|
46
|
+
s.email = 'guilhem.vellut@gmail.com'
|
47
|
+
s.homepage = 'http://proj4rb.rubyforge.org/'
|
48
|
+
s.rubyforge_project = 'proj4rb'
|
49
|
+
s.required_ruby_version = '>= 1.8.4'
|
50
|
+
s.date = DateTime.now
|
51
|
+
|
52
|
+
s.platform = Gem::Platform::RUBY
|
53
|
+
s.requirements << 'Proj.4 C library'
|
54
|
+
s.require_path = 'lib'
|
55
|
+
s.extensions = ["ext/extconf.rb"]
|
56
|
+
s.files = FILES.to_a
|
57
|
+
s.test_files = FileList['test/test*.rb']
|
58
|
+
|
59
|
+
s.has_rdoc = true
|
60
|
+
s.extra_rdoc_files = ["README"]
|
61
|
+
s.rdoc_options.concat ['--main', 'README']
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Package the library as a gem"
|
65
|
+
Rake::GemPackageTask.new(default_spec) do |pkg|
|
66
|
+
pkg.need_zip = true
|
67
|
+
pkg.need_tar = true
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
# ------- Windows Package ----------
|
72
|
+
binaries = (FileList['ext/mingw/*.so',
|
73
|
+
'ext/mingw/*.dll*'])
|
74
|
+
|
75
|
+
win_spec = default_spec.clone
|
76
|
+
win_spec.extensions = []
|
77
|
+
win_spec.platform = Gem::Platform::CURRENT
|
78
|
+
win_spec.files += binaries.map {|binaryname| "lib/#{File.basename(binaryname)}"}
|
79
|
+
|
80
|
+
desc "Create Windows Gem"
|
81
|
+
task :create_win32_gem do
|
82
|
+
# Copy the win32 extension built by MingW - easier to install
|
83
|
+
# since there are no dependencies of msvcr80.dll
|
84
|
+
current_dir = File.expand_path(File.dirname(__FILE__))
|
85
|
+
|
86
|
+
binaries.each do |binaryname|
|
87
|
+
target = File.join(current_dir, 'lib', File.basename(binaryname))
|
88
|
+
cp(binaryname, target)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Create the gem, then move it to admin/pkg
|
92
|
+
Gem::Builder.new(win_spec).build
|
93
|
+
gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
|
94
|
+
mv(gem_file, "pkg/#{gem_file}")
|
95
|
+
|
96
|
+
# Remove win extension from top level directory
|
97
|
+
binaries.each do |binaryname|
|
98
|
+
target = File.join(current_dir, 'lib', File.basename(binaryname))
|
99
|
+
rm(target)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
# --------- Test Task ---------
|
105
|
+
Rake::TestTask.new do |t|
|
106
|
+
t.libs << "test"
|
107
|
+
t.libs << "lib"
|
108
|
+
end
|
109
|
+
|
110
|
+
# --------- RDoc Documentation ---------
|
111
|
+
desc "Generate rdoc documentation"
|
112
|
+
Rake::RDocTask.new("rdoc") do |rdoc|
|
113
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
114
|
+
rdoc.title = "Proj4rb Documentation"
|
115
|
+
# Show source inline with line numbers
|
116
|
+
rdoc.options << "--inline-source" << "--line-numbers"
|
117
|
+
# Make the readme file the start page for the generated html
|
118
|
+
rdoc.options << '--main' << 'README'
|
119
|
+
rdoc.rdoc_files.include('doc/*.rdoc',
|
120
|
+
'ext/**/*.c',
|
121
|
+
'lib/**/*.rb',
|
122
|
+
'README',
|
123
|
+
'MIT-LICENSE')
|
124
|
+
end
|
125
|
+
|
126
|
+
task :default => :package
|
127
|
+
|
128
|
+
if RUBY_PLATFORM.match(/win32/)
|
129
|
+
task :package => :create_win32_gem
|
130
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class ConstantsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_version
|
8
|
+
assert 440 < Proj4::LIBVERSION
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_deg
|
12
|
+
assert_equal Math::PI/180, Proj4::DEG_TO_RAD
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_rad
|
16
|
+
assert_equal 180/Math::PI, Proj4::RAD_TO_DEG
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class CreateProjectionTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@proj_wgs84 = Proj4::Projection.new(["init=epsg:4326"]) # WGS84
|
9
|
+
@proj_gk = Proj4::Projection.new(["init=epsg:31467"]) # Gauss-Kruger Zone 3
|
10
|
+
@proj_conakry = Proj4::Projection.new(["init=epsg:31528"]) # Conakry 1905 / UTM zone 28N
|
11
|
+
@proj_ortel = Proj4::Projection.new(["proj=ortel", "lon_0=90w"]) # Ortelius Oval Projection
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_has_inverse
|
15
|
+
assert @proj_wgs84.hasInverse?
|
16
|
+
assert @proj_gk.hasInverse?
|
17
|
+
assert @proj_conakry.hasInverse?
|
18
|
+
assert ! @proj_ortel.hasInverse?
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_is_latlong
|
22
|
+
assert @proj_wgs84.isLatLong?
|
23
|
+
assert ! @proj_gk.isLatLong?
|
24
|
+
assert ! @proj_conakry.isLatLong?
|
25
|
+
assert ! @proj_ortel.isLatLong?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_is_geocent
|
29
|
+
assert_equal @proj_gk.isGeocent?, @proj_gk.isGeocentric? # two names for same method
|
30
|
+
assert ! @proj_wgs84.isGeocent?
|
31
|
+
assert ! @proj_gk.isGeocent?
|
32
|
+
assert ! @proj_conakry.isGeocent?
|
33
|
+
assert ! @proj_ortel.isGeocent?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_def
|
37
|
+
assert_equal '+init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0', @proj_wgs84.getDef.strip
|
38
|
+
d = @proj_gk.getDef.strip
|
39
|
+
assert ('+init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs +towgs84=606.0,23.0,413.0' == d || '+init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1.000000 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs +towgs84=606.0,23.0,413.0' == d)
|
40
|
+
assert_equal '+init=epsg:31528 +proj=utm +zone=28 +a=6378249.2 +b=6356515 +towgs84=-23,259,-9,0,0,0,0 +units=m +no_defs', @proj_conakry.getDef.strip
|
41
|
+
assert_equal '+proj=ortel +lon_0=90w +ellps=WGS84', @proj_ortel.getDef.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_inspect
|
45
|
+
assert_equal '#<Proj4::Projection +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0>', @proj_wgs84.to_s
|
46
|
+
assert_equal '#<Proj4::Projection +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0>', @proj_wgs84.inspect
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_projection
|
50
|
+
assert_equal 'longlat', @proj_wgs84.projection
|
51
|
+
assert_equal 'tmerc', @proj_gk.projection
|
52
|
+
assert_equal 'utm', @proj_conakry.projection
|
53
|
+
assert_equal 'ortel', @proj_ortel.projection
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_datum
|
57
|
+
assert_equal 'WGS84', @proj_wgs84.datum
|
58
|
+
assert_equal 'potsdam', @proj_gk.datum
|
59
|
+
assert_nil @proj_conakry.datum
|
60
|
+
assert_nil @proj_ortel.datum
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
data/test/test_datums.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if Proj4::LIBVERSION >= 449
|
6
|
+
class DatumsTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_all
|
9
|
+
datums = Proj4::Datum.list.sort.collect{ |u| u.id }
|
10
|
+
assert datums.index('WGS84')
|
11
|
+
assert datums.index('potsdam')
|
12
|
+
assert datums.index('ire65')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_one
|
16
|
+
datum = Proj4::Datum.get('potsdam')
|
17
|
+
assert_kind_of Proj4::Datum, datum
|
18
|
+
assert_equal 'potsdam', datum.id
|
19
|
+
assert_equal 'potsdam', datum.to_s
|
20
|
+
assert_equal 'bessel', datum.ellipse_id
|
21
|
+
assert_equal 'towgs84=606.0,23.0,413.0', datum.defn
|
22
|
+
assert_equal 'Potsdam Rauenberg 1950 DHDN', datum.comments
|
23
|
+
assert_equal '#<Proj4::Datum id="potsdam", ellipse_id="bessel", defn="towgs84=606.0,23.0,413.0", comments="Potsdam Rauenberg 1950 DHDN">', datum.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_compare
|
27
|
+
u1 = Proj4::Datum.get('potsdam')
|
28
|
+
u2 = Proj4::Datum.get('potsdam')
|
29
|
+
assert u1 == u2
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_failed_get
|
33
|
+
datum = Proj4::Datum.get('foo')
|
34
|
+
assert_nil datum
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_new
|
38
|
+
assert_raise TypeError do
|
39
|
+
Proj4::Datum.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if Proj4::LIBVERSION >= 449
|
6
|
+
class EllipsoidsTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_all
|
9
|
+
ellipsoids = Proj4::Ellipsoid.list.sort.collect{ |u| u.id }
|
10
|
+
assert ellipsoids.index('WGS84')
|
11
|
+
assert ellipsoids.index('bessel')
|
12
|
+
assert ellipsoids.index('lerch')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_one
|
16
|
+
ellipsoid = Proj4::Ellipsoid.get('bessel')
|
17
|
+
assert_kind_of Proj4::Ellipsoid, ellipsoid
|
18
|
+
assert_equal 'bessel', ellipsoid.id
|
19
|
+
assert_equal 'a=6377397.155', ellipsoid.major
|
20
|
+
assert_equal 'rf=299.1528128', ellipsoid.ell
|
21
|
+
assert_equal 'Bessel 1841', ellipsoid.name
|
22
|
+
assert_equal 'bessel', ellipsoid.to_s
|
23
|
+
assert_equal '#<Proj4::Ellipsoid id="bessel", major="a=6377397.155", ell="rf=299.1528128", name="Bessel 1841">', ellipsoid.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_compare
|
27
|
+
e1 = Proj4::Ellipsoid.get('bessel')
|
28
|
+
e2 = Proj4::Ellipsoid.get('bessel')
|
29
|
+
assert e1 == e2
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_failed_get
|
33
|
+
ellipsoid = Proj4::Ellipsoid.get('foo')
|
34
|
+
assert_nil ellipsoid
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_new
|
38
|
+
assert_raise TypeError do
|
39
|
+
Proj4::Ellipsoid.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/test/test_errors.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class ErrorsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_list
|
8
|
+
assert_equal "Unknown", Proj4::Error.error(0)
|
9
|
+
assert_equal "NoOptionsInInitFile", Proj4::Error.error(2)
|
10
|
+
assert_equal "NoOptionsInInitFile", Proj4::Error.error(-2)
|
11
|
+
assert_equal "Unknown", Proj4::Error.error(-2000)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_parenting
|
15
|
+
assert_kind_of Proj4::Error, Proj4::UnknownError.new
|
16
|
+
assert_kind_of Proj4::Error, Proj4::ToleranceConditionError.new
|
17
|
+
assert_kind_of StandardError, Proj4::UnknownError.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_num
|
21
|
+
assert 0, Proj4::UnknownError.errnum
|
22
|
+
assert 1, Proj4::NoArgsInInitListError.errnum
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_raise
|
26
|
+
assert_raise Proj4::UnknownError do
|
27
|
+
Proj4::Error.raise_error(0)
|
28
|
+
end
|
29
|
+
assert_raise Proj4::NoOptionsInInitFileError do
|
30
|
+
Proj4::Error.raise_error(2)
|
31
|
+
end
|
32
|
+
assert_raise Proj4::ProjectionNotNamedError do
|
33
|
+
Proj4::Error.raise_error(-4)
|
34
|
+
end
|
35
|
+
assert_raise Proj4::UnknownError do
|
36
|
+
Proj4::Error.raise_error(2000)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_strerrno
|
41
|
+
assert_equal 'no arguments in initialization list', Proj4::Error.message(-1)
|
42
|
+
assert_equal 'reciprocal flattening (1/f) = 0', Proj4::Error.message(-10)
|
43
|
+
assert_equal 'unknown error', Proj4::Error.message(0)
|
44
|
+
assert_match /^invalid projection system error/, Proj4::Error.message(-2000)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_raise_err0
|
48
|
+
begin
|
49
|
+
Proj4::Error.raise_error(0)
|
50
|
+
rescue => exception
|
51
|
+
assert_equal Proj4::UnknownError, exception.class
|
52
|
+
assert_equal "unknown error", exception.message
|
53
|
+
assert_equal 0, exception.errnum
|
54
|
+
assert_match %r{test/test_errors.rb:[0-9]+:in .test_raise_err0.$} , exception.backtrace[0]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_raise_err1
|
59
|
+
begin
|
60
|
+
Proj4::Error.raise_error(1)
|
61
|
+
rescue => exception
|
62
|
+
assert_equal Proj4::NoArgsInInitListError, exception.class
|
63
|
+
assert_equal 'no arguments in initialization list', exception.message
|
64
|
+
assert_equal 1, exception.errnum
|
65
|
+
assert_match %r{test/test_errors.rb:[0-9]+:in .test_raise_err1.$} , exception.backtrace[0]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,108 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class InitProjectionTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
# NAD27(76) / UTM zone 17N
|
9
|
+
# <2029> +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs no_defs <>
|
10
|
+
@epsg2029i = ['init=epsg:2029']
|
11
|
+
@epsg2029x = ['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'].sort
|
12
|
+
|
13
|
+
@nad = ' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_arg_fail
|
17
|
+
assert_raise ArgumentError do
|
18
|
+
Proj4::Projection._parse_init_parameters()
|
19
|
+
end
|
20
|
+
assert_raise ArgumentError do
|
21
|
+
Proj4::Projection._parse_init_parameters(nil)
|
22
|
+
end
|
23
|
+
assert_raise ArgumentError do
|
24
|
+
Proj4::Projection._parse_init_parameters(1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_arg_string
|
29
|
+
args = Proj4::Projection._parse_init_parameters('init=epsg:2029')
|
30
|
+
assert_equal @epsg2029i, args
|
31
|
+
args = Proj4::Projection._parse_init_parameters(' proj=utm zone=17 ellps=clrk66 units=m no_defs ')
|
32
|
+
assert_equal @epsg2029x, args.sort
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_arg_string_with_plus
|
36
|
+
args = Proj4::Projection._parse_init_parameters('+init=epsg:2029')
|
37
|
+
assert_equal @epsg2029i, args
|
38
|
+
args = Proj4::Projection._parse_init_parameters('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
|
39
|
+
assert_equal @epsg2029x, args.sort
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_arg_array
|
43
|
+
args = Proj4::Projection._parse_init_parameters(['init=epsg:2029'])
|
44
|
+
assert_equal @epsg2029i, args
|
45
|
+
args = Proj4::Projection._parse_init_parameters(['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'])
|
46
|
+
assert_equal @epsg2029x, args.sort
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_arg_array_with_plus
|
50
|
+
args = Proj4::Projection._parse_init_parameters(['+init=epsg:2029'])
|
51
|
+
assert_equal @epsg2029i, args
|
52
|
+
args = Proj4::Projection._parse_init_parameters(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
|
53
|
+
assert_equal @epsg2029x, args.sort
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_arg_hash_with_string
|
57
|
+
args = Proj4::Projection._parse_init_parameters( {'init' => 'epsg:2029'} )
|
58
|
+
assert_equal @epsg2029i, args
|
59
|
+
args = Proj4::Projection._parse_init_parameters( {'proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil} )
|
60
|
+
assert_equal @epsg2029x, args.sort
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_arg_hash_with_symbol
|
64
|
+
args = Proj4::Projection._parse_init_parameters( {:init => 'epsg:2029'} )
|
65
|
+
assert_equal @epsg2029i, args
|
66
|
+
args = Proj4::Projection._parse_init_parameters( {:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil} )
|
67
|
+
assert_equal @epsg2029x, args.sort
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_arg_hash_with_symbol_simple
|
71
|
+
args = Proj4::Projection._parse_init_parameters( :init => 'epsg:2029' )
|
72
|
+
assert_equal @epsg2029i, args
|
73
|
+
args = Proj4::Projection._parse_init_parameters( :proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil )
|
74
|
+
assert_equal @epsg2029x, args.sort
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_arg_projection
|
78
|
+
proj = Proj4::Projection.new(['init=epsg:2029'])
|
79
|
+
args = Proj4::Projection._parse_init_parameters(proj)
|
80
|
+
assert_equal [@epsg2029i, @epsg2029x].flatten.sort, args.sort
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_init_arg_string
|
84
|
+
proj = Proj4::Projection.new('+init=epsg:2029')
|
85
|
+
assert_equal @nad, proj.getDef
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_init_arg_array
|
89
|
+
proj = Proj4::Projection.new(['init=epsg:2029'])
|
90
|
+
assert_equal @nad, proj.getDef
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_init_arg_hash
|
94
|
+
proj = Proj4::Projection.new( :proj => 'utm', 'zone' => '17', '+ellps' => 'clrk66', :units => 'm', :no_defs => nil )
|
95
|
+
assert_equal @epsg2029x, proj.getDef.strip.split(' ').collect{ |a| a.sub(/^\+/, '') }.sort
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_init_arg_fail
|
99
|
+
assert_raise Proj4::UnknownProjectionIdError do
|
100
|
+
Proj4::Projection.new( :proj => 'xxxx' )
|
101
|
+
end
|
102
|
+
assert_raise Proj4::ProjectionNotNamedError do
|
103
|
+
Proj4::Projection.new( :foo => 'xxxx' )
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if Proj4::LIBVERSION >= 449
|
6
|
+
class PrimeMeridiansTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_all
|
9
|
+
prime_meridians = Proj4::PrimeMeridian.list.sort.collect{ |u| u.id}
|
10
|
+
assert prime_meridians.index('greenwich')
|
11
|
+
assert prime_meridians.index('athens')
|
12
|
+
assert prime_meridians.index('lisbon')
|
13
|
+
assert prime_meridians.index('rome')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_one
|
17
|
+
prime_meridian = Proj4::PrimeMeridian.get('lisbon')
|
18
|
+
assert_kind_of Proj4::PrimeMeridian, prime_meridian
|
19
|
+
assert_equal 'lisbon', prime_meridian.id
|
20
|
+
assert_equal 'lisbon', prime_meridian.to_s
|
21
|
+
assert_equal '9d07\'54.862"W', prime_meridian.defn
|
22
|
+
assert_equal '#<Proj4::PrimeMeridian id="lisbon", defn="9d07\'54.862"W">', prime_meridian.inspect
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_compare
|
26
|
+
u1 = Proj4::PrimeMeridian.get('lisbon')
|
27
|
+
u2 = Proj4::PrimeMeridian.get('lisbon')
|
28
|
+
assert u1 == u2
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_failed_get
|
32
|
+
prime_meridian = Proj4::PrimeMeridian.get('foo')
|
33
|
+
assert_nil prime_meridian
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_new
|
37
|
+
assert_raise TypeError do
|
38
|
+
Proj4::PrimeMeridian.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if Proj4::LIBVERSION >= 449
|
6
|
+
class ProjectionTypesTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_all
|
9
|
+
pt = Proj4::ProjectionType.list.sort.collect{ |u| u.id }
|
10
|
+
assert pt.index('merc')
|
11
|
+
assert pt.index('aea')
|
12
|
+
assert pt.index('bipc')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_one
|
16
|
+
pt = Proj4::ProjectionType.get('merc')
|
17
|
+
assert_kind_of Proj4::ProjectionType, pt
|
18
|
+
assert_equal 'merc', pt.id
|
19
|
+
assert_equal 'merc', pt.to_s
|
20
|
+
assert_equal 'Mercator', pt.name
|
21
|
+
assert_equal "Mercator\n\tCyl, Sph&Ell\n\tlat_ts=", pt.descr
|
22
|
+
assert_equal '#<Proj4::ProjectionType id="merc", name="Mercator">', pt.inspect
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_compare
|
26
|
+
pt1 = Proj4::ProjectionType.get('merc')
|
27
|
+
pt2 = Proj4::ProjectionType.get('merc')
|
28
|
+
assert pt1 == pt2
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_failed_get
|
32
|
+
assert_nil Proj4::ProjectionType.get('foo')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_new
|
36
|
+
assert_raise TypeError do
|
37
|
+
Proj4::ProjectionType.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
$: << 'lib' << 'ext'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class SimpleProjectionTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@proj_gk = Proj4::Projection.new(["init=epsg:31467"])
|
9
|
+
@lon = 8.4302123334
|
10
|
+
@lat = 48.9906726079
|
11
|
+
@rw = 3458305
|
12
|
+
@hw = 5428192
|
13
|
+
end
|
14
|
+
|
15
|
+
def rad2deg(rad)
|
16
|
+
rad * Proj4::RAD_TO_DEG
|
17
|
+
end
|
18
|
+
|
19
|
+
def deg2rad(deg)
|
20
|
+
deg * Proj4::DEG_TO_RAD
|
21
|
+
end
|
22
|
+
|
23
|
+
# echo "8.4302123334 48.9906726079" | proj +init=epsg:31467 -
|
24
|
+
def test_forward_gk
|
25
|
+
result = @proj_gk.forward( Proj4::Point.new( deg2rad(@lon), deg2rad(@lat) ) )
|
26
|
+
assert_in_delta @rw, result.x, 0.1
|
27
|
+
assert_in_delta @hw, result.y, 0.1
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_forward_gk_degrees
|
31
|
+
result = @proj_gk.forwardDeg( Proj4::Point.new( @lon, @lat ) )
|
32
|
+
assert_in_delta @rw, result.x, 0.1
|
33
|
+
assert_in_delta @hw, result.y, 0.1
|
34
|
+
end
|
35
|
+
|
36
|
+
# echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
|
37
|
+
def test_inverse_gk
|
38
|
+
result = @proj_gk.inverse( Proj4::Point.new(@rw, @hw) )
|
39
|
+
assert_in_delta @lon, rad2deg(result.x), 0.000000001
|
40
|
+
assert_in_delta @lat, rad2deg(result.y), 0.000000001
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_inverse_gk_degrees
|
44
|
+
result = @proj_gk.inverseDeg( Proj4::Point.new(@rw, @hw) )
|
45
|
+
assert_in_delta @lon, result.x, 0.000000001
|
46
|
+
assert_in_delta @lat, result.y, 0.000000001
|
47
|
+
end
|
48
|
+
|
49
|
+
# echo "190 92" | proj +init=epsg:31467 -
|
50
|
+
def test_out_of_bounds
|
51
|
+
assert_raise Proj4::LatitudeOrLongitudeExceededLimitsError do
|
52
|
+
@proj_gk.forward( Proj4::Point.new( deg2rad(190), deg2rad(92) ) )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|