proj4rb 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +26 -15
  3. data/README.rdoc +82 -44
  4. data/Rakefile +27 -27
  5. data/lib/api/api.rb +96 -118
  6. data/lib/api/api_5_0.rb +331 -300
  7. data/lib/api/api_5_1.rb +6 -6
  8. data/lib/api/api_5_2.rb +4 -4
  9. data/lib/api/api_6_0.rb +116 -14
  10. data/lib/api/api_6_1.rb +4 -4
  11. data/lib/api/api_6_2.rb +9 -6
  12. data/lib/api/api_6_3.rb +6 -0
  13. data/lib/api/api_7_0.rb +68 -0
  14. data/lib/api/api_7_1.rb +73 -0
  15. data/lib/api/api_7_2.rb +14 -0
  16. data/lib/api/api_8_0.rb +6 -0
  17. data/lib/api/api_8_1.rb +24 -0
  18. data/lib/api/api_8_2.rb +6 -0
  19. data/lib/api/api_9_1.rb +7 -0
  20. data/lib/api/api_9_2.rb +9 -0
  21. data/lib/api/api_experimental.rb +196 -0
  22. data/lib/proj/area.rb +73 -32
  23. data/lib/proj/axis_info.rb +44 -0
  24. data/lib/proj/bounds.rb +13 -0
  25. data/lib/proj/context.rb +174 -28
  26. data/lib/proj/conversion.rb +92 -0
  27. data/lib/proj/coordinate.rb +281 -197
  28. data/lib/proj/coordinate_operation_mixin.rb +381 -0
  29. data/lib/proj/coordinate_system.rb +137 -0
  30. data/lib/proj/crs.rb +672 -204
  31. data/lib/proj/crs_info.rb +47 -0
  32. data/lib/proj/database.rb +305 -0
  33. data/lib/proj/datum.rb +32 -0
  34. data/lib/proj/datum_ensemble.rb +34 -0
  35. data/lib/proj/ellipsoid.rb +77 -41
  36. data/lib/proj/error.rb +62 -9
  37. data/lib/proj/file_api.rb +166 -0
  38. data/lib/proj/grid.rb +121 -0
  39. data/lib/proj/grid_cache.rb +64 -0
  40. data/lib/proj/grid_info.rb +19 -0
  41. data/lib/proj/network_api.rb +92 -0
  42. data/lib/proj/operation.rb +42 -42
  43. data/lib/proj/operation_factory_context.rb +136 -0
  44. data/lib/proj/parameter.rb +38 -0
  45. data/lib/proj/parameters.rb +106 -0
  46. data/lib/proj/pj_object.rb +670 -80
  47. data/lib/proj/pj_objects.rb +44 -0
  48. data/lib/proj/prime_meridian.rb +65 -39
  49. data/lib/proj/projection.rb +698 -207
  50. data/lib/proj/session.rb +46 -0
  51. data/lib/proj/strings.rb +32 -0
  52. data/lib/proj/transformation.rb +101 -60
  53. data/lib/proj/unit.rb +108 -53
  54. data/lib/proj.rb +110 -9
  55. data/proj4rb.gemspec +5 -5
  56. data/test/abstract_test.rb +23 -1
  57. data/test/context_test.rb +172 -82
  58. data/test/conversion_test.rb +368 -0
  59. data/test/coordinate_system_test.rb +144 -0
  60. data/test/crs_test.rb +770 -71
  61. data/test/database_test.rb +360 -0
  62. data/test/datum_ensemble_test.rb +65 -0
  63. data/test/datum_test.rb +55 -0
  64. data/test/ellipsoid_test.rb +64 -18
  65. data/test/file_api_test.rb +66 -0
  66. data/test/grid_cache_test.rb +72 -0
  67. data/test/grid_test.rb +141 -0
  68. data/test/network_api_test.rb +45 -0
  69. data/test/operation_factory_context_test.rb +201 -0
  70. data/test/parameters_test.rb +40 -0
  71. data/test/pj_object_test.rb +179 -0
  72. data/test/prime_meridian_test.rb +76 -0
  73. data/test/proj_test.rb +46 -4
  74. data/test/projection_test.rb +646 -222
  75. data/test/session_test.rb +78 -0
  76. data/test/transformation_test.rb +149 -7
  77. data/test/unit_test.rb +57 -28
  78. metadata +51 -13
  79. data/lib/api/api_4_9.rb +0 -31
  80. data/lib/proj/config.rb +0 -70
  81. data/lib/proj/point.rb +0 -72
  82. data/test/prime_meridians_test.rb +0 -33
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative './abstract_test'
4
+
5
+ class PrimeMeridianTest < AbstractTest
6
+ def parameter_crs
7
+ wkt = <<~EOS
8
+ PROJCS["WGS 84 / UTM zone 31N",
9
+ GEOGCS["WGS 84",
10
+ DATUM["WGS_1984",
11
+ SPHEROID["WGS 84",6378137,298.257223563,
12
+ AUTHORITY["EPSG","7030"]],
13
+ AUTHORITY["EPSG","6326"]],
14
+ PRIMEM["Greenwich",0,
15
+ AUTHORITY["EPSG","8901"]],
16
+ UNIT["degree",0.0174532925199433,
17
+ AUTHORITY["EPSG","9122"]],
18
+ AUTHORITY["EPSG","4326"]],
19
+ PROJECTION["Transverse_Mercator"],
20
+ PARAMETER["latitude_of_origin",0],
21
+ PARAMETER["central_meridian",3],
22
+ PARAMETER["scale_factor",0.9996],
23
+ PARAMETER["false_easting",500000],
24
+ PARAMETER["false_northing",0],
25
+ UNIT["metre",1,
26
+ AUTHORITY["EPSG","9001"]],
27
+ AXIS["Easting",EAST],
28
+ AXIS["Northing",NORTH],
29
+ AUTHORITY["EPSG","32631"]]
30
+ EOS
31
+ Proj::Crs.new(wkt)
32
+ end
33
+
34
+ def test_built_in
35
+ prime_meridians = Proj::PrimeMeridian.built_in.map {|prime_merdian| prime_merdian[:id] }
36
+ assert(prime_meridians.include?('greenwich'))
37
+ assert(prime_meridians.include?('athens'))
38
+ assert(prime_meridians.include?('lisbon'))
39
+ assert(prime_meridians.include?('rome'))
40
+ end
41
+
42
+ def test_from_database
43
+ meridian = Proj::PrimeMeridian.create_from_database("EPSG", "8903", :PJ_CATEGORY_PRIME_MERIDIAN)
44
+ assert_instance_of(Proj::PrimeMeridian, meridian)
45
+ assert_equal(:PJ_TYPE_PRIME_MERIDIAN, meridian.proj_type)
46
+ assert_equal("EPSG", meridian.auth_name)
47
+ assert_equal("Paris", meridian.name)
48
+ assert_equal("8903", meridian.id_code)
49
+ end
50
+
51
+ def test_parameters
52
+ meridian = parameter_crs.prime_meridian
53
+ params = meridian.parameters
54
+
55
+ expected = {longitude: 0.0,
56
+ unit_conv_factor: 0.017453292519943295,
57
+ unit_name: "degree"}
58
+
59
+ assert_equal(expected, params)
60
+ end
61
+
62
+ def test_longitude
63
+ meridian = parameter_crs.prime_meridian
64
+ assert_equal(0.0, meridian.longitude)
65
+ end
66
+
67
+ def test_unit_conv_factor
68
+ meridian = parameter_crs.prime_meridian
69
+ assert_equal(0.017453292519943295, meridian.unit_conv_factor)
70
+ end
71
+
72
+ def test_unit_name
73
+ meridian = parameter_crs.prime_meridian
74
+ assert_equal("degree", meridian.unit_name)
75
+ end
76
+ end
data/test/proj_test.rb CHANGED
@@ -5,13 +5,55 @@ require_relative './abstract_test'
5
5
  class ProjTest < AbstractTest
