proj4rb 4.1.0 → 5.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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -0
  3. data/Gemfile +4 -4
  4. data/README.md +53 -0
  5. data/lib/api/proj.rb +750 -0
  6. data/lib/api/proj_experimental.rb +7 -0
  7. data/lib/api/proj_ffi.rb +47 -0
  8. data/lib/api/proj_version.rb +26 -0
  9. data/lib/examples/axis_order_normalization.rb +13 -0
  10. data/lib/examples/batch_transformation.rb +25 -0
  11. data/lib/examples/context_logging.rb +26 -0
  12. data/lib/examples/crs_identification.rb +18 -0
  13. data/lib/examples/database_query.rb +27 -0
  14. data/lib/examples/geodetic_distance.rb +38 -0
  15. data/lib/examples/geodetic_to_projected.rb +18 -0
  16. data/lib/examples/operation_factory_context.rb +19 -0
  17. data/lib/examples/pipeline_operator.rb +21 -0
  18. data/lib/examples/promote_demote_3d.rb +23 -0
  19. data/lib/examples/serialization_formats.rb +17 -0
  20. data/lib/examples/transform_bounds.rb +18 -0
  21. data/lib/examples/transformation_with_area.rb +18 -0
  22. data/lib/proj/area.rb +74 -74
  23. data/lib/proj/axis_info.rb +44 -44
  24. data/lib/proj/bounds.rb +22 -0
  25. data/lib/proj/bounds3d.rb +45 -0
  26. data/lib/proj/context.rb +57 -23
  27. data/lib/proj/conversion.rb +94 -91
  28. data/lib/proj/coordinate.rb +304 -281
  29. data/lib/proj/coordinate_metadata.rb +38 -0
  30. data/lib/proj/coordinate_operation_mixin.rb +464 -381
  31. data/lib/proj/coordinate_system.rb +143 -137
  32. data/lib/proj/crs.rb +688 -672
  33. data/lib/proj/crs_info.rb +47 -47
  34. data/lib/proj/database.rb +310 -305
  35. data/lib/proj/datum.rb +32 -32
  36. data/lib/proj/datum_ensemble.rb +34 -34
  37. data/lib/proj/domain.rb +82 -0
  38. data/lib/proj/ellipsoid.rb +77 -77
  39. data/lib/proj/error.rb +7 -8
  40. data/lib/proj/file_api_callbacks.rb +165 -0
  41. data/lib/proj/grid.rb +121 -121
  42. data/lib/proj/grid_cache.rb +65 -64
  43. data/lib/proj/grid_info.rb +19 -19
  44. data/lib/proj/life_span.rb +21 -0
  45. data/lib/proj/network_api_callbacks.rb +86 -0
  46. data/lib/proj/operation.rb +66 -42
  47. data/lib/proj/operation_factory_context.rb +4 -2
  48. data/lib/proj/options.rb +41 -0
  49. data/lib/proj/parameter.rb +37 -37
  50. data/lib/proj/parameters.rb +106 -107
  51. data/lib/proj/pj_axis_description.rb +26 -0
  52. data/lib/proj/pj_object.rb +602 -670
  53. data/lib/proj/pj_objects.rb +45 -45
  54. data/lib/proj/pj_param_description.rb +28 -0
  55. data/lib/proj/prime_meridian.rb +65 -65
  56. data/lib/proj/projection.rb +1771 -698
  57. data/lib/proj/session.rb +2 -0
  58. data/lib/proj/transformation.rb +102 -102
  59. data/lib/proj/unit.rb +81 -108
  60. data/lib/proj.rb +10 -3
  61. data/lib/proj4.rb +5 -5
  62. data/proj4rb.gemspec +10 -5
  63. data/test/abstract_test.rb +7 -28
  64. data/test/context_test.rb +210 -172
  65. data/test/context_validation_test.rb +11 -0
  66. data/test/conversion_test.rb +376 -368
  67. data/test/coordinate_metadata_test.rb +34 -0
  68. data/test/coordinate_system_test.rb +162 -144
  69. data/test/coordinate_test.rb +289 -34
  70. data/test/crs_test.rb +1112 -1072
  71. data/test/database_test.rb +407 -359
  72. data/test/datum_ensemble_test.rb +64 -64
  73. data/test/datum_test.rb +61 -54
  74. data/test/domain_test.rb +72 -0
  75. data/test/ellipsoid_test.rb +80 -80
  76. data/test/examples_test.rb +149 -0
  77. data/test/file_api_example.rb +58 -0
  78. data/test/file_api_test.rb +74 -66
  79. data/test/grid_cache_test.rb +72 -72
  80. data/test/grid_test.rb +126 -141
  81. data/test/network_api_example.rb +48 -0
  82. data/test/network_api_test.rb +33 -45
  83. data/test/operation_factory_context_test.rb +225 -201
  84. data/test/operation_test.rb +40 -29
  85. data/test/options_test.rb +17 -0
  86. data/test/parameters_test.rb +86 -40
  87. data/test/pj_object_test.rb +221 -179
  88. data/test/prime_meridian_test.rb +75 -75
  89. data/test/proj_test.rb +58 -58
  90. data/test/projection_test.rb +680 -650
  91. data/test/session_test.rb +78 -77
  92. data/test/transformation_test.rb +238 -210
  93. data/test/unit_test.rb +114 -76
  94. metadata +45 -31
  95. data/ChangeLog +0 -89
  96. data/README.rdoc +0 -207
  97. data/lib/api/api.rb +0 -117
  98. data/lib/api/api_5_0.rb +0 -338
  99. data/lib/api/api_5_1.rb +0 -7
  100. data/lib/api/api_5_2.rb +0 -5
  101. data/lib/api/api_6_0.rb +0 -146
  102. data/lib/api/api_6_1.rb +0 -5
  103. data/lib/api/api_6_2.rb +0 -10
  104. data/lib/api/api_6_3.rb +0 -6
  105. data/lib/api/api_7_0.rb +0 -69
  106. data/lib/api/api_7_1.rb +0 -73
  107. data/lib/api/api_7_2.rb +0 -14
  108. data/lib/api/api_8_0.rb +0 -6
  109. data/lib/api/api_8_1.rb +0 -24
  110. data/lib/api/api_8_2.rb +0 -6
  111. data/lib/api/api_9_1.rb +0 -7
  112. data/lib/api/api_9_2.rb +0 -9
  113. data/lib/api/api_experimental.rb +0 -201
  114. data/lib/proj/file_api.rb +0 -166
  115. data/lib/proj/network_api.rb +0 -92
