proj4rb 0.4.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/MIT-LICENSE +9 -0
  2. data/README.rdoc +163 -0
  3. data/Rakefile +72 -0
  4. data/data/GL27 +22 -0
  5. data/data/MD +0 -0
  6. data/data/TN +0 -0
  7. data/data/WI +0 -0
  8. data/data/WO +0 -0
  9. data/data/conus +0 -0
  10. data/data/epsg +5443 -0
  11. data/data/epsg-deprecated +2 -0
  12. data/data/esri +5937 -0
  13. data/data/esri.extra +948 -0
  14. data/data/hawaii +0 -0
  15. data/data/nad.lst +142 -0
  16. data/data/nad27 +809 -0
  17. data/data/nad83 +744 -0
  18. data/data/ntv1_can.dat +0 -0
  19. data/data/null +0 -0
  20. data/data/other.extra +49 -0
  21. data/data/proj_def.dat +17 -0
  22. data/data/prvi +0 -0
  23. data/data/stgeorge +0 -0
  24. data/data/stlrnc +0 -0
  25. data/data/stpaul +0 -0
  26. data/data/world +212 -0
  27. data/example/basic.rb +18 -0
  28. data/example/list-datums.rb +17 -0
  29. data/example/list-ellipsoids.rb +17 -0
  30. data/example/list-errors.rb +11 -0
  31. data/example/list-prime-meridians.rb +17 -0
  32. data/example/list-projection-types.rb +17 -0
  33. data/example/list-units.rb +17 -0
  34. data/example/version.rb +8 -0
  35. data/ext/Makefile +212 -0
  36. data/ext/extconf.rb +13 -0
  37. data/ext/mkmf.log +25 -0
  38. data/ext/projrb.c +560 -0
  39. data/ext/vc/proj4_ruby.sln +19 -0
  40. data/ext/vc/proj4_ruby.vcproj +208 -0
  41. data/lib/1.8/proj4_ruby.so +0 -0
  42. data/lib/1.9/proj4_ruby.so +0 -0
  43. data/lib/proj4.rb +466 -0
  44. data/test/test_constants.rb +20 -0
  45. data/test/test_create_projection.rb +64 -0
  46. data/test/test_datums.rb +44 -0
  47. data/test/test_ellipsoids.rb +45 -0
  48. data/test/test_errors.rb +70 -0
  49. data/test/test_init_projection.rb +108 -0
  50. data/test/test_prime_meridians.rb +44 -0
  51. data/test/test_projection_type.rb +43 -0
  52. data/test/test_simple_projection.rb +57 -0
  53. data/test/test_transform.rb +114 -0
  54. data/test/test_units.rb +45 -0
  55. metadata +145 -0
@@ -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
+
@@ -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
+
@@ -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
+