proj4rb 1.0.0 → 2.0.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.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/ChangeLog +46 -0
  3. data/Gemfile +4 -0
  4. data/README.rdoc +158 -148
  5. data/Rakefile +26 -41
  6. data/lib/area.rb +32 -0
  7. data/lib/config.rb +70 -0
  8. data/lib/context.rb +103 -0
  9. data/lib/coordinate.rb +197 -0
  10. data/lib/crs.rb +206 -0
  11. data/lib/ellipsoid.rb +42 -0
  12. data/lib/error.rb +18 -0
  13. data/lib/operation.rb +43 -0
  14. data/lib/pj_object.rb +82 -0
  15. data/lib/point.rb +72 -0
  16. data/lib/prime_meridian.rb +40 -0
  17. data/lib/proj.rb +31 -0
  18. data/lib/proj4.rb +3 -469
  19. data/lib/projection.rb +207 -0
  20. data/lib/transformation.rb +61 -0
  21. data/lib/unit.rb +54 -0
  22. data/proj4rb.gemspec +31 -0
  23. data/test/abstract_test.rb +7 -0
  24. data/test/context_test.rb +82 -0
  25. data/test/coordinate_test.rb +35 -0
  26. data/test/crs_test.rb +373 -0
  27. data/test/ellipsoid_test.rb +34 -0
  28. data/test/operation_test.rb +29 -0
  29. data/test/prime_meridians_test.rb +33 -0
  30. data/test/proj_test.rb +17 -0
  31. data/test/projection_test.rb +224 -0
  32. data/test/transformation_test.rb +68 -0
  33. data/test/unit_test.rb +47 -0
  34. metadata +82 -77
  35. data/data/GL27 +0 -22
  36. data/data/MD +0 -0
  37. data/data/TN +0 -0
  38. data/data/WI +0 -0
  39. data/data/WO +0 -0
  40. data/data/conus +0 -0
  41. data/data/epsg +0 -5443
  42. data/data/epsg-deprecated +0 -2
  43. data/data/esri +0 -5937
  44. data/data/esri.extra +0 -948
  45. data/data/hawaii +0 -0
  46. data/data/nad.lst +0 -142
  47. data/data/nad27 +0 -809
  48. data/data/nad83 +0 -744
  49. data/data/ntv1_can.dat +0 -0
  50. data/data/null +0 -0
  51. data/data/other.extra +0 -49
  52. data/data/proj_def.dat +0 -17
  53. data/data/prvi +0 -0
  54. data/data/stgeorge +0 -0
  55. data/data/stlrnc +0 -0
  56. data/data/stpaul +0 -0
  57. data/data/world +0 -212
  58. data/example/basic.rb +0 -18
  59. data/example/list-datums.rb +0 -17
  60. data/example/list-ellipsoids.rb +0 -17
  61. data/example/list-errors.rb +0 -11
  62. data/example/list-prime-meridians.rb +0 -17
  63. data/example/list-projection-types.rb +0 -17
  64. data/example/list-units.rb +0 -17
  65. data/example/version.rb +0 -8
  66. data/ext/Makefile +0 -238
  67. data/ext/extconf.rb +0 -16
  68. data/ext/mkmf.log +0 -103
  69. data/ext/out.log +0 -0
  70. data/ext/proj4_ruby-x64-mingw32.def +0 -2
  71. data/ext/proj4_ruby.so +0 -0
  72. data/ext/projrb.c +0 -566
  73. data/ext/projrb.o +0 -0
  74. data/ext/vc/proj4_ruby.sln +0 -19
  75. data/ext/vc/proj4_ruby.vcproj +0 -208
  76. data/test/test_constants.rb +0 -18
  77. data/test/test_create_projection.rb +0 -63
  78. data/test/test_datums.rb +0 -45
  79. data/test/test_ellipsoids.rb +0 -46
  80. data/test/test_errors.rb +0 -66
  81. data/test/test_init_projection.rb +0 -109
  82. data/test/test_prime_meridians.rb +0 -45
  83. data/test/test_projection_type.rb +0 -44
  84. data/test/test_simple_projection.rb +0 -58
  85. data/test/test_suite.rb +0 -14
  86. data/test/test_transform.rb +0 -115
  87. data/test/test_units.rb +0 -46