data/lib/proj/session.rb CHANGED
@@ -4,7 +4,9 @@ module Proj
4
4
 
5
5
  # @!visibility private
6
6
  def self.finalize(context, pointer)
7
+ life_span = context.life_span
7
8
  proc do
9
+ next unless life_span.alive?
8
10
  Api.proj_insert_object_session_destroy(context, pointer)
9
11
  end
10
12
  end
@@ -1,102 +1,102 @@
1
- module Proj
2
- # Transformations are {CoordinateOperationMixin coordinate operations} that
3
- # convert {Coordinate coordinates} from one {Crs} to another.
4
- # In Proj they are defined as operations that exert a change in reference frame
5
- # while {Conversion conversions } do not.
6
- class Transformation < PjObject
7
- include CoordinateOperationMixin
8
-
9
- # Create a Transformation
10
- #
11
- # @param context [Context] Context
12
- # @param name [String] Name of the transformation. Default is nil.
13
- # @param auth_name [String] Transformation authority name. Default is nil.
14
- # @param code [String] Transformation code. Default is nil.
15
- # @param source_crs [CoordinateSystem] Source CRS
16
- # @param target_crs [CoordinateSystem] Target CRS
17
- # @param interpolation_crs [CoordinateSystem] Interpolation. Default is nil
18
- # @param method_name [String] Method name. Default is nil.
19
- # @param method_auth_name [String] Method authority name. Default is nil.
20
- # @param method_code [String] Method code. Default is nil.
21
- # @param params [Array<Parameter>] Parameter descriptions
22
- # @param accuracy [Float] Accuracy of the transformation in meters. A negative value means unknown.
23
- #
24
- # @return [Transformation]
25
- def self.create(context, name: nil, auth_name: nil, code: nil,
26
- source_crs:, target_crs:, interpolation_crs: nil,
27
- method_name: nil, method_auth_name: nil, method_code: nil,
28
- params:, accuracy:)
29
-
30
- params_ptr = FFI::MemoryPointer.new(Api::PJ_PARAM_DESCRIPTION, params.size)
31
- params.each_with_index do |param, i|
32
- param_description_target = Api::PJ_PARAM_DESCRIPTION.new(params_ptr[i])
33
- param_description_source = param.to_description
34
- param_description_target.to_ptr.__copy_from__(param_description_source.to_ptr, Api::PJ_PARAM_DESCRIPTION.size)
35
- end
36
-
37
- ptr = Api.proj_create_transformation(context, name, auth_name, code,
38
- source_crs, target_crs, interpolation_crs,
39
- method_name, method_auth_name, method_code,
40
- params.count, params_ptr, accuracy)
41
- self.create_object(ptr, context)
42
- end
43
-
44
- # Transforms a {Coordinate} from the source {Crs} to the target {Crs}. Coordinates should be expressed in
45
- # the units and axis order of the definition of the source CRS. The returned transformed coordinate will
46
- # be in the units and axis order of the definition of the target CRS.
47
- #
48
- # For most geographic Crses, the units will be in degrees. For geographic CRS defined by the EPSG authority,
49
- # the order of coordinates is latitude first, longitude second. When using a PROJ initialization string,
50
- # on contrary, the order will be longitude first, latitude second.
51
- #
52
- # For projected CRS, the units may vary (metre, us-foot, etc..).
53
- #
54
- # For projected CRS defined by the EPSG authority, and with EAST / NORTH directions, the axis order might be
55
- # easting first, northing second, or the reverse. When using a PROJ string, the order will be
56
- # easting first, northing second, except if the +axis parameter modifies it.
57
- #
58
- # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs_from_pj
59
- # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs proj_create_crs_to_crs
60
- #
61
- # @param source [Crs, String] The source Crs. See the Crs documentation for the string format
62
- # @param target [Crs, String] The target Crs. See the Crs documentation for the string format
63
- # @param area [Area] If an area is specified a more accurate transformation between two given systems can be chosen
64
- # @param context [Context]
65
- # @param authority [String] Restricts the authority of coordinate operations looked up in the database
66
- # @param accuracy [Float] Sets the minimum desired accuracy (in metres) of the candidate coordinate operations
67
- # @param allow_ballpark [Boolean] Set to false to disallow the use of Ballpark transformation in the candidate coordinate operations.
68
- # @param only_best [Boolean] Set to true to cause PROJ to error out if the best transformation cannot be used. Requires Proj 9.2 and higher
69
- #
70
- # @return [Transformation] A new transformation
71
- def initialize(source, target, context=nil,
72
- area: nil, authority: nil, accuracy: nil, allow_ballpark: nil, only_best: nil, force_over: nil)
73
-
74
- context ||= Context.current
75
-
76
- options = {"AUTHORITY": authority,
77
- "ACCURACY": accuracy.nil? ? nil : accuracy.to_s,
78
- "ALLOW_BALLPARK": allow_ballpark.nil? ? nil : (allow_ballpark ? "YES" : "NO"),
79
- "ONLY_BEST": only_best.nil? ? nil : (only_best ? "YES" : "NO"),
80
- "FORCE_OVER": force_over.nil? ? nil : (force_over ? "YES" : "NO")}
81
- options_ptr = create_options_pointer(options)
82
-
83
- ptr = if source.is_a?(Crs) && target.is_a?(Crs)
84
- if Api.method_defined?(:proj_create_crs_to_crs_from_pj)
85
- Api.proj_create_crs_to_crs_from_pj(context, source, target, area, options_ptr)
86
- else
87
- Api.proj_create_crs_to_crs(context, source.definition, target.definition, area)
88
- end
89
- else
90
- Api.proj_create_crs_to_crs(context, source, target, nil)
91
- end
92
-
93
- if ptr.null?
94
- Error.check_context(context)
95
- # If that does not raise an error then no operation was found
96
- raise(Error, "No operation found matching criteria")
97
- end
98
-
99
- super(ptr, context)
100
- end
101
- end
102
- end
1
+ module Proj
2
+ # Transformations are {CoordinateOperationMixin coordinate operations} that
3
+ # convert {Coordinate coordinates} from one {Crs} to another.
4
+ # In Proj they are defined as operations that exert a change in reference frame
5
+ # while {Conversion conversions } do not.
6
+ class Transformation < PjObject
7
+ include CoordinateOperationMixin
8
+
9
+ # Create a Transformation
10
+ #
11
+ # @param context [Context] Context
12
+ # @param name [String] Name of the transformation. Default is nil.
13
+ # @param auth_name [String] Transformation authority name. Default is nil.
14
+ # @param code [String] Transformation code. Default is nil.
15
+ # @param source_crs [CoordinateSystem] Source CRS
16
+ # @param target_crs [CoordinateSystem] Target CRS
17
+ # @param interpolation_crs [CoordinateSystem] Interpolation. Default is nil
18
+ # @param method_name [String] Method name. Default is nil.
19
+ # @param method_auth_name [String] Method authority name. Default is nil.
20
+ # @param method_code [String] Method code. Default is nil.
21
+ # @param params [Array<Parameter>] Parameter descriptions
22
+ # @param accuracy [Float] Accuracy of the transformation in meters. A negative value means unknown.
23
+ #
24
+ # @return [Transformation]
25
+ def self.create(context, name: nil, auth_name: nil, code: nil,
26
+ source_crs:, target_crs:, interpolation_crs: nil,
27
+ method_name: nil, method_auth_name: nil, method_code: nil,
28
+ params:, accuracy:)
29
+ Error.validate_context!(context)
30
+
31
+ params_ptr = FFI::MemoryPointer.new(Api::PjParamDescription, params.size)
32
+ params.each_with_index do |param, i|
33
+ param_description_target = Api::PjParamDescription.new(params_ptr[i])
34
+ param_description_source = param.to_description
35
+ param_description_target.to_ptr.__copy_from__(param_description_source.to_ptr, Api::PjParamDescription.size)
36
+ end
37
+
38
+ ptr = Api.proj_create_transformation(context, name, auth_name, code,
39
+ source_crs, target_crs, interpolation_crs,
40
+ method_name, method_auth_name, method_code,
41
+ params.count, params_ptr, accuracy)
42
+ self.create_object(ptr, context)
43
+ end
44
+
45
+ # Transforms a {Coordinate} from the source {Crs} to the target {Crs}. Coordinates should be expressed in
46
+ # the units and axis order of the definition of the source CRS. The returned transformed coordinate will
47
+ # be in the units and axis order of the definition of the target CRS.
48
+ #
49
+ # For most geographic Crses, the units will be in degrees. For geographic CRS defined by the EPSG authority,
50
+ # the order of coordinates is latitude first, longitude second. When using a PROJ initialization string,
51
+ # on contrary, the order will be longitude first, latitude second.
52
+ #
53
+ # For projected CRS, the units may vary (metre, us-foot, etc..).
54
+ #
55
+ # For projected CRS defined by the EPSG authority, and with EAST / NORTH directions, the axis order might be
56
+ # easting first, northing second, or the reverse. When using a PROJ string, the order will be
57
+ # easting first, northing second, except if the +axis parameter modifies it.
58
+ #
59
+ # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs_from_pj
60
+ # @see https://proj.org/development/reference/functions.html#c.proj_create_crs_to_crs proj_create_crs_to_crs
61
+ #
62
+ # @param source [Crs, String] The source Crs. See the Crs documentation for the string format
63
+ # @param target [Crs, String] The target Crs. See the Crs documentation for the string format
64
+ # @param area [Area] If an area is specified a more accurate transformation between two given systems can be chosen
65
+ # @param context [Context]
66
+ # @param authority [String] Restricts the authority of coordinate operations looked up in the database
67
+ # @param accuracy [Float] Sets the minimum desired accuracy (in metres) of the candidate coordinate operations
68
+ # @param allow_ballpark [Boolean] Set to false to disallow the use of Ballpark transformation in the candidate coordinate operations.
69
+ # @param only_best [Boolean] Set to true to cause PROJ to error out if the best transformation cannot be used. Requires Proj 9.2 and higher
70
+ #
71
+ # @return [Transformation] A new transformation
72
+ def initialize(source, target, context=nil,
73
+ area: nil, authority: nil, accuracy: nil, allow_ballpark: nil, only_best: nil, force_over: nil)
74
+
75
+ context ||= Context.current
76
+
77
+ options = Options.new("AUTHORITY": authority,
78
+ "ACCURACY": accuracy.nil? ? nil : accuracy.to_s,
79
+ "ALLOW_BALLPARK": allow_ballpark.nil? ? nil : (allow_ballpark ? "YES" : "NO"),
80
+ "ONLY_BEST": only_best.nil? ? nil : (only_best ? "YES" : "NO"),
81
+ "FORCE_OVER": force_over.nil? ? nil : (force_over ? "YES" : "NO"))
82
+
83
+ ptr = if source.is_a?(Crs) && target.is_a?(Crs)
84
+ if Api.method_defined?(:proj_create_crs_to_crs_from_pj)
85
+ Api.proj_create_crs_to_crs_from_pj(context, source, target, area, options)
86
+ else
87
+ Api.proj_create_crs_to_crs(context, source.definition, target.definition, area)
88
+ end
89
+ else
90
+ Api.proj_create_crs_to_crs(context, source, target, nil)
91
+ end
92
+
93
+ if ptr.null?
94
+ Error.check_context(context)
95
+ # If that does not raise an error then no operation was found
96
+ raise(Error, "No operation found matching criteria")
97
+ end
98
+
99
+ super(ptr, context)
100
+ end
101
+ end
102
+ end
data/lib/proj/unit.rb CHANGED
@@ -1,109 +1,82 @@
1
- module Proj
2
- class Unit
3
- # @!attribute [r] auth_name
4
- # @return [String] Authority name
5
- # @!attribute [r] code
6
- # @return [String] Object code
7
- # @!attribute [r] name
8
- # @return [String] Object name. For example "metre", "US survey foot", etc
9
- # @!attribute [r] category
10
- # @return [String] Category of the unit: one of "linear", "linear_per_time", "angular", "angular_per_time", "scale", "scale_per_time" or "time"
11
- # @!attribute [r] conv_factor
12
- # @return [String] Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for "linear", radian for "angular", etc.). It might be 0 in some cases to indicate no known conversion factor
13
- # @!attribute [r] proj_short_name
14
- # @return [String] PROJ short name, like "m", "ft", "us-ft", etc... Might be nil
15
- # @!attribute [r] deprecated
16
- # @return [Boolean] Whether the object is deprecated
17
- attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated
18
-
19
- # Returns a list of built in Units. This is deprecated. Use Database#units instead
20
- def self.built_in(auth_name: nil, category: nil, allow_deprecated: false)
21
- # First get linear units
22
- pointer_to_array = FFI::Pointer.new(Api::PJ_UNITS, Api.proj_list_units)
23
- result = Array.new
24
- 0.step do |i|
25
- unit_info = Api::PJ_UNITS.new(pointer_to_array[i])
26
- break if unit_info[:id].nil?
27
- result << self.new('PROJ', unit_info[:id], unit_info[:name],
28
- 'length', unit_info[:factor], unit_info[:id], false)
29
- end
30
-
31
- # Now get angular linear units
32
- if Api.method_defined?(:proj_list_angular_units)
33
- pointer_to_array = FFI::Pointer.new(Api::PJ_UNITS, Api.proj_list_angular_units)
34
- 0.step do |i|
35
- unit_info = Api::PJ_UNITS.new(pointer_to_array[i])
36
- break result if unit_info[:id].nil?
37
- result << self.new('PROJ', unit_info[:id], unit_info[:name],
38
- 'angular', unit_info[:factor], unit_info[:id], false)
39
- end
40
- end
41
-
42
- if auth_name
43
- result = result.find_all {|unit_info| unit_info.auth_name == auth_name}
44
- end
45
-
46
- if category
47
- result = result.find_all {|unit_info| unit_info.category == category}
48
- end
49
- result
50
- end
51
-
52
- # Create a new Unit
53
- #
54
- # @param auth_name [String] Authority name
55
- # @param code [String] Object code
56
- # @param name [String] Object name. For example "metre", "US survey foot", etc
57
- # @param category [String] Category of the unit: one of "linear", "linear_per_time", "angular", "angular_per_time", "scale", "scale_per_time" or "time"
58
- # @param conv_factor [String] Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for "linear", radian for "angular", etc.). It might be 0 in some cases to indicate no known conversion factor
59
- # @param proj_short_name [String] PROJ short name, like "m", "ft", "us-ft", etc... Might be nil
60
- # @param deprecated [Boolean] Whether the object is deprecated
61
- #
62
- # @return [Unit]
63
- def initialize(auth_name, code, name, category, conv_factor, proj_short_name, deprecated)
64
- @auth_name = auth_name
65
- @code = code
66
- @name = name
67
- @category = category
68
- @conv_factor = conv_factor
69
- @proj_short_name = proj_short_name
70
- @deprecated = deprecated
71
- end
72
-
73
- def <=>(other)
74
- self.name <=> other.name
75
- end
76
-
77
- def ==(other)
78
- self.auth_name == other.auth_name &&
79
- self.code == other.code
80
- end
81
-
82
- def unit_type
83
- case self.category
84
- when "linear"
85
- :PJ_UT_LINEAR
86
- when "linear_per_time"
87
- :PJ_UT_LINEAR
88
- when "angular"
89
- :PJ_UT_ANGULAR
90
- when "angular_per_time"
91
- :PJ_UT_ANGULAR
92
- when "scale"
93
- :PJ_UT_SCALE
94
- when "scale_per_time"
95
- :PJ_UT_SCALE
96
- when "time"
97
- :PJ_UT_TIME
98
- end
99
- end
100
-
101
- def to_s
102
- self.name
103
- end
104
-
105
- def inspect
106
- "#<#{self.class} authority=\"#{auth_name}\", code=\"#{code}\", name=\"#{name}\">"
107
- end
108
- end
1
+ module Proj
2
+ class Unit
3
+ # @!attribute [r] auth_name
4
+ # @return [String] Authority name
5
+ # @!attribute [r] code
6
+ # @return [String] Object code
7
+ # @!attribute [r] name
8
+ # @return [String] Object name. For example "metre", "US survey foot", etc
9
+ # @!attribute [r] category
10
+ # @return [String] Category of the unit: one of "linear", "linear_per_time", "angular", "angular_per_time", "scale", "scale_per_time" or "time"
11
+ # @!attribute [r] conv_factor
12
+ # @return [String] Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for "linear", radian for "angular", etc.). It might be 0 in some cases to indicate no known conversion factor
13
+ # @!attribute [r] proj_short_name
14
+ # @return [String] PROJ short name, like "m", "ft", "us-ft", etc... Might be nil
15
+ # @!attribute [r] deprecated
16
+ # @return [Boolean] Whether the object is deprecated
17
+ attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated
18
+
19
+ # Returns a list of built in Units.
20
+ def self.built_in(auth_name: nil, category: nil, allow_deprecated: false)
21
+ database = Database.new(Context.current)
22
+ database.units(auth_name: auth_name, category: category, allow_deprecated: allow_deprecated)
23
+ end
24
+
25
+ # Create a new Unit
26
+ #
27
+ # @param auth_name [String] Authority name
28
+ # @param code [String] Object code
29
+ # @param name [String] Object name. For example "metre", "US survey foot", etc
30
+ # @param category [String] Category of the unit: one of "linear", "linear_per_time", "angular", "angular_per_time", "scale", "scale_per_time" or "time"
31
+ # @param conv_factor [String] Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for "linear", radian for "angular", etc.). It might be 0 in some cases to indicate no known conversion factor
32
+ # @param proj_short_name [String] PROJ short name, like "m", "ft", "us-ft", etc... Might be nil
33
+ # @param deprecated [Boolean] Whether the object is deprecated
34
+ #
35
+ # @return [Unit]
36
+ def initialize(auth_name, code, name, category, conv_factor, proj_short_name, deprecated)
37
+ @auth_name = auth_name
38
+ @code = code
39
+ @name = name
40
+ @category = category
41
+ @conv_factor = conv_factor
42
+ @proj_short_name = proj_short_name
43
+ @deprecated = deprecated
44
+ end
45
+
46
+ def <=>(other)
47
+ self.name <=> other.name
48
+ end
49
+
50
+ def ==(other)
51
+ self.auth_name == other.auth_name &&
52
+ self.code == other.code
53
+ end
54
+
55
+ def unit_type
56
+ case self.category
57
+ when "linear"
58
+ :PJ_UT_LINEAR
59
+ when "linear_per_time"
60
+ :PJ_UT_LINEAR
61
+ when "angular"
62
+ :PJ_UT_ANGULAR
63
+ when "angular_per_time"
64
+ :PJ_UT_ANGULAR
65
+ when "scale"
66
+ :PJ_UT_SCALE
67
+ when "scale_per_time"
68
+ :PJ_UT_SCALE
69
+ when "time"
70
+ :PJ_UT_TIME
71
+ end
72
+ end
73
+
74
+ def to_s
75
+ self.name
76
+ end
77
+
78
+ def inspect
79
+ "#<#{self.class} authority=\"#{auth_name}\", code=\"#{code}\", name=\"#{name}\">"
80
+ end
81
+ end
109
82
  end
