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/api/api_7_0.rb DELETED
@@ -1,69 +0,0 @@
1
- module Proj
2
- module Api
3
- # ---- File API ----------
4
- typedef :pointer, :PROJ_FILE_HANDLE
5
- typedef :pointer, :USER_DATA
6
-
7
- # @return [Symbol]
8
- PROJ_OPEN_ACCESS = enum(:PROJ_OPEN_ACCESS_READ_ONLY, # Read-only access. Equivalent to "rb"
9
- :PROJ_OPEN_ACCESS_READ_UPDATE, # Read-update access. File should be created if not existing. Equivalent to "r+b
10
- :PROJ_OPEN_ACCESS_CREATE) # Create access. File should be truncated to 0-byte if already existing. Equivalent to "w+b"
11
-
12
- # File API callbacks
13
- callback :open_file_cbk, [:PJ_CONTEXT, :string, PROJ_OPEN_ACCESS, :USER_DATA], :PROJ_FILE_HANDLE
14
- callback :read_file_cbk, [:PJ_CONTEXT, :PROJ_FILE_HANDLE, :pointer, :size_t, :USER_DATA], :size_t
15
- callback :write_file_cbk, [:PJ_CONTEXT, :PROJ_FILE_HANDLE, :pointer, :size_t, :USER_DATA], :size_t
16
- callback :seek_file_cbk, [:PJ_CONTEXT, :PROJ_FILE_HANDLE, :long_long, :int, :USER_DATA], :int
17
- callback :tell_file_cbk, [:PJ_CONTEXT, :PROJ_FILE_HANDLE, :USER_DATA], :long_long
18
- callback :close_file_cbk, [:PJ_CONTEXT, :PROJ_FILE_HANDLE, :USER_DATA], :void
19
- callback :exists_file_cbk, [:PJ_CONTEXT, :string, :USER_DATA], :int
20
- callback :mkdir_file_cbk, [:PJ_CONTEXT, :string, :USER_DATA], :int
21
- callback :unlink_file_cbk, [:PJ_CONTEXT, :string, :USER_DATA], :int
22
- callback :rename_file_cbk, [:PJ_CONTEXT, :string, :string, :USER_DATA], :int
23
-
24
- # Progress callback. The passed percentage is in the range [0, 1]. The progress callback must return
25
- # TRUE if the download should be continued.
26
- callback :progress_file_cbk, [:PJ_CONTEXT, :double, :USER_DATA], :int
27
-
28
- class PROJ_FILE_API < FFI::Struct
29
- layout :version, :int, # Version of this structure. Should be set to 1 currently.
30
- :open_cbk, :open_file_cbk,
31
- :read_cbk, :read_file_cbk,
32
- :write_cbk, :write_file_cbk,
33
- :seek_cbk, :seek_file_cbk,
34
- :tell_cbk, :tell_file_cbk,
35
- :close_cbk, :close_file_cbk,
36
- :exists_cbk, :exists_file_cbk,
37
- :mkdir_cbk, :mkdir_file_cbk,
38
- :unlink_cbk, :unlink_file_cbk,
39
- :rename_cbk, :rename_file_cbk
40
- end
41
- attach_function :proj_context_set_fileapi, [:PJ_CONTEXT, PROJ_FILE_API, :USER_DATA], :int
42
- attach_function :proj_is_download_needed, [:PJ_CONTEXT, :string, :int], :int
43
- attach_function :proj_download_file, [:PJ_CONTEXT, :string, :int, :progress_file_cbk, :USER_DATA], :int
44
-
45
- # --------- Network API ------------
46
- typedef :pointer, :PROJ_NETWORK_HANDLE
47
- callback :open_network_cbk, [:PJ_CONTEXT, :string, :ulong_long, :size_t, :pointer, :pointer, :size_t, :string, :USER_DATA], :PROJ_NETWORK_HANDLE
48
- callback :close_network_cbk, [:PJ_CONTEXT, :PROJ_NETWORK_HANDLE, :USER_DATA], :void
49
- callback :header_value_cbk, [:PJ_CONTEXT, :PROJ_NETWORK_HANDLE, :pointer, :USER_DATA], :pointer
50
- callback :read_range_cbk, [:PJ_CONTEXT, :PROJ_NETWORK_HANDLE, :ulong_long, :size_t, :pointer, :size_t, :string, :USER_DATA], :size_t
51
- attach_function :proj_context_set_network_callbacks, [:PJ_CONTEXT, :open_network_cbk, :close_network_cbk, :header_value_cbk, :read_range_cbk, :pointer], :int
52
-
53
- attach_function :proj_context_is_network_enabled, [:PJ_CONTEXT], :int
54
- attach_function :proj_context_set_enable_network, [:PJ_CONTEXT, :int], :int
55
- attach_function :proj_context_set_url_endpoint, [:PJ_CONTEXT, :string], :void
56
-
57
- # --------- Cache ------------
58
- attach_function :proj_grid_cache_set_enable, [:PJ_CONTEXT, :int], :void
59
- attach_function :proj_grid_cache_set_filename, [:PJ_CONTEXT, :string], :void
60
- attach_function :proj_grid_cache_set_max_size, [:PJ_CONTEXT, :int], :void
61
- attach_function :proj_grid_cache_set_ttl, [:PJ_CONTEXT, :int], :void
62
- attach_function :proj_grid_cache_clear, [:PJ_CONTEXT], :void
63
-
64
- # -------- Other ----------
65
- attach_function :proj_assign_context, [:PJ, :PJ_CONTEXT], :void
66
- attach_function :proj_degree_input, [:PJ, PJ_DIRECTION], :int
67
- attach_function :proj_degree_output, [:PJ, PJ_DIRECTION], :int
68
- end
69
- end
data/lib/api/api_7_1.rb DELETED
@@ -1,73 +0,0 @@
1
- module Proj
2
- module Api
3
- # ----- Int List
4
- attach_function :proj_int_list_destroy, [:pointer], :void
5
-
6
- # ---- Units ------
7
- class PROJ_UNIT_INFO < FFI::Struct
8
- layout :auth_name, :string,
9
- :code, :string,
10
- :name, :string,
11
- :category, :string,
12
- :conv_factor, :double,
13
- :proj_short_name, :string,
14
- :deprecated, :int
15
- end
16
-
17
- attach_function :proj_get_units_from_database, [:PJ_CONTEXT, :string, :string, :int, :pointer], :pointer #Array of pointers to PROJ_UNIT_INFO
18
- attach_function :proj_unit_list_destroy, [:pointer], :void
19
-
20
- # ---- Operation Factories ------
21
- # Specifies how source and target CRS extent should be used to restrict candidate
22
- # operations (only taken into account if no explicit area of interest is specified.
23
- enum :PROJ_CRS_EXTENT_USE, [:PJ_CRS_EXTENT_NONE, # Ignore CRS extent
24
- :PJ_CRS_EXTENT_BOTH, # Test extent against both CRS extent.
25
- :PJ_CRS_EXTENT_INTERSECTION, # Test extent against the intersection of both CRS extents
26
- :PJ_CRS_EXTENT_SMALLEST] # Test against the smallest of both CRS extent
27
-
28
-
29
- # Spatial criterion to restrict candidate operations
30
- enum :PROJ_SPATIAL_CRITERION, [:PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT, # The area of validity of transforms should strictly contain the area of interest
31
- :PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION] # The area of validity of transforms should at least intersect the area of interest
32
-
33
- # Describe how grid availability is used
34
- enum :PROJ_GRID_AVAILABILITY_USE, [:PROJ_GRID_AVAILABILITY_USE, # Grid availability is only used for sorting results. Operations where some grids are missing will be sorted last
35
- :PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID, # Completely discard an operation if a required grid is missing
36
- :PROJ_GRID_AVAILABILITY_IGNORED, # Ignore grid availability at all. Results will be presented as if all grids were available
37
- :PROJ_GRID_AVAILABILITY_KNOWN_AVAILABLE] # Results will be presented as if grids known to PROJ (that is registered in the grid_alternatives table of its database) were available. Used typically when networking is enabled.
38
-
39
- # Describe if and how intermediate CRS should be used
40
- enum :PROJ_INTERMEDIATE_CRS_USE, [:PROJ_INTERMEDIATE_CRS_USE_ALWAYS, # Always search for intermediate CRS
41
- :PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION, # Only attempt looking for intermediate CRS if there is no direct transformation available
42
- :PROJ_INTERMEDIATE_CRS_USE_NEVER] # Do not attempt looking for intermediate CRS
43
-
44
- attach_function :proj_create_operation_factory_context, [:PJ_CONTEXT, :string], :PJ_OBJ_LIST
45
- attach_function :proj_operation_factory_context_destroy, [:pointer], :void
46
- attach_function :proj_create_operations, [:PJ_CONTEXT, :PJ, :PJ, :pointer], :pointer
47
- attach_function :proj_operation_factory_context_set_allow_ballpark_transformations, [:PJ_CONTEXT, :pointer, :int], :void
48
- attach_function :proj_operation_factory_context_set_desired_accuracy, [:PJ_CONTEXT, :pointer, :double], :void
49
- attach_function :proj_operation_factory_context_set_area_of_interest, [:PJ_CONTEXT, :pointer, :double, :double, :double, :double], :void
50
- attach_function :proj_operation_factory_context_set_crs_extent_use, [:PJ_CONTEXT, :pointer, :PROJ_CRS_EXTENT_USE], :void
51
- attach_function :proj_operation_factory_context_set_spatial_criterion, [:PJ_CONTEXT, :pointer, :PROJ_SPATIAL_CRITERION], :void
52
- attach_function :proj_operation_factory_context_set_grid_availability_use, [:PJ_CONTEXT, :pointer, :PROJ_GRID_AVAILABILITY_USE], :void
53
- attach_function :proj_operation_factory_context_set_use_proj_alternative_grid_names, [:PJ_CONTEXT, :pointer, :int], :void
54
- attach_function :proj_operation_factory_context_set_allow_use_intermediate_crs, [:PJ_CONTEXT, :pointer, :PROJ_INTERMEDIATE_CRS_USE], :void
55
- attach_function :proj_operation_factory_context_set_allowed_intermediate_crs, [:PJ_CONTEXT, :pointer, :pointer], :void
56
-
57
- # Operations
58
- attach_function :proj_coordoperation_has_ballpark_transformation, [:PJ_CONTEXT, :PJ], :int
59
- attach_function :proj_get_suggested_operation, [:PJ_CONTEXT, :PJ_OBJ_LIST, PJ_DIRECTION, PJ_COORD], :int
60
- attach_function :proj_coordoperation_get_param_count, [:PJ_CONTEXT, :PJ], :int
61
- attach_function :proj_coordoperation_get_param_index, [:PJ_CONTEXT, :PJ, :string], :int
62
- attach_function :proj_coordoperation_get_param, [:PJ_CONTEXT, :PJ, :int, :pointer, :pointer, :pointer,
63
- :pointer, :pointer, :pointer, :pointer,:pointer, :pointer, :pointer], :int
64
- attach_function :proj_coordoperation_is_instantiable, [:PJ_CONTEXT, :PJ], :int
65
- attach_function :proj_coordoperation_get_grid_used_count, [:PJ_CONTEXT, :PJ], :int
66
- attach_function :proj_coordoperation_get_grid_used, [:PJ_CONTEXT, :PJ, :int,
67
- :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :int
68
-
69
- # Network
70
- attach_function :proj_context_get_url_endpoint, [:PJ_CONTEXT], :string
71
- attach_function :proj_context_get_user_writable_directory, [:PJ_CONTEXT, :int], :string
72
- end
73
- end
data/lib/api/api_7_2.rb DELETED
@@ -1,14 +0,0 @@
1
- module Proj
2
- module Api
3
- attach_function :proj_context_clone, [:PJ_CONTEXT], :PJ_CONTEXT
4
- attach_function :proj_context_set_ca_bundle_path, [:PJ_CONTEXT, :string], :void
5
-
6
- # Datum ensembles
7
- attach_function :proj_crs_get_datum_ensemble, [:PJ_CONTEXT, :PJ], :PJ
8
- attach_function :proj_crs_get_datum_forced, [:PJ_CONTEXT, :PJ], :PJ
9
- attach_function :proj_datum_ensemble_get_member_count, [:PJ_CONTEXT, :PJ], :int
10
- attach_function :proj_datum_ensemble_get_accuracy, [:PJ_CONTEXT, :PJ], :double
11
- attach_function :proj_datum_ensemble_get_member, [:PJ_CONTEXT, :PJ, :int], :PJ
12
- attach_function :proj_dynamic_datum_get_frame_reference_epoch, [:PJ_CONTEXT, :PJ], :double
13
- end
14
- end
data/lib/api/api_8_0.rb DELETED
@@ -1,6 +0,0 @@
1
- module Proj
2
- module Api
3
- attach_function :proj_crs_is_derived, [:PJ_CONTEXT, :PJ], :int
4
- attach_function :proj_context_errno_string, [:PJ_CONTEXT, :int], :string
5
- end
6
- end
data/lib/api/api_8_1.rb DELETED
@@ -1,24 +0,0 @@
1
- module Proj
2
- module Api
3
- # Stores a description of a celestial body.
4
- class ProjCelestialBodyInfo < FFI::Struct
5
- layout :auth_name, :string,
6
- :name, :string
7
- end
8
-
9
- attach_function :proj_context_get_database_structure, [:PJ_CONTEXT, :pointer], :PROJ_STRING_LIST
10
- attach_function :proj_get_geoid_models_from_database, [:PJ_CONTEXT, :string, :string, :pointer], :PROJ_STRING_LIST
11
- attach_function :proj_suggests_code_for, [:PJ_CONTEXT, :PJ, :string, :int, :pointer], :pointer
12
- attach_function :proj_string_destroy, [:pointer], :void
13
-
14
- attach_function :proj_get_celestial_body_list_from_database, [:PJ_CONTEXT, :string, :pointer], :pointer
15
- attach_function :proj_get_celestial_body_name, [:PJ_CONTEXT, :PJ], :string
16
- attach_function :proj_celestial_body_list_destroy, [:pointer], :void
17
-
18
- typedef :pointer, :PJ_INSERT_SESSION
19
- attach_function :proj_insert_object_session_create, [:PJ_CONTEXT], :PJ_INSERT_SESSION
20
- attach_function :proj_insert_object_session_destroy, [:PJ_CONTEXT, :PJ_INSERT_SESSION], :void
21
- attach_function :proj_get_insert_statements, [:PJ_CONTEXT, :PJ_INSERT_SESSION, :PJ, :string, :string, :int,
22
- :pointer , :pointer], :PROJ_STRING_LIST
23
- end
24
- end
data/lib/api/api_8_2.rb DELETED
@@ -1,6 +0,0 @@
1
- module Proj
2
- module Api
3
- attach_function :proj_trans_bounds, [:PJ_CONTEXT, :PJ, PJ_DIRECTION, :double, :double, :double, :double,
4
- :pointer, :pointer, :pointer, :pointer, :int], :int
5
- end
6
- end
data/lib/api/api_9_1.rb DELETED
@@ -1,7 +0,0 @@
1
- module Proj
2
- module Api
3
- attach_function :proj_trans_get_last_used_operation, [:PJ], :PJ
4
- attach_function :proj_operation_factory_context_set_area_of_interest_name, [:PJ_CONTEXT, :pointer, :string], :void
5
- attach_function :proj_area_set_name, [:PJ_AREA, :string], :void
6
- end
7
- end
data/lib/api/api_9_2.rb DELETED
@@ -1,9 +0,0 @@
1
- module Proj
2
- module Api
3
- attach_function :proj_rtodms2, [:pointer, :size_t, :double, :int, :int], :string
4
- attach_function :proj_get_area_of_use_ex, [:PJ_CONTEXT, :PJ, :int, :pointer, :pointer, :pointer, :pointer, :pointer], :bool
5
- attach_function :proj_get_domain_count, [:PJ], :int
6
- attach_function :proj_get_scope_ex, [:PJ, :int], :string
7
- attach_function :proj_coordinate_metadata_get_epoch, [:PJ_CONTEXT, :PJ], :double
8
- end
9
- end
@@ -1,201 +0,0 @@
1
- module Proj
2
- module Api
3
- if Api::PROJ_VERSION >= Gem::Version.new('6.0.0')
4
-
5
- # @return [Symbol]
6
- PJ_UNIT_TYPE = enum(:PJ_UT_ANGULAR,
7
- :PJ_UT_LINEAR,
8
- :PJ_UT_SCALE,
9
- :PJ_UT_TIME)
10
-
11
- # @return [Symbol]
12
- PJ_CARTESIAN_CS_2D_TYPE = enum(:PJ_CART2D_EASTING_NORTHING,
13
- :PJ_CART2D_NORTHING_EASTING,
14
- :PJ_CART2D_NORTH_POLE_EASTING_SOUTH_NORTHING_SOUTH,
15
- :PJ_CART2D_SOUTH_POLE_EASTING_NORTH_NORTHING_NORTH,
16
- :PJ_CART2D_WESTING_SOUTHING)
17
-
18
- # @return [Symbol]
19
- PJ_ELLIPSOIDAL_CS_2D_TYPE = enum(:PJ_ELLPS2D_LONGITUDE_LATITUDE,
20
- :PJ_ELLPS2D_LATITUDE_LONGITUDE)
21
-
22
- class PJ_AXIS_DESCRIPTION < FFI::Struct
23
- layout :name, :pointer,
24
- :abbreviation, :pointer,
25
- :direction, :pointer,
26
- :unit_name, :pointer,
27
- :unit_conv_factor, :double,
28
- :unit_type, PJ_UNIT_TYPE
29
-
30
- def self.create(name:, abbreviation:, direction:, unit_name:, unit_conv_factor:, unit_type:)
31
- result = PJ_AXIS_DESCRIPTION.new
32
- result[:name] = FFI::MemoryPointer.from_string(name)
33
- result[:abbreviation] = FFI::MemoryPointer.from_string(abbreviation)
34
- result[:direction] = FFI::MemoryPointer.from_string(direction)
35
- result[:unit_name] = FFI::MemoryPointer.from_string(unit_name)
36
- result[:unit_conv_factor] = unit_conv_factor
37
- result[:unit_type] = unit_type
38
- result
39
- end
40
- end
41
-
42
- class PJ_PARAM_DESCRIPTION < FFI::Struct
43
- layout :name, :pointer,
44
- :auth_name, :pointer,
45
- :code, :pointer,
46
- :value, :double,
47
- :unit_name, :pointer,
48
- :unit_conv_factor, :double,
49
- :unit_type, PJ_UNIT_TYPE
50
-
51
- def self.create(name:, auth_name: nil, code: nil, value:, unit_name: nil, unit_conv_factor:, unit_type:)
52
- result = PJ_PARAM_DESCRIPTION.new
53
- result[:name] = FFI::MemoryPointer.from_string(name)
54
- result[:auth_name] = auth_name ? FFI::MemoryPointer.from_string(auth_name) : nil
55
- result[:code] = code ? FFI::MemoryPointer.from_string(code) : nil
56
- result[:value] = value
57
- result[:unit_name] = unit_name ? FFI::MemoryPointer.from_string(unit_name) : nil
58
- result[:unit_conv_factor] = unit_conv_factor
59
- result[:unit_type] = unit_type
60
- result
61
- end
62
- end
63
-
64
- # Create coordinate systems
65
- attach_function :proj_create_cs, [:PJ_CONTEXT, PJ_COORDINATE_SYSTEM_TYPE, :int, :pointer], :PJ
66
- attach_function :proj_create_cartesian_2D_cs, [:PJ_CONTEXT, PJ_CARTESIAN_CS_2D_TYPE, :string, :double], :PJ
67
- attach_function :proj_create_ellipsoidal_2D_cs, [:PJ_CONTEXT, PJ_ELLIPSOIDAL_CS_2D_TYPE, :string, :double], :PJ
68
-
69
- # Create CRSes
70
- attach_function :proj_create_geographic_crs, [:PJ_CONTEXT, :string, :string, :string, :double, :double, :string, :double, :string, :double, :PJ], :PJ
71
- attach_function :proj_create_geocentric_crs, [:PJ_CONTEXT, :string, :string, :string, :double, :double, :string, :double, :string, :double, :string, :double], :PJ
72
- attach_function :proj_crs_alter_geodetic_crs, [:PJ_CONTEXT, :PJ, :PJ], :PJ
73
- attach_function :proj_crs_alter_cs_angular_unit, [:PJ_CONTEXT, :PJ, :string, :double, :string, :string], :PJ
74
- attach_function :proj_crs_alter_cs_linear_unit, [:PJ_CONTEXT, :PJ, :string, :double, :string, :string], :PJ
75
- attach_function :proj_crs_alter_parameters_linear_unit, [:PJ_CONTEXT, :PJ, :string, :double, :string, :string, :int], :PJ
76
- attach_function :proj_create_engineering_crs, [:PJ_CONTEXT, :string], :PJ
77
- attach_function :proj_create_vertical_crs, [:PJ_CONTEXT, :string, :string, :string, :double], :PJ
78
- attach_function :proj_create_compound_crs, [:PJ_CONTEXT, :string, :PJ, :PJ], :PJ
79
- attach_function :proj_create_projected_crs, [:PJ_CONTEXT, :string, :PJ, :PJ, :PJ], :PJ
80
- attach_function :proj_crs_create_bound_crs, [:PJ_CONTEXT, :PJ, :PJ, :PJ], :PJ
81
- attach_function :proj_crs_create_bound_crs_to_WGS84, [:PJ_CONTEXT, :PJ, :pointer], :PJ
82
-
83
- # Modify CRS
84
- attach_function :proj_alter_name, [:PJ_CONTEXT, :PJ, :string], :PJ
85
- attach_function :proj_alter_id, [:PJ_CONTEXT, :PJ, :string, :string], :PJ
86
-
87
- # Transformation
88
- attach_function :proj_create_transformation, [:PJ_CONTEXT, :string, :string, :string, :PJ, :PJ, :PJ, :string, :string, :string, :int, :pointer, :double], :PJ
89
-
90
- # Conversion
91
- attach_function :proj_create_conversion, [:PJ_CONTEXT, :string, :string, :string, :string, :string, :string, :int, :pointer], :PJ
92
- attach_function :proj_convert_conversion_to_other_method, [:PJ_CONTEXT, :PJ, :int, :string], :PJ
93
-
94
- # Projections
95
- attach_function :proj_create_conversion_utm, [:PJ_CONTEXT, :int, :int], :PJ
96
- attach_function :proj_create_conversion_transverse_mercator, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
97
- attach_function :proj_create_conversion_gauss_schreiber_transverse_mercator, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
98
- attach_function :proj_create_conversion_transverse_mercator_south_oriented, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
99
- attach_function :proj_create_conversion_two_point_equidistant, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
100
- attach_function :proj_create_conversion_albers_equal_area, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
101
- attach_function :proj_create_conversion_lambert_conic_conformal_1sp, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
102
- attach_function :proj_create_conversion_lambert_conic_conformal_2sp, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
103
- attach_function :proj_create_conversion_lambert_conic_conformal_2sp_michigan, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
104
- attach_function :proj_create_conversion_lambert_conic_conformal_2sp_belgium, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
105
- attach_function :proj_create_conversion_azimuthal_equidistant, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
106
- attach_function :proj_create_conversion_guam_projection, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
107
- attach_function :proj_create_conversion_bonne, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
108
- attach_function :proj_create_conversion_lambert_cylindrical_equal_area_spherical, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
109
- attach_function :proj_create_conversion_lambert_cylindrical_equal_area, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
110
- attach_function :proj_create_conversion_cassini_soldner, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
111
- attach_function :proj_create_conversion_equidistant_conic, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
112
- attach_function :proj_create_conversion_eckert_i, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
113
- attach_function :proj_create_conversion_eckert_ii, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
114
- attach_function :proj_create_conversion_eckert_iii, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
115
- attach_function :proj_create_conversion_eckert_iv, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
116
- attach_function :proj_create_conversion_eckert_v, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
117
- attach_function :proj_create_conversion_eckert_vi, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
118
- attach_function :proj_create_conversion_equidistant_cylindrical, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
119
- attach_function :proj_create_conversion_equidistant_cylindrical_spherical, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
120
- attach_function :proj_create_conversion_gall, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
121
- attach_function :proj_create_conversion_goode_homolosine, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
122
- attach_function :proj_create_conversion_interrupted_goode_homolosine, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
123
- attach_function :proj_create_conversion_geostationary_satellite_sweep_x, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
124
- attach_function :proj_create_conversion_geostationary_satellite_sweep_y, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
125
- attach_function :proj_create_conversion_gnomonic, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
126
- attach_function :proj_create_conversion_hotine_oblique_mercator_variant_a, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
127
- attach_function :proj_create_conversion_hotine_oblique_mercator_variant_b, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
128
- attach_function :proj_create_conversion_hotine_oblique_mercator_two_point_natural_origin, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
129
- attach_function :proj_create_conversion_laborde_oblique_mercator, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
130
- attach_function :proj_create_conversion_international_map_world_polyconic, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
131
- attach_function :proj_create_conversion_krovak_north_oriented, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
132
- attach_function :proj_create_conversion_krovak, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
133
- attach_function :proj_create_conversion_lambert_azimuthal_equal_area, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
134
- attach_function :proj_create_conversion_miller_cylindrical, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
135
- attach_function :proj_create_conversion_mercator_variant_a, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
136
- attach_function :proj_create_conversion_mercator_variant_b, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
137
- attach_function :proj_create_conversion_popular_visualisation_pseudo_mercator, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
138
- attach_function :proj_create_conversion_mollweide, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
139
- attach_function :proj_create_conversion_new_zealand_mapping_grid, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
140
- attach_function :proj_create_conversion_oblique_stereographic, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
141
- attach_function :proj_create_conversion_orthographic, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
142
- attach_function :proj_create_conversion_american_polyconic, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
143
- attach_function :proj_create_conversion_polar_stereographic_variant_a, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
144
- attach_function :proj_create_conversion_polar_stereographic_variant_b, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
145
- attach_function :proj_create_conversion_robinson, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
146
- attach_function :proj_create_conversion_sinusoidal, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
147
- attach_function :proj_create_conversion_stereographic, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
148
- attach_function :proj_create_conversion_van_der_grinten, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
149
- attach_function :proj_create_conversion_wagner_i, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
150
- attach_function :proj_create_conversion_wagner_ii, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
151
- attach_function :proj_create_conversion_wagner_iii, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
152
- attach_function :proj_create_conversion_wagner_iv, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
153
- attach_function :proj_create_conversion_wagner_v, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
154
- attach_function :proj_create_conversion_wagner_vi, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
155
- attach_function :proj_create_conversion_wagner_vii, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
156
- attach_function :proj_create_conversion_quadrilateralized_spherical_cube, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
157
- attach_function :proj_create_conversion_spherical_cross_track_height, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
158
- attach_function :proj_create_conversion_equal_earth, [:PJ_CONTEXT, :double, :double, :double, :string, :double, :string, :double], :PJ
159
- attach_function :proj_query_geodetic_crs_from_datum, [:PJ_CONTEXT, :string, :string, :string, :string], :PJ_OBJ_LIST
160
- end
161
-
162
- if Api::PROJ_VERSION >= Gem::Version.new('6.3.0')
163
- # @return [Symbol]
164
- PJ_ELLIPSOIDAL_CS_3D_TYPE = enum(:PJ_ELLPS3D_LONGITUDE_LATITUDE_HEIGHT,
165
- :PJ_ELLPS3D_LATITUDE_LONGITUDE_HEIGHT)
166
-
167
- # Coordinate System
168
- attach_function :proj_create_ellipsoidal_3D_cs, [:PJ_CONTEXT, PJ_ELLIPSOIDAL_CS_3D_TYPE, :string, :double, :string, :double], :PJ
169
-
170
- # CRS
171
- attach_function :proj_create_derived_geographic_crs, [:PJ_CONTEXT, :string, :PJ, :PJ, :PJ], :PJ
172
- attach_function :proj_is_derived_crs, [:PJ_CONTEXT, :PJ], :int
173
- attach_function :proj_crs_promote_to_3D, [:PJ_CONTEXT, :string, :PJ], :PJ
174
- attach_function :proj_crs_create_projected_3D_crs_from_2D, [:PJ_CONTEXT, :string, :PJ, :PJ], :PJ
175
- attach_function :proj_crs_demote_to_2D, [:PJ_CONTEXT, :string, :PJ], :PJ
176
- attach_function :proj_create_vertical_crs_ex, [:PJ_CONTEXT, :string, :string, :string, :string, :string, :double, :string, :string, :string, :PJ, :pointer], :PJ
177
- attach_function :proj_crs_create_bound_vertical_crs, [:PJ_CONTEXT, :PJ, :PJ, :string], :PJ
178
-
179
- # Projections
180
- attach_function :proj_create_conversion_vertical_perspective, [:PJ_CONTEXT, :double, :double, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
181
- attach_function :proj_create_conversion_pole_rotation_grib_convention, [:PJ_CONTEXT, :double, :double, :double, :string, :double], :PJ
182
- end
183
-
184
- if Api::PROJ_VERSION >= Gem::Version.new('7.2.0')
185
- # CRS
186
- attach_function :proj_create_geographic_crs_from_datum, [:PJ_CONTEXT, :string, :PJ, :PJ], :PJ
187
- attach_function :proj_create_geocentric_crs_from_datum, [:PJ_CONTEXT, :string, :PJ, :string, :double], :PJ
188
- end
189
-
190
- if Api::PROJ_VERSION >= Gem::Version.new('8.2.0')
191
- # Projection
192
- attach_function :proj_create_conversion_pole_rotation_netcdf_cf_convention, [:PJ_CONTEXT, :double, :double, :double, :string, :double], :PJ
193
- end
194
-
195
- if Api::PROJ_VERSION >= Gem::Version.new('9.2.0')
196
- # Projection
197
- attach_function :proj_create_conversion_tunisia_mining_grid, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
198
- attach_function :proj_create_conversion_tunisia_mapping_grid, [:PJ_CONTEXT, :double, :double, :double, :double, :string, :double, :string, :double], :PJ
199
- end
200
- end
201
- end
data/lib/proj/file_api.rb DELETED
@@ -1,166 +0,0 @@
1
- module Proj
2
- module FileApiCallbacks
3
- def install_callbacks(context)
4
- proj_file_api = Api::PROJ_FILE_API.new
5
- proj_file_api[:version] = 1
6
-
7
- # Store procs to instance variables so they don't get garbage collected
8
- @open_cbk = proj_file_api[:open_cbk] = self.method(:open_callback)
9
- @read_cbk = proj_file_api[:read_cbk] = self.method(:read_callback)
10
- @write_cbk = proj_file_api[:write_cbk] = self.method(:write_callback)
11
- @seek_cbk = proj_file_api[:seek_cbk] = self.method(:seek_callback)
12
- @tell_cbk = proj_file_api[:tell_cbk] = self.method(:tell_callback)
13
- @close_cbk = proj_file_api[:close_cbk] = self.method(:close_callback)
14
- @exists_cbk = proj_file_api[:exists_cbk] = self.method(:exists_callback)
15
- @mkdir_cbk = proj_file_api[:mkdir_cbk] = self.method(:mkdir_callback)
16
- @unlink_cbk = proj_file_api[:unlink_cbk] = self.method(:unlink_callback)
17
- @rename_cbk = proj_file_api[:rename_cbk] = self.method(:rename_callback)
18
-
19
- result = Api.proj_context_set_fileapi(context, proj_file_api, nil)
20
-
21
- if result != 1
22
- Error.check_object(self)
23
- end
24
- end
25
-
26
- # Open file. Return NULL if error
27
- def open_callback(context, path, access_mode, user_data)
28
- result = self.open(path, access_mode)
29
- result ? FFI::MemoryPointer.new(:size_t) : nil
30
- end
31
-
32
- # Read sizeBytes into buffer from current position and return number of bytes read
33
- def read_callback(context, handle, buffer, size_bytes, user_data)
34
- data = self.read(size_bytes)
35
- read_bytes = [size_bytes, data.size].min
36
- buffer.write_bytes(data, 0, read_bytes)
37
- read_bytes
38
- end
39
-
40
- # Write sizeBytes into buffer from current position and return number of bytes written
41
- def write_callback(context, handle, buffer, size_bytes, user_data)
42
- data = buffer.get_bytes(0, size_bytes)
43
- self.write(data)
44
- end
45
-
46
- # Seek to offset using whence=SEEK_SET/SEEK_CUR/SEEK_END. Return TRUE in case of success
47
- def seek_callback(context, handle, offset, whence, user_data)
48
- self.seek(offset, whence)
49
- return 1 # True
50
- end
51
-
52
- # Return current file position
53
- def tell_callback(context, handle, user_data)
54
- self.tell
55
- end
56
-
57
- # Close file
58
- def close_callback(context, handle, user_data)
59
- self.close
60
- end
61
-
62
- # Return TRUE if a file exists
63
- def exists_callback(context, path, user_data)
64
- if self.exists(path)
65
- 1
66
- else
67
- 0
68
- end
69
- end
70
-
71
- # Return TRUE if directory exists or could be created
72
- def mkdir_callback(context, path, user_data)
73
- if self.mdkir(path)
74
- 1
75
- else
76
- 0
77
- end
78
- end
79
-
80
- # Return TRUE if file could be removed
81
- def unlink_callback(context, path, user_data)
82
- if self.unlink(path)
83
- 1
84
- else
85
- 0
86
- end
87
- end
88
-
89
- # Return TRUE if file could be renamed
90
- def rename_callback(context, original_path, new_path, user_data)
91
- if self.rename(original_path, new_path)
92
- 1
93
- else
94
- 0
95
- end
96
- end
97
- end
98
-
99
- # Proj allows its file api to be replaced by a custom implementation. This can be
100
- # done by calling Context#set_file_api with a user defined Class that includes the
101
- # FileApiCallbacks module and implements its required methods.
102
- #
103
- # The FileApiImpl class is a simple example file api implementation.
104
- class FileApiImpl
105
- include FileApiCallbacks
106
-
107
- def initialize(context)
108
- install_callbacks(context)
109
- end
110
-
111
- def open(path, access_mode)
112
- case access_mode
113
- when :PROJ_OPEN_ACCESS_READ_ONLY
114
- if File.exist?(path)
115
- @file = File.open(path, :mode => 'rb')
116
- else
117
- nil # False
118
- end
119
- when :PROJ_OPEN_ACCESS_READ_UPDATE
120
- if File.exist?(path)
121
- @file = File.open(path, :mode => 'r+b')
122
- else
123
- nil # False
124
- end
125
- when :PROJ_OPEN_ACCESS_CREATE
126
- @file = File.open(path, :mode => 'wb')
127
- end
128
- end
129
-
130
- def read(size_bytes)
131
- @file.read(size_bytes)
132
- end
133
-
134
- def write(data)
135
- @file.write(data)
136
- end
137
-
138
- def seek(offset, whence)
139
- @file.seek(offset, whence)
140
- end
141
-
142
- def tell
143
- @file.tell
144
- end
145
-
146
- def close
147
- @file.close
148
- end
149
-
150
- def exists(path)
151
- File.exist?(path)
152
- end
153
-
154
- def mkdir(path)
155
- Dir.mkdir(path)
156
- end
157
-
158
- def unlink(path)
159
- File.unlink(path) if File.exist?(path)
160
- end
161
-
162
- def rename(original_path, new_path)
163
- File.rename(original_path, new_path)
164
- end
165
- end
166
- end