proj4rb 0.4.0-x86-mingw32 → 0.4.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +1,45 @@
1
- $: << 'lib' << 'ext'
1
+ # encoding: UTF-8
2
+
2
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
3
4
  require 'test/unit'
4
5
 
5
6
  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
7
+ class PrimeMeridiansTest < Test::Unit::TestCase
8
+
9
+ def test_get_all
10
+ prime_meridians = Proj4::PrimeMeridian.list.sort.collect{ |u| u.id}
11
+ assert prime_meridians.index('greenwich')
12
+ assert prime_meridians.index('athens')
13
+ assert prime_meridians.index('lisbon')
14
+ assert prime_meridians.index('rome')
15
+ end
41
16
 
17
+ def test_one
18
+ prime_meridian = Proj4::PrimeMeridian.get('lisbon')
19
+ assert_kind_of Proj4::PrimeMeridian, prime_meridian
20
+ assert_equal 'lisbon', prime_meridian.id
21
+ assert_equal 'lisbon', prime_meridian.to_s
22
+ assert_equal '9d07\'54.862"W', prime_meridian.defn
23
+ assert_equal '#<Proj4::PrimeMeridian id="lisbon", defn="9d07\'54.862"W">', prime_meridian.inspect
42
24
  end
25
+
26
+ def test_compare
27
+ u1 = Proj4::PrimeMeridian.get('lisbon')
28
+ u2 = Proj4::PrimeMeridian.get('lisbon')
29
+ assert u1 == u2
30
+ end
31
+
32
+ def test_failed_get
33
+ prime_meridian = Proj4::PrimeMeridian.get('foo')
34
+ assert_nil prime_meridian
35
+ end
36
+
37
+ def test_new
38
+ assert_raise TypeError do
39
+ Proj4::PrimeMeridian.new
40
+ end
41
+ end
42
+
43
+ end
43
44
  end
44
45
 
@@ -1,43 +1,44 @@
1
- $: << 'lib' << 'ext'
1
+ # encoding: UTF-8
2
+
2
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
3
4
  require 'test/unit'
4
5
 
5
6
  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
7
+ class ProjectionTypesTest < Test::Unit::TestCase
8
+
9
+ def test_get_all
10
+ pt = Proj4::ProjectionType.list.sort.collect{ |u| u.id }
11
+ assert pt.index('merc')
12
+ assert pt.index('aea')
13
+ assert pt.index('bipc')
14
+ end
15
+
16
+ def test_one
17
+ pt = Proj4::ProjectionType.get('merc')
18
+ assert_kind_of Proj4::ProjectionType, pt
19
+ assert_equal 'merc', pt.id
20
+ assert_equal 'merc', pt.to_s
21
+ assert_equal 'Mercator', pt.name
22
+ assert_equal "Mercator\n\tCyl, Sph&Ell\n\tlat_ts=", pt.descr
23
+ assert_equal '#<Proj4::ProjectionType id="merc", name="Mercator">', pt.inspect
24
+ end
40
25
 
26
+ def test_compare
27
+ pt1 = Proj4::ProjectionType.get('merc')
28
+ pt2 = Proj4::ProjectionType.get('merc')
29
+ assert pt1 == pt2
41
30
  end
31
+
32
+ def test_failed_get
33
+ assert_nil Proj4::ProjectionType.get('foo')
34
+ end
35
+
36
+ def test_new
37
+ assert_raise TypeError do
38
+ Proj4::ProjectionType.new
39
+ end
40
+ end
41
+
42
+ end
42
43
  end
43
44
 
@@ -1,57 +1,58 @@
1
- $: << 'lib' << 'ext'
1
+ # encoding: UTF-8
2
+
2
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
3
4
  require 'test/unit'
4
5
 
5
6
  class SimpleProjectionTest < Test::Unit::TestCase