data/lib/proj.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require_relative 'api/api'
3
+ require_relative 'api/proj_ffi'
4
4
 
5
+ require_relative 'proj/pj_axis_description'
6
+ require_relative 'proj/pj_param_description'
7
+ require_relative 'proj/options'
5
8
  require_relative 'proj/pj_object'
6
9
  require_relative 'proj/pj_objects'
7
10
  require_relative 'proj/coordinate_operation_mixin'
@@ -13,20 +16,24 @@ require_relative 'proj/transformation'
13
16
  require_relative 'proj/area'
14
17
  require_relative 'proj/axis_info'
15
18
  require_relative 'proj/bounds'
19
+ require_relative 'proj/bounds3d'
20
+ require_relative 'proj/coordinate_metadata'
16
21
  require_relative 'proj/coordinate_system'
17
22
  require_relative 'proj/crs_info'
23
+ require_relative 'proj/life_span'
18
24
  require_relative 'proj/context'
19
25
  require_relative 'proj/coordinate'
20
26
  require_relative 'proj/database'
21
27
  require_relative 'proj/datum'
28
+ require_relative 'proj/domain'
22
29
  require_relative 'proj/datum_ensemble'
23
30
  require_relative 'proj/ellipsoid'
24
31
  require_relative 'proj/error'
