proj4rb 0.2.0-i486-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +8 -0
- data/README +151 -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 +9 -0
- data/lib/proj4.rb +518 -0
- data/lib/projrb.so +0 -0
- data/rakefile.rb +72 -0
- data/src/extconf.rb +8 -0
- data/src/projrb.c +532 -0
- data/test/test_constants.rb +20 -0
- data/test/test_create_projection.rb +63 -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 +64 -0
- data/test/test_transform.rb +114 -0
- data/test/test_units.rb +45 -0
- data/test/test_uv.rb +53 -0
- metadata +84 -0
data/test/test_errors.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
$: << 'lib'
|
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.strerrno(-1)
|
42
|
+
assert_equal 'reciprocal flattening (1/f) = 0', Proj4::Error.strerrno(-10)
|
43
|
+
assert_equal 'unknown error', Proj4::Error.strerrno(0)
|
44
|
+
assert_match /^invalid projection system error/, Proj4::Error.strerrno(-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'
|
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'
|
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'
|
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,64 @@
|
|
1
|
+
$: << 'lib'
|
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
|
+
# for backwards compatibility
|
37
|
+
def test_forward_gk_degrees_UV
|
38
|
+
result = @proj_gk.forwardDeg( Proj4::UV.new( @lon, @lat ) )
|
39
|
+
assert_in_delta @rw, result.u, 0.1
|
40
|
+
assert_in_delta @hw, result.v, 0.1
|
41
|
+
end
|
42
|
+
|
43
|
+
# echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
|
44
|
+
def test_inverse_gk
|
45
|
+
result = @proj_gk.inverse( Proj4::Point.new(@rw, @hw) )
|
46
|
+
assert_in_delta @lon, rad2deg(result.x), 0.000000001
|
47
|
+
assert_in_delta @lat, rad2deg(result.y), 0.000000001
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_inverse_gk_degrees
|
51
|
+
result = @proj_gk.inverseDeg( Proj4::Point.new(@rw, @hw) )
|
52
|
+
assert_in_delta @lon, result.x, 0.000000001
|
53
|
+
assert_in_delta @lat, result.y, 0.000000001
|
54
|
+
end
|
55
|
+
|
56
|
+
# echo "190 92" | proj +init=epsg:31467 -
|
57
|
+
def test_out_of_bounds
|
58
|
+
assert_raise Proj4::LatitudeOrLongitudeExceededLimitsError do
|
59
|
+
@proj_gk.forward( Proj4::Point.new( deg2rad(190), deg2rad(92) ) )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,114 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TransformTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
PRECISION = 0.1 ** 8
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@proj_wgs84 = Proj4::Projection.new(["init=epsg:4326"])
|
11
|
+
@proj_gk = Proj4::Projection.new(["init=epsg:31467"])
|
12
|
+
@proj_merc = Proj4::Projection.new(["proj=merc"])
|
13
|
+
@lon = 8.4293092923
|
14
|
+
@lat = 48.9896114523
|
15
|
+
@rw = 3458305
|
16
|
+
@hw = 5428192
|
17
|
+
@zw = -5.1790915237
|
18
|
+
end
|
19
|
+
|
20
|
+
# echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
|
21
|
+
def test_gk_to_wgs84
|
22
|
+
from = Proj4::Point.new(@rw, @hw, @zw)
|
23
|
+
to = @proj_gk.transform(@proj_wgs84, from)
|
24
|
+
assert_not_equal from.object_id, to.object_id
|
25
|
+
assert_in_delta @lon, to.x * Proj4::RAD_TO_DEG, PRECISION
|
26
|
+
assert_in_delta @lat, to.y * Proj4::RAD_TO_DEG, PRECISION
|
27
|
+
assert_in_delta 0, to.z, PRECISION
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_gk_to_wgs84_inplace
|
31
|
+
from = Proj4::Point.new(@rw, @hw, @zw)
|
32
|
+
to = @proj_gk.transform!(@proj_wgs84, from)
|
33
|
+
assert_equal from.object_id, to.object_id
|
34
|
+
assert_in_delta @lon, to.x * Proj4::RAD_TO_DEG, PRECISION
|
35
|
+
assert_in_delta @lat, to.y * Proj4::RAD_TO_DEG, PRECISION
|
36
|
+
assert_in_delta 0, to.z, PRECISION
|
37
|
+
end
|
38
|
+
|
39
|
+
# echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
|
40
|
+
def test_wgs84_to_gk
|
41
|
+
point = @proj_wgs84.transform(@proj_gk, Proj4::Point.new(@lon * Proj4::DEG_TO_RAD, @lat * Proj4::DEG_TO_RAD, 0))
|
42
|
+
assert_equal @rw, point.x.round
|
43
|
+
assert_equal @hw, point.y.round
|
44
|
+
assert_in_delta @zw, point.z, PRECISION
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_no_dst_proj
|
48
|
+
assert_raise TypeError do
|
49
|
+
point = @proj_wgs84.transform(nil, Proj4::Point.new(@lon * Proj4::DEG_TO_RAD, @lat * Proj4::DEG_TO_RAD, 0))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_not_a_point
|
54
|
+
assert_raise TypeError do
|
55
|
+
point = @proj_wgs84.transform(@proj_gk, nil)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_mercator_at_pole_raise
|
60
|
+
assert_raise Proj4::ToleranceConditionError do
|
61
|
+
point = @proj_wgs84.transform(@proj_merc, Proj4::Point.new(0, 90 * Proj4::DEG_TO_RAD, 0))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_mercator_at_pole_rescue
|
66
|
+
begin
|
67
|
+
point = @proj_wgs84.transform(@proj_merc, Proj4::Point.new(0, 90 * Proj4::DEG_TO_RAD, 0))
|
68
|
+
rescue => exception
|
69
|
+
assert_kind_of Proj4::ToleranceConditionError, exception
|
70
|
+
assert_equal 'tolerance condition error', exception.message
|
71
|
+
assert_equal 20, exception.errnum
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class XYPoint
|
76
|
+
attr_accessor :x, :y, :extra
|
77
|
+
def initialize(x, y, extra)
|
78
|
+
@x = x
|
79
|
+
@y = y
|
80
|
+
@extra = extra
|
81
|
+
end
|
82
|
+
end
|
83
|
+
def test_no_z
|
84
|
+
point = @proj_gk.transform(@proj_wgs84, XYPoint.new(@rw, @hw, 'foo') )
|
85
|
+
assert_kind_of XYPoint, point
|
86
|
+
assert_equal 'foo', point.extra
|
87
|
+
assert_in_delta @lon, point.x * Proj4::RAD_TO_DEG, PRECISION
|
88
|
+
assert_in_delta @lat, point.y * Proj4::RAD_TO_DEG, PRECISION
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_no_float
|
92
|
+
assert_raise TypeError do
|
93
|
+
@proj_gk.transform(@proj_wgs84, XYPoint.new('x', 'y', 'foo') )
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_syscallerr
|
98
|
+
# we need a test here that checks whether transform() properly returns a SystemCallError exception
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_collection
|
102
|
+
from0 = Proj4::Point.new(@rw, @hw, @zw)
|
103
|
+
from1 = Proj4::Point.new(0, 0, 0)
|
104
|
+
collection = @proj_gk.transform_all!(@proj_wgs84, [from0, from1])
|
105
|
+
to0 = collection[0]
|
106
|
+
to1 = collection[1]
|
107
|
+
assert_equal from1.object_id, to1.object_id
|
108
|
+
assert_in_delta @lon, to0.x * Proj4::RAD_TO_DEG, PRECISION
|
109
|
+
assert_in_delta @lat, to0.y * Proj4::RAD_TO_DEG, PRECISION
|
110
|
+
assert_in_delta 0, to0.z, PRECISION
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
data/test/test_units.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if Proj4::LIBVERSION >= 449
|
6
|
+
class UnitsTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_get_all
|
9
|
+
units = Proj4::Unit.list.sort.collect{ |u| u.id }
|
10
|
+
assert units.index('km')
|
11
|
+
assert units.index('m')
|
12
|
+
assert units.index('yd')
|
13
|
+
assert units.index('us-mi')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_one
|
17
|
+
unit = Proj4::Unit.get('km')
|
18
|
+
assert_kind_of Proj4::Unit, unit
|
19
|
+
assert_equal 'km', unit.id
|
20
|
+
assert_equal 'km', unit.to_s
|
21
|
+
assert_equal '1000.', unit.to_meter
|
22
|
+
assert_equal 'Kilometer', unit.name
|
23
|
+
assert_equal '#<Proj4::Unit id="km", to_meter="1000.", name="Kilometer">', unit.inspect
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_compare
|
27
|
+
u1 = Proj4::Unit.get('km')
|
28
|
+
u2 = Proj4::Unit.get('km')
|
29
|
+
assert u1 == u2
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_failed_get
|
33
|
+
unit = Proj4::Unit.get('foo')
|
34
|
+
assert_nil unit
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_new
|
38
|
+
assert_raise TypeError do
|
39
|
+
Proj4::Unit.new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/test/test_uv.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
$: << 'lib'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
# this is needed to get rid of the "UV is deprecated" warnings
|
6
|
+
$VERBOSE = nil
|
7
|
+
|
8
|
+
class UVTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_create_set_get
|
11
|
+
uv = Proj4::UV.new(10.1, 20.2)
|
12
|
+
assert_kind_of Proj4::UV, uv
|
13
|
+
assert_equal 10.1, uv.u
|
14
|
+
assert_equal 20.2, uv.v
|
15
|
+
uv.u = 30.3
|
16
|
+
assert_equal 30.3, uv.u
|
17
|
+
uv.v = 40.4
|
18
|
+
assert_equal 40.4, uv.v
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_copy
|
22
|
+
uv1 = Proj4::UV.new(10.1, 20.2)
|
23
|
+
uv2 = uv1.dup
|
24
|
+
assert_equal uv1, uv2
|
25
|
+
uv3 = uv1.clone
|
26
|
+
assert_equal uv1, uv3
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_failed_creation
|
30
|
+
assert_raise ArgumentError do
|
31
|
+
Proj4::UV.new(1)
|
32
|
+
end
|
33
|
+
assert_raise ArgumentError do
|
34
|
+
Proj4::UV.new(1, 2, 3)
|
35
|
+
end
|
36
|
+
assert_raise TypeError do
|
37
|
+
Proj4::UV.new('foo', 'bar')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_equality
|
42
|
+
uv1 = Proj4::UV.new(10.1, 20.2)
|
43
|
+
uv2 = Proj4::UV.new(10.1, 20.2)
|
44
|
+
assert_equal uv1, uv2
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_stringify
|
48
|
+
uv = Proj4::UV.new(10.1, 20.2)
|
49
|
+
assert_equal '10.1,20.2', uv.to_s
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: proj4rb
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-08-31 00:00:00 +02:00
|
8
|
+
summary: Ruby bindings for the Proj.4 Carthographic Projection library
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: guilhem.vellut@gmail.com
|
12
|
+
homepage: http://thepochisuperstarmegashow.com
|
13
|
+
rubyforge_project: proj4rb
|
14
|
+
description: 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.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: i486-linux
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Guilhem Vellut
|
31
|
+
files:
|
32
|
+
- lib/proj4.rb
|
33
|
+
- lib/projrb.so
|
34
|
+
- example/basic.rb
|
35
|
+
- example/list-errors.rb
|
36
|
+
- example/list-datums.rb
|
37
|
+
- example/list-ellipsoids.rb
|
38
|
+
- example/list-prime-meridians.rb
|
39
|
+
- example/list-projection-types.rb
|
40
|
+
- example/list-units.rb
|
41
|
+
- example/version.rb
|
42
|
+
- src/extconf.rb
|
43
|
+
- src/projrb.c
|
44
|
+
- test/test_simple_projection.rb
|
45
|
+
- test/test_uv.rb
|
46
|
+
- test/test_constants.rb
|
47
|
+
- test/test_units.rb
|
48
|
+
- test/test_create_projection.rb
|
49
|
+
- test/test_datums.rb
|
50
|
+
- test/test_ellipsoids.rb
|
51
|
+
- test/test_transform.rb
|
52
|
+
- test/test_prime_meridians.rb
|
53
|
+
- test/test_errors.rb
|
54
|
+
- test/test_projection_type.rb
|
55
|
+
- test/test_init_projection.rb
|
56
|
+
- README
|
57
|
+
- MIT-LICENSE
|
58
|
+
- rakefile.rb
|
59
|
+
test_files:
|
60
|
+
- test/test_simple_projection.rb
|
61
|
+
- test/test_uv.rb
|
62
|
+
- test/test_constants.rb
|
63
|
+
- test/test_units.rb
|
64
|
+
- test/test_create_projection.rb
|
65
|
+
- test/test_datums.rb
|
66
|
+
- test/test_ellipsoids.rb
|
67
|
+
- test/test_transform.rb
|
68
|
+
- test/test_prime_meridians.rb
|
69
|
+
- test/test_errors.rb
|
70
|
+
- test/test_projection_type.rb
|
71
|
+
- test/test_init_projection.rb
|
72
|
+
rdoc_options:
|
73
|
+
- --main
|
74
|
+
- README
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README
|
77
|
+
executables: []
|
78
|
+
|
79
|
+
extensions: []
|
80
|
+
|
81
|
+
requirements:
|
82
|
+
- Proj.4 C library
|
83
|
+
dependencies: []
|
84
|
+
|