@@ -1,109 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- class InitProjectionTest < Minitest::Test
7
-
8
- def setup
9
- # NAD27(76) / UTM zone 17N
10
- # <2029> +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs no_defs <>
11
- @epsg2029i = ['init=epsg:2029']
12
- @epsg2029x = ['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'].sort
13
-
14
- @nad = ' +init=epsg:2029 +proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs'
15
- end
16
-
17
- def test_arg_fail
18
- assert_raise ArgumentError do
19
- Proj4::Projection._parse_init_parameters()
20
- end
21
- assert_raise ArgumentError do
22
- Proj4::Projection._parse_init_parameters(nil)
23
- end
24
- assert_raise ArgumentError do
25
- Proj4::Projection._parse_init_parameters(1)
26
- end
27
- end
28
-
29
- def test_arg_string
30
- args = Proj4::Projection._parse_init_parameters('init=epsg:2029')
31
- assert_equal @epsg2029i, args
32
- args = Proj4::Projection._parse_init_parameters(' proj=utm zone=17 ellps=clrk66 units=m no_defs ')
33
- assert_equal @epsg2029x, args.sort
34
- end
35
-
36
- def test_arg_string_with_plus
37
- args = Proj4::Projection._parse_init_parameters('+init=epsg:2029')
38
- assert_equal @epsg2029i, args
39
- args = Proj4::Projection._parse_init_parameters('+proj=utm +zone=17 +ellps=clrk66 +units=m +no_defs')
40
- assert_equal @epsg2029x, args.sort
41
- end
42
-
43
- def test_arg_array
44
- args = Proj4::Projection._parse_init_parameters(['init=epsg:2029'])
45
- assert_equal @epsg2029i, args
46
- args = Proj4::Projection._parse_init_parameters(['proj=utm', 'zone=17', 'ellps=clrk66', 'units=m', 'no_defs'])
47
- assert_equal @epsg2029x, args.sort
48
- end
49
-
50
- def test_arg_array_with_plus
51
- args = Proj4::Projection._parse_init_parameters(['+init=epsg:2029'])
52
- assert_equal @epsg2029i, args
53
- args = Proj4::Projection._parse_init_parameters(['+proj=utm', '+zone=17', '+ellps=clrk66', '+units=m', '+no_defs'])
54
- assert_equal @epsg2029x, args.sort
55
- end
56
-
57
- def test_arg_hash_with_string
58
- args = Proj4::Projection._parse_init_parameters( {'init' => 'epsg:2029'} )
59
- assert_equal @epsg2029i, args
60
- args = Proj4::Projection._parse_init_parameters( {'proj' => 'utm', 'zone' => '17', 'ellps' => 'clrk66', 'units' => 'm', 'no_defs' => nil} )
61
- assert_equal @epsg2029x, args.sort
62
- end
63
-
64
- def test_arg_hash_with_symbol
65
- args = Proj4::Projection._parse_init_parameters( {:init => 'epsg:2029'} )
66
- assert_equal @epsg2029i, args
67
- args = Proj4::Projection._parse_init_parameters( {:proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil} )
68
- assert_equal @epsg2029x, args.sort
69
- end
70
-
71
- def test_arg_hash_with_symbol_simple
72
- args = Proj4::Projection._parse_init_parameters( :init => 'epsg:2029' )
73
- assert_equal @epsg2029i, args
74
- args = Proj4::Projection._parse_init_parameters( :proj => 'utm', :zone => '17', :ellps => 'clrk66', :units => 'm', :no_defs => nil )
75
- assert_equal @epsg2029x, args.sort
76
- end
77
-
78
- def test_arg_projection
79
- proj = Proj4::Projection.new(['init=epsg:2029'])
80
- args = Proj4::Projection._parse_init_parameters(proj)
81
- assert_equal [@epsg2029i, @epsg2029x].flatten.sort, args.sort
82
- end
83
-
84
- def test_init_arg_string
85
- proj = Proj4::Projection.new('+init=epsg:2029')
86
- assert_equal @nad, proj.getDef
87
- end
88
-
89
- def test_init_arg_array
90
- proj = Proj4::Projection.new(['init=epsg:2029'])
91
- assert_equal @nad, proj.getDef
92
- end
93
-
94
- def test_init_arg_hash
95
- proj = Proj4::Projection.new( :proj => 'utm', 'zone' => '17', '+ellps' => 'clrk66', :units => 'm', :no_defs => nil )
96
- assert_equal @epsg2029x, proj.getDef.strip.split(' ').collect{ |a| a.sub(/^\+/, '') }.sort
97
- end
98
-
99
- def test_init_arg_fail
100
- assert_raise Proj4::UnknownProjectionIdError do
101
- Proj4::Projection.new( :proj => 'xxxx' )
102
- end
103
- assert_raise Proj4::ProjectionNotNamedError do
104
- Proj4::Projection.new( :foo => 'xxxx' )
105
- end
106
- end
107
-
108
- end
109
-
@@ -1,45 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- if Proj4::LIBVERSION >= 449
7
- class PrimeMeridiansTest < Minitest::Test
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
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
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
44
- end
45
-
@@ -1,44 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- if Proj4::LIBVERSION >= 449
7
- class ProjectionTypesTest < Minitest::Test
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
25
-
26
- def test_compare
27
- pt1 = Proj4::ProjectionType.get('merc')
28
- pt2 = Proj4::ProjectionType.get('merc')
29
- assert pt1 == pt2
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
43
- end
44
-
@@ -1,58 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- class SimpleProjectionTest < Minitest::Test
7
-
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
56
-
57
- end
58
-
@@ -1,14 +0,0 @@
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,115 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- class TransformTest < Minitest::Test
7
-
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))
51
- end
52
- end
53
-
54
- def test_not_a_point
55
- assert_raise TypeError do
56
- point = @proj_wgs84.transform(@proj_gk, nil)
57
- end
58
- end
59
-
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))
63
- end
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
73
- 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
82
- end
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') )
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
113
-
114
- end
115
-
@@ -1,46 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require File.join(File.dirname(__FILE__), '..', 'lib', 'proj4')
4
- require 'minitest/autorun'
5
-
6
- if Proj4::LIBVERSION >= 449
7
- class UnitsTest < Minitest::Test
8
-
9
- def test_get_all
10
- units = Proj4::Unit.list.sort.collect{ |u| u.id }
11
- assert units.index('km')
12
- assert units.index('m')
13
- assert units.index('yd')
14
- assert units.index('us-mi')
15
- end
16
-
17
- def test_one
18
- unit = Proj4::Unit.get('km')
19
- assert_kind_of Proj4::Unit, unit
20
- assert_equal 'km', unit.id
21
- assert_equal 'km', unit.to_s
22
- assert_equal '1000.', unit.to_meter
23
- assert_equal 'Kilometer', unit.name
24
- assert_equal '#<Proj4::Unit id="km", to_meter="1000.", name="Kilometer">', unit.inspect
25
- end
26
-
27
- def test_compare
28
- u1 = Proj4::Unit.get('km')
29
- u2 = Proj4::Unit.get('km')
30
- assert u1 == u2
31
- end
32
-
33
- def test_failed_get
34
- unit = Proj4::Unit.get('foo')
35
- assert_nil unit
36
- end
37
-
38
- def test_new
39
- assert_raise TypeError do
40
- Proj4::Unit.new
41
- end
42
- end
43
-
44
- end
45
- end
46
-