6
7
 
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
8
+ def setup
9
+ @proj_gk = Proj4::Projection.new(["init=epsg:31467"])
10
+ @lon = 8.4302123334
11
+ @lat = 48.9906726079
12
+ @rw = 3458305
13
+ @hw = 5428192
14
+ end
15
+
16
+ def rad2deg(rad)
17
+ rad * Proj4::RAD_TO_DEG
18
+ end
19
+
20
+ def deg2rad(deg)
21
+ deg * Proj4::DEG_TO_RAD
22
+ end
23
+
24
+ # echo "8.4302123334 48.9906726079" | proj +init=epsg:31467 -
25
+ def test_forward_gk
26
+ result = @proj_gk.forward( Proj4::Point.new( deg2rad(@lon), deg2rad(@lat) ) )
27
+ assert_in_delta @rw, result.x, 0.1
28
+ assert_in_delta @hw, result.y, 0.1
29
+ end
30
+
31
+ def test_forward_gk_degrees
32
+ result = @proj_gk.forwardDeg( Proj4::Point.new( @lon, @lat ) )
33
+ assert_in_delta @rw, result.x, 0.1
34
+ assert_in_delta @hw, result.y, 0.1
35
+ end
36
+
37
+ # echo "3458305 5428192" | invproj -f '%.10f' +init=epsg:31467 -
38
+ def test_inverse_gk
39
+ result = @proj_gk.inverse( Proj4::Point.new(@rw, @hw) )
40
+ assert_in_delta @lon, rad2deg(result.x), 0.000000001
41
+ assert_in_delta @lat, rad2deg(result.y), 0.000000001
42
+ end
43
+
44
+ def test_inverse_gk_degrees
45
+ result = @proj_gk.inverseDeg( Proj4::Point.new(@rw, @hw) )
46
+ assert_in_delta @lon, result.x, 0.000000001
47
+ assert_in_delta @lat, result.y, 0.000000001
48
+ end
49
+
50
+ # echo "190 92" | proj +init=epsg:31467 -
51
+ def test_out_of_bounds
52
+ assert_raise Proj4::LatitudeOrLongitudeExceededLimitsError do
53
+ @proj_gk.forward( Proj4::Point.new( deg2rad(190), deg2rad(92) ) )
54
+ end
55
+ end
55
56
 
56
57
  end
57
58
 
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+
3
+ require './test_constants'
4
+ require './test_create_projection'
5
+ require './test_datums'
6
+ require './test_ellipsoids'
7
+ require './test_errors'
8
+ require './test_init_projection'
9
+ require './test_prime_meridians'
10
+ require './test_projection_type'
11
+ require './test_simple_projection'
12
+ require './test_transform'
13
+ require './test_units'
14
+
@@ -1,114 +1,115 @@
1
- $: << 'lib' << 'ext'
1
+ # encoding: UTF-8
2
+
2
3
  require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
3
4
  require 'test/unit'
4
5
 
5
6
  class TransformTest < Test::Unit::TestCase
6
7
 
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
8
+ PRECISION = 0.1 ** 8
9
+
10
+ def setup
11
+ @proj_wgs84 = Proj4::Projection.new(["init=epsg:4326"])
12
+ @proj_gk = Proj4::Projection.new(["init=epsg:31467"])
13
+ @proj_merc = Proj4::Projection.new(["proj=merc"])
14
+ @lon = 8.4293092923
15
+ @lat = 48.9896114523
16
+ @rw = 3458305
17
+ @hw = 5428192
18
+ @zw = -5.1790915237
19
+ end
20
+
21
+ # echo "3458305 5428192" | cs2cs -f '%.10f' +init=epsg:31467 +to +init=epsg:4326 -
22
+ def test_gk_to_wgs84
23
+ from = Proj4::Point.new(@rw, @hw, @zw)
24
+ to = @proj_gk.transform(@proj_wgs84, from)
25
+ assert_not_equal from.object_id, to.object_id
26
+ assert_in_delta @lon, to.x * Proj4::RAD_TO_DEG, PRECISION
27
+ assert_in_delta @lat, to.y * Proj4::RAD_TO_DEG, PRECISION
28
+ assert_in_delta 0, to.z, PRECISION
29
+ end
30
+
31
+ def test_gk_to_wgs84_inplace
32
+ from = Proj4::Point.new(@rw, @hw, @zw)
33
+ to = @proj_gk.transform!(@proj_wgs84, from)
34
+ assert_equal from.object_id, to.object_id
35
+ assert_in_delta @lon, to.x * Proj4::RAD_TO_DEG, PRECISION
36
+ assert_in_delta @lat, to.y * Proj4::RAD_TO_DEG, PRECISION
37
+ assert_in_delta 0, to.z, PRECISION
38
+ end
39
+
40
+ # echo "8.4293092923 48.9896114523" | cs2cs -f '%.10f' +init=epsg:4326 +to +init=epsg:31467 -
41
+ def test_wgs84_to_gk
42
+ point = @proj_wgs84.transform(@proj_gk, Proj4::Point.new(@lon * Proj4::DEG_TO_RAD, @lat * Proj4::DEG_TO_RAD, 0))
43
+ assert_equal @rw, point.x.round
44
+ assert_equal @hw, point.y.round
45
+ assert_in_delta @zw, point.z, PRECISION
46
+ end
47
+
48
+ def test_no_dst_proj
49
+ assert_raise TypeError do
50
+ point = @proj_wgs84.transform(nil, Proj4::Point.new(@lon * Proj4::DEG_TO_RAD, @lat * Proj4::DEG_TO_RAD, 0))
18
51
  end