25
- require_relative 'proj/file_api'
32
+ require_relative 'proj/file_api_callbacks'
26
33
  require_relative 'proj/grid'
27
34
  require_relative 'proj/grid_cache'
28
35
  require_relative 'proj/grid_info'
29
- require_relative 'proj/network_api'
36
+ require_relative 'proj/network_api_callbacks'
30
37
  require_relative 'proj/parameter'
31
38
  require_relative 'proj/operation'
32
39
  require_relative 'proj/operation_factory_context'
data/lib/proj4.rb CHANGED
@@ -1,6 +1,6 @@
1
- # encoding: UTF-8
2
-
3
- # This file is for backwards compatibility to the Proj4 namespace
4
- require_relative './proj'
5
-
1
+ # encoding: UTF-8
2
+
3
+ # This file is for backwards compatibility to the Proj4 namespace
4
+ require_relative './proj'
5
+
6
6
  Proj4 = Proj
data/proj4rb.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'proj4rb'
3
- spec.version = '4.1.0'
3
+ spec.version = '5.0.0'
4
4
  spec.summary = 'Ruby bindings for the Proj coordinate transformation library'
5
5
  spec.description = <<-EOF
6
6
  Ruby bindings for the Proj coordinate transformation library
@@ -13,18 +13,23 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.requirements << 'Proj Library'
15
15
  spec.require_path = 'lib'
