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,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
+
@@ -0,0 +1,114 @@
1
+ $: << 'lib' << 'ext'
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
+
@@ -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 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
+
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proj4rb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
+ platform: x86-mingw32
12
+ authors:
13
+ - Guilhem Vellut
14
+ - Jochen Topf
15
+ - Charlie Savage
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-07-30 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: rake-compiler
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :development
35
+ version_requirements: *id001
36
+ 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 datumspec.\n"
37
+ email:
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - Rakefile
46
+ - README.rdoc
47
+ - MIT-LICENSE
48
+ - data/conus
49
+ - data/epsg
50
+ - data/epsg-deprecated
51
+ - data/esri
52
+ - data/esri.extra
53
+ - data/GL27
54
+ - data/hawaii
55
+ - data/MD
56
+ - data/nad.lst
57
+ - data/nad27
58
+ - data/nad83
59
+ - data/ntv1_can.dat
60
+ - data/null
61
+ - data/other.extra
62
+ - data/proj_def.dat
63
+ - data/prvi
64
+ - data/stgeorge
65
+ - data/stlrnc
66
+ - data/stpaul
67
+ - data/TN
68
+ - data/WI
69
+ - data/WO
70
+ - data/world
71
+ - example/basic.rb
72
+ - example/list-datums.rb
73
+ - example/list-ellipsoids.rb
74
+ - example/list-errors.rb
75
+ - example/list-prime-meridians.rb
76
+ - example/list-projection-types.rb
77
+ - example/list-units.rb
78
+ - example/version.rb
79
+ - ext/extconf.rb
80
+ - ext/Makefile
81
+ - ext/mkmf.log
82
+ - ext/projrb.c
83
+ - ext/vc/proj4_ruby.sln
84
+ - ext/vc/proj4_ruby.vcproj
85
+ - lib/proj4.rb
86
+ - test/test_constants.rb
87
+ - test/test_create_projection.rb
88
+ - test/test_datums.rb
89
+ - test/test_ellipsoids.rb
90
+ - test/test_errors.rb
91
+ - test/test_init_projection.rb
92
+ - test/test_prime_meridians.rb
93
+ - test/test_projection_type.rb
94
+ - test/test_simple_projection.rb
95
+ - test/test_transform.rb
96
+ - test/test_units.rb
97
+ - lib/1.8/proj4_ruby.so
98
+ - lib/1.9/proj4_ruby.so
99
+ homepage: http://proj4rb.rubyforge.org/
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 57
113
+ segments:
114
+ - 1
115
+ - 8
116
+ - 7
117
+ version: 1.8.7
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ requirements:
128
+ - Proj.4 C library
129
+ rubyforge_project: proj4rb
130
+ rubygems_version: 1.8.6
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Ruby bindings for the Proj.4 Carthographic Projection library
134
+ test_files:
135
+ - test/test_constants.rb
136
+ - test/test_create_projection.rb
137
+ - test/test_datums.rb
138
+ - test/test_ellipsoids.rb
139
+ - test/test_errors.rb
140
+ - test/test_init_projection.rb
141
+ - test/test_prime_meridians.rb
142
+ - test/test_projection_type.rb
143
+ - test/test_simple_projection.rb
144
+ - test/test_transform.rb
145
+ - test/test_units.rb