6
6
  def test_info
7
7
  info = Proj.info
8
- assert([4,6,7,8].include?(info[:major]))
8
+ assert([4,6,7,8,9].include?(info[:major]))
9
9
  assert([0,1,2,3].include?(info[:minor]))
10
10
  assert([0,1,2,3].include?(info[:patch]))
11
11
  refute_nil(info[:release])
12
- assert_match(/\d\.\d\.\d/, info[:version])
13
12
  refute_nil(info[:searchpath])
14
- refute(info[:paths].null?)
15
- assert_equal(1, info[:path_count])
13
+ assert(info[:paths].null?)
14
+ assert(0, info[:path_count])
15
+ end
16
+
17
+ def test_search_paths
18
+ search_paths = Proj.search_paths
19
+ assert_instance_of(Array, search_paths)
20
+ refute(search_paths.empty?)
21
+ end
22
+
23
+ def test_init_file_info
24
+ info = Proj.init_file_info("EPSG")
25
+ assert_equal("EPSG", info[:name].to_ptr.read_string)
26
+ assert(info[:filename].to_ptr.read_string.empty?)
27
+ # Info returns gibberish hex values, need to look at Proj source code
28
+ # and see what is going on
29
+ #assert_equal("epsg", info[:version].to_ptr.read_string)
30
+ #assert_equal("", info[:origin].to_ptr.read_string)
31
+ #assert_equal("", info[:lastupdate].to_ptr.read_string)
32
+ end
33
+
34
+ def test_version
35
+ assert_instance_of(Gem::Version, Proj::Api::PROJ_VERSION)
36
+ assert(Proj::Api::PROJ_VERSION.canonical_segments.first >= 5)
37
+ end
38
+
39
+ def test_degrees_to_radians
40
+ radians = Proj.degrees_to_radians(180)
41
+ assert_equal(Math::PI, radians)
42
+ end
43
+
44
+ def test_radians_to_degrees
45
+ degrees = Proj.radians_to_degrees(-Math::PI)
46
+ assert_equal(-180, degrees)
47
+ end
48
+
49
+ def test_degrees_minutes_seconds_to_radians
50
+ value = "19°46'27\"E"
51
+ radians = Proj.degrees_minutes_seconds_to_radians(value)
52
+ assert_in_delta(0.34512432, radians, 1e-7)
53
+ end
54
+
55
+ def test_radians_to_degrees_minutes_seconds
56
+ result = Proj.radians_to_degrees_minutes_seconds(Math::PI)
57
+ assert_equal("180dN", result)
16
58
  end
17
59
  end