16
- spec.files = Dir['ChangeLog',
16
+ spec.files = Dir['CHANGELOG.md',
17
17
  'Gemfile',
18
18
  'MIT-LICENSE',
19
19
  'proj4rb.gemspec',
20
20
  'Rakefile',
21
- 'README.rdoc',
21
+ 'README.md',
22
22
  'lib/**/*.rb',
23
23
  'test/*.rb']
24
24
 
25
- spec.test_files = Dir["test/test_*.rb"]
25
+ spec.metadata = {
26
+ 'homepage_uri' => spec.homepage,
27
+ 'source_code_uri' => 'https://github.com/cfis/proj4rb',
28
+ 'changelog_uri' => 'https://github.com/cfis/proj4rb/blob/master/CHANGELOG.md',
29
+ 'documentation_uri' => 'https://cfis.github.io/proj4rb/'
30
+ }
26
31
 
27
- spec.add_dependency "ffi"
32
+ spec.add_dependency "ffi", ">=1.17.4"
28
33
 
29
34
  spec.add_development_dependency('bundler')
30
35
  spec.add_development_dependency('rake')
@@ -1,29 +1,8 @@
1
- require 'bundler/setup'
2
- require 'minitest/autorun'
3
- require 'proj'
4
-
5
- class AbstractTest < Minitest::Test
6
- def self.proj7?
7
- Proj::Api::PROJ_VERSION >= Gem::Version.new("7.0.0")
8
- end
9
-
10
- def self.proj8?
11
- Proj::Api::PROJ_VERSION >= Gem::Version.new("8.0.0")
12
- end
13
-
14
- def self.proj9?
15
- Proj::Api::PROJ_VERSION >= Gem::Version.new("9.0.0")
16
- end
17
-
18
- def proj7?
19
- self.class.proj7?
20
- end
21
-
22
- def proj8?
23
- self.class.proj8?
24
- end
25
-
26
- def proj9?
27
- self.class.proj9?
28
- end
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'proj'
4
+
5
+ Minitest.load_plugins
6
+
7
+ class AbstractTest < Minitest::Test
29
8
  end