52
+ end
19
53
 
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
54
+ def test_not_a_point
55
+ assert_raise TypeError do
56
+ point = @proj_wgs84.transform(@proj_gk, nil)
28
57
  end
58
+ end
29
59
 
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
60
+ def test_mercator_at_pole_raise
61
+ assert_raise Proj4::ToleranceConditionError do
62
+ point = @proj_wgs84.transform(@proj_merc, Proj4::Point.new(0, 90 * Proj4::DEG_TO_RAD, 0))
37
63
  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
64
+ end
65
+
66
+ def test_mercator_at_pole_rescue
67
+ begin
68
+ point = @proj_wgs84.transform(@proj_merc, Proj4::Point.new(0, 90 * Proj4::DEG_TO_RAD, 0))
69
+ rescue => exception
70
+ assert_kind_of Proj4::ToleranceConditionError, exception
71
+ assert_equal 'tolerance condition error', exception.message
72
+ assert_equal 20, exception.errnum
45
73
  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
74
+ end
75
+
76
+ class XYPoint
77
+ attr_accessor :x, :y, :extra
78
+ def initialize(x, y, extra)
79
+ @x = x
80
+ @y = y
81
+ @extra = extra
73
82
  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
83
+ end
84
+ def test_no_z
85
+ point = @proj_gk.transform(@proj_wgs84, XYPoint.new(@rw, @hw, 'foo') )
86
+ assert_kind_of XYPoint, point
87
+ assert_equal 'foo', point.extra
88
+ assert_in_delta @lon, point.x * Proj4::RAD_TO_DEG, PRECISION
89
+ assert_in_delta @lat, point.y * Proj4::RAD_TO_DEG, PRECISION
90
+ end
91
+
92
+ def test_no_float
93
+ assert_raise TypeError do
94
+ @proj_gk.transform(@proj_wgs84, XYPoint.new('x', 'y', 'foo') )
111
95
  end
96
+ end
97
+
98
+ def test_syscallerr
99
+ # we need a test here that checks whether transform() properly returns a SystemCallError exception
100
+ end
101
+
102
+ def test_collection
103
+ from0 = Proj4::Point.new(@rw, @hw, @zw)
104
+ from1 = Proj4::Point.new(0, 0, 0)
105
+ collection = @proj_gk.transform_all!(@proj_wgs84, [from0, from1])
106
+ to0 = collection[0]
107
+ to1 = collection[1]
108
+ assert_equal from1.object_id, to1.object_id
109
+ assert_in_delta @lon, to0.x * Proj4::RAD_TO_DEG, PRECISION
110
+ assert_in_delta @lat, to0.y * Proj4::RAD_TO_DEG, PRECISION
111
+ assert_in_delta 0, to0.z, PRECISION
112
+ end
112
113
 
113
114
  end
114
115