ffi-gdal 1.0.0.beta16 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +17 -0
  3. data/.github/workflows/codacy.yml +61 -0
  4. data/.github/workflows/codeql.yml +74 -0
  5. data/.github/workflows/continuous-integration.yml +36 -0
  6. data/.github/workflows/dependency-review.yml +20 -0
  7. data/.github/workflows/specs-in-docker.yml +27 -0
  8. data/.gitignore +3 -0
  9. data/.rspec +1 -0
  10. data/.rubocop.yml +10 -80
  11. data/.rubocop_todo.yml +23 -40
  12. data/.ruby-version +1 -1
  13. data/Changelog-0.x.md +512 -0
  14. data/Changelog.md +12 -0
  15. data/Dockerfile.gdal2 +110 -0
  16. data/Dockerfile.gdal3 +73 -0
  17. data/README.md +25 -14
  18. data/Rakefile +0 -8
  19. data/Tiltfile +91 -0
  20. data/bin/bundle +123 -0
  21. data/bin/docker-clean +8 -0
  22. data/bin/rake +29 -0
  23. data/bin/rspec +29 -0
  24. data/bin/rubocop +29 -0
  25. data/docker-compose.yml +25 -0
  26. data/examples/extract_and_colorize.rb +0 -13
  27. data/examples/geometries.rb +14 -14
  28. data/examples/ogr_layer_to_layer.rb +1 -3
  29. data/examples/raster_erasing.rb +1 -0
  30. data/examples/remove_small_polygons.rb +1 -1
  31. data/examples/testing_gdal.rb +20 -17
  32. data/examples/warping.rb +9 -7
  33. data/ffi-gdal.gemspec +12 -6
  34. data/lib/ext/ffi_library_function_checks.rb +2 -2
  35. data/lib/ext/to_bool.rb +5 -3
  36. data/lib/ffi/cpl/conv.rb +27 -25
  37. data/lib/ffi/cpl/error.rb +19 -20
  38. data/lib/ffi/cpl/hash_set.rb +4 -4
  39. data/lib/ffi/cpl/http.rb +3 -3
  40. data/lib/ffi/cpl/http_result.rb +8 -8
  41. data/lib/ffi/cpl/list.rb +1 -1
  42. data/lib/ffi/cpl/mime_part.rb +2 -2
  43. data/lib/ffi/cpl/minixml.rb +7 -7
  44. data/lib/ffi/cpl/progress.rb +8 -8
  45. data/lib/ffi/cpl/quad_tree.rb +14 -14
  46. data/lib/ffi/cpl/rect_obj.rb +3 -3
  47. data/lib/ffi/cpl/string.rb +17 -20
  48. data/lib/ffi/cpl/vsi.rb +13 -13
  49. data/lib/ffi/cpl/xml_node.rb +3 -3
  50. data/lib/ffi/extensions/gdal/extensions/all.rb +4 -0
  51. data/lib/ffi/extensions/gdal/extensions/version.rb +9 -0
  52. data/lib/ffi/extensions/gdal/extensions.rb +12 -0
  53. data/lib/ffi/extensions/rttopo/gbox.rb +19 -0
  54. data/lib/ffi/extensions/rttopo/geom.rb +16 -0
  55. data/lib/ffi/extensions/rttopo.rb +41 -0
  56. data/lib/ffi/gdal/alg.rb +277 -277
  57. data/lib/ffi/gdal/color_entry.rb +3 -3
  58. data/lib/ffi/gdal/gcp.rb +6 -6
  59. data/lib/ffi/gdal/gdal.rb +349 -349
  60. data/lib/ffi/gdal/grid.rb +134 -134
  61. data/lib/ffi/gdal/grid_data_metrics_options.rb +4 -4
  62. data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +9 -9
  63. data/lib/ffi/gdal/grid_moving_average_options.rb +4 -4
  64. data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +3 -3
  65. data/lib/ffi/gdal/matching.rb +3 -3
  66. data/lib/ffi/gdal/rpc_info.rb +17 -17
  67. data/lib/ffi/gdal/transformer_info.rb +4 -4
  68. data/lib/ffi/gdal/version.rb +1 -1
  69. data/lib/ffi/gdal/vrt.rb +39 -39
  70. data/lib/ffi/gdal/warp_options.rb +34 -34
  71. data/lib/ffi/gdal/warper.rb +90 -90
  72. data/lib/ffi/gdal.rb +2 -31
  73. data/lib/ffi/ogr/api.rb +175 -167
  74. data/lib/ffi/ogr/contour_writer_info.rb +4 -4
  75. data/lib/ffi/ogr/core.rb +107 -107
  76. data/lib/ffi/ogr/envelope.rb +3 -3
  77. data/lib/ffi/ogr/envelope_3d.rb +5 -5
  78. data/lib/ffi/ogr/featurestyle.rb +3 -3
  79. data/lib/ffi/ogr/field.rb +22 -22
  80. data/lib/ffi/ogr/geocoding.rb +4 -4
  81. data/lib/ffi/ogr/srs_api.rb +154 -155
  82. data/lib/ffi/ogr/style_param.rb +3 -3
  83. data/lib/ffi/ogr/style_value.rb +4 -4
  84. data/lib/gdal/color_entry.rb +1 -5
  85. data/lib/gdal/color_interpretation.rb +7 -3
  86. data/lib/gdal/color_table.rb +46 -27
  87. data/lib/gdal/cpl_error_handler.rb +26 -6
  88. data/lib/gdal/data_type.rb +10 -3
  89. data/lib/gdal/dataset.rb +171 -85
  90. data/lib/gdal/dataset_mixins/algorithm_methods.rb +44 -44
  91. data/lib/gdal/dataset_mixins/matching.rb +1 -1
  92. data/lib/gdal/dataset_mixins/warp_methods.rb +4 -2
  93. data/lib/gdal/driver.rb +38 -21
  94. data/lib/gdal/environment_methods.rb +6 -6
  95. data/lib/gdal/extensions/all.rb +3 -0
  96. data/lib/gdal/{color_entry_mixins → extensions/color_entry}/extensions.rb +4 -1
  97. data/lib/gdal/{color_table_mixins → extensions/color_table}/extensions.rb +3 -0
  98. data/lib/gdal/extensions/dataset/extensions.rb +205 -0
  99. data/lib/gdal/{driver_mixins → extensions/driver}/extensions.rb +6 -2
  100. data/lib/gdal/{geo_transform_mixins → extensions/geo_transform}/extensions.rb +10 -8
  101. data/lib/gdal/{gridder → extensions/gridder}/point_extracting.rb +7 -5
  102. data/lib/gdal/{gridder.rb → extensions/gridder.rb} +33 -33
  103. data/lib/gdal/{gridder_options.rb → extensions/gridder_options.rb} +13 -14
  104. data/lib/gdal/{raster_attribute_table_mixins → extensions/raster_attribute_table}/extensions.rb +8 -6
  105. data/lib/gdal/{raster_band_mixins → extensions/raster_band}/algorithm_extensions.rb +8 -6
  106. data/lib/gdal/{raster_band_mixins → extensions/raster_band}/coloring_extensions.rb +6 -4
  107. data/lib/gdal/{raster_band_mixins → extensions/raster_band}/extensions.rb +9 -5
  108. data/lib/gdal/{raster_band_mixins → extensions/raster_band}/io_extensions.rb +18 -14
  109. data/lib/gdal/{raster_band_classifier.rb → extensions/raster_band_classifier.rb} +3 -5
  110. data/lib/gdal/geo_transform.rb +1 -6
  111. data/lib/gdal/grid.rb +3 -2
  112. data/lib/gdal/grid_algorithms.rb +9 -9
  113. data/lib/gdal/internal_helpers.rb +46 -9
  114. data/lib/gdal/major_object.rb +11 -3
  115. data/lib/gdal/options.rb +26 -32
  116. data/lib/gdal/raster_attribute_table.rb +63 -37
  117. data/lib/gdal/raster_band.rb +164 -116
  118. data/lib/gdal/raster_band_mixins/algorithm_methods.rb +26 -25
  119. data/lib/gdal/rpc_info.rb +3 -2
  120. data/lib/gdal/transformers/approximate_transformer.rb +12 -3
  121. data/lib/gdal/transformers/base_general_image_projection_transformer.rb +15 -2
  122. data/lib/gdal/transformers/gcp_transformer.rb +27 -19
  123. data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -6
  124. data/lib/gdal/transformers/general_image_projection_transformer2.rb +9 -6
  125. data/lib/gdal/transformers/general_image_projection_transformer3.rb +6 -2
  126. data/lib/gdal/transformers/geolocation_transformer.rb +12 -4
  127. data/lib/gdal/transformers/reprojection_transformer.rb +11 -3
  128. data/lib/gdal/transformers/rpc_transformer.rb +11 -2
  129. data/lib/gdal/transformers/tps_transformer.rb +12 -4
  130. data/lib/gdal/version_info.rb +2 -2
  131. data/lib/gdal/virtual_dataset.rb +2 -0
  132. data/lib/gdal/warp_operation.rb +65 -54
  133. data/lib/gdal/warp_options.rb +9 -11
  134. data/lib/ogr/coordinate_transformation.rb +23 -9
  135. data/lib/ogr/data_source.rb +68 -37
  136. data/lib/ogr/driver.rb +18 -17
  137. data/lib/ogr/envelope.rb +0 -3
  138. data/lib/ogr/error_handling.rb +22 -24
  139. data/lib/ogr/extensions/all.rb +3 -0
  140. data/lib/ogr/{data_source_mixins → extensions/data_source}/capability_methods.rb +2 -0
  141. data/lib/ogr/extensions/data_source/data_source_extensions.rb +16 -0
  142. data/lib/ogr/{driver_mixins → extensions/driver}/capability_methods.rb +5 -1
  143. data/lib/ogr/extensions/envelope/extensions.rb +114 -0
  144. data/lib/ogr/extensions/feature/extensions.rb +87 -0
  145. data/lib/ogr/extensions/feature_definition/extensions.rb +43 -0
  146. data/lib/ogr/extensions/geometries/point/extensions.rb +19 -0
  147. data/lib/ogr/extensions/geometry/container_mixins.rb +56 -0
  148. data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +44 -0
  149. data/lib/ogr/extensions/geometry/ewkb_record.rb +94 -0
  150. data/lib/ogr/{geometry_mixins → extensions/geometry}/extensions.rb +16 -9
  151. data/lib/ogr/extensions/geometry/rttopo_extensions.rb +48 -0
  152. data/lib/ogr/extensions/geometry/wkb_record.rb +63 -0
  153. data/lib/ogr/extensions/geometry_types/curve/extensions.rb +68 -0
  154. data/lib/ogr/{layer_mixins → extensions/layer}/capability_methods.rb +4 -0
  155. data/lib/ogr/{layer_mixins → extensions/layer}/extensions.rb +11 -6
  156. data/lib/ogr/extensions/spatial_reference/extensions.rb +38 -0
  157. data/lib/ogr/extensions/spatial_reference/initializers.rb +138 -0
  158. data/lib/ogr/extensions/style_table/extensions.rb +31 -0
  159. data/lib/ogr/feature.rb +173 -88
  160. data/lib/ogr/feature_definition.rb +53 -45
  161. data/lib/ogr/field.rb +17 -19
  162. data/lib/ogr/field_definition.rb +30 -18
  163. data/lib/ogr/geocoder.rb +11 -4
  164. data/lib/ogr/geometries/line_string.rb +1 -0
  165. data/lib/ogr/geometries/line_string_25d.rb +0 -9
  166. data/lib/ogr/geometries/linear_ring.rb +2 -2
  167. data/lib/ogr/geometries/point.rb +0 -9
  168. data/lib/ogr/geometry.rb +116 -49
  169. data/lib/ogr/geometry_field_definition.rb +31 -15
  170. data/lib/ogr/geometry_types/container.rb +26 -28
  171. data/lib/ogr/geometry_types/curve.rb +5 -61
  172. data/lib/ogr/geometry_types/surface.rb +1 -1
  173. data/lib/ogr/internal_helpers.rb +2 -2
  174. data/lib/ogr/layer.rb +12 -10
  175. data/lib/ogr/layer_mixins/ogr_feature_methods.rb +39 -27
  176. data/lib/ogr/layer_mixins/ogr_field_methods.rb +66 -50
  177. data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +17 -8
  178. data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +7 -6
  179. data/lib/ogr/layer_mixins/ogr_sql_methods.rb +15 -7
  180. data/lib/ogr/spatial_reference.rb +79 -42
  181. data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +149 -118
  182. data/lib/ogr/spatial_reference_mixins/exporters.rb +87 -51
  183. data/lib/ogr/spatial_reference_mixins/importers.rb +88 -43
  184. data/lib/ogr/spatial_reference_mixins/morphers.rb +12 -8
  185. data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +27 -13
  186. data/lib/ogr/style_table.rb +15 -5
  187. data/lib/ogr/style_tool.rb +29 -15
  188. data/lib/ogr.rb +1 -0
  189. data/rakelib/docker.rake +10 -0
  190. data/sorbet/rbi/hidden-definitions/errors.txt +21790 -0
  191. data/tilt/gdal2.yml +22 -0
  192. data/tilt/gdal3.yml +22 -0
  193. metadata +116 -280
  194. data/History.md +0 -360
  195. data/lib/ext/error_symbols.rb +0 -7
  196. data/lib/gdal/dataset_mixins/extensions.rb +0 -380
  197. data/lib/gdal/merger.rb +0 -132
  198. data/lib/ogr/data_source_extensions.rb +0 -10
  199. data/lib/ogr/envelope_extensions.rb +0 -110
  200. data/lib/ogr/feature_definition_extensions.rb +0 -39
  201. data/lib/ogr/feature_extensions.rb +0 -87
  202. data/lib/ogr/geometry_mixins/container_mixins.rb +0 -25
  203. data/lib/ogr/spatial_reference_extensions.rb +0 -34
  204. data/lib/ogr/style_table_extensions.rb +0 -26
  205. data/spec/ffi-gdal_spec.rb +0 -24
  206. data/spec/integration/gdal/color_table_info_spec.rb +0 -78
  207. data/spec/integration/gdal/dataset_info_spec.rb +0 -342
  208. data/spec/integration/gdal/driver_info_spec.rb +0 -170
  209. data/spec/integration/gdal/geo_transform_info_spec.rb +0 -226
  210. data/spec/integration/gdal/gridder_spec.rb +0 -331
  211. data/spec/integration/gdal/raster_attribute_table_info_spec.rb +0 -229
  212. data/spec/integration/gdal/raster_band_algorithms_spec.rb +0 -35
  213. data/spec/integration/gdal/raster_band_info_spec.rb +0 -320
  214. data/spec/integration/ogr/layer_spec.rb +0 -95
  215. data/spec/spec_helper.rb +0 -116
  216. data/spec/support/images/123.tiff +0 -0
  217. data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
  218. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +0 -31
  219. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
  220. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
  221. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +0 -10
  222. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
  223. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +0 -84
  224. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +0 -45
  225. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
  226. data/spec/support/integration_help.rb +0 -34
  227. data/spec/support/shapefiles/states_21basic/states.dbf +0 -0
  228. data/spec/support/shapefiles/states_21basic/states.prj +0 -1
  229. data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
  230. data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
  231. data/spec/support/shapefiles/states_21basic/states.shp +0 -0
  232. data/spec/support/shapefiles/states_21basic/states.shp.xml +0 -3
  233. data/spec/support/shapefiles/states_21basic/states.shx +0 -0
  234. data/spec/support/shared_contexts.rb +0 -28
  235. data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -55
  236. data/spec/support/shared_examples/ogr/a_25d_geometry.rb +0 -9
  237. data/spec/support/shared_examples/ogr/a_container_geometry.rb +0 -49
  238. data/spec/support/shared_examples/ogr/a_geometry.rb +0 -406
  239. data/spec/support/shared_examples/ogr/a_line_string.rb +0 -18
  240. data/spec/support/test_style_table.txt +0 -3
  241. data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +0 -1
  242. data/spec/support/worldfiles/SR_50M/SR_50M.prj +0 -1
  243. data/spec/support/worldfiles/SR_50M/SR_50M.tfw +0 -6
  244. data/spec/support/worldfiles/SR_50M/SR_50M.tif +0 -0
  245. data/spec/unit/ext/error_symbols_spec.rb +0 -69
  246. data/spec/unit/ext/numeric_as_data_type_spec.rb +0 -115
  247. data/spec/unit/ffi/gdal_spec.rb +0 -73
  248. data/spec/unit/gdal/color_entry_spec.rb +0 -8
  249. data/spec/unit/gdal/color_interpretation_spec.rb +0 -8
  250. data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +0 -62
  251. data/spec/unit/gdal/color_table_spec.rb +0 -146
  252. data/spec/unit/gdal/data_type_spec.rb +0 -74
  253. data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +0 -55
  254. data/spec/unit/gdal/dataset_spec.rb +0 -148
  255. data/spec/unit/gdal/driver_mixins/extensions_spec.rb +0 -24
  256. data/spec/unit/gdal/driver_spec.rb +0 -51
  257. data/spec/unit/gdal/environment_methods_spec.rb +0 -8
  258. data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +0 -69
  259. data/spec/unit/gdal/geo_transform_spec.rb +0 -265
  260. data/spec/unit/gdal/grid_spec.rb +0 -98
  261. data/spec/unit/gdal/gridder/point_extracting_spec.rb +0 -101
  262. data/spec/unit/gdal/gridder_options_spec.rb +0 -185
  263. data/spec/unit/gdal/gridder_spec.rb +0 -182
  264. data/spec/unit/gdal/internal_helpers_spec.rb +0 -278
  265. data/spec/unit/gdal/major_object_spec.rb +0 -10
  266. data/spec/unit/gdal/options_spec.rb +0 -33
  267. data/spec/unit/gdal/raster_attribute_table_spec.rb +0 -7
  268. data/spec/unit/gdal/raster_band_classifier_spec.rb +0 -260
  269. data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +0 -73
  270. data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +0 -135
  271. data/spec/unit/gdal/raster_band_spec.rb +0 -8
  272. data/spec/unit/gdal/rpc_info_spec.rb +0 -8
  273. data/spec/unit/gdal/version_info_spec.rb +0 -10
  274. data/spec/unit/gdal/virtual_dataset_spec.rb +0 -34
  275. data/spec/unit/gdal/warp_operation_spec.rb +0 -8
  276. data/spec/unit/gdal/warp_options_spec.rb +0 -338
  277. data/spec/unit/ogr/coordinate_transformation_spec.rb +0 -104
  278. data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +0 -32
  279. data/spec/unit/ogr/data_source_spec.rb +0 -223
  280. data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +0 -20
  281. data/spec/unit/ogr/driver_spec.rb +0 -152
  282. data/spec/unit/ogr/envelope_spec.rb +0 -324
  283. data/spec/unit/ogr/feature_definition_spec.rb +0 -296
  284. data/spec/unit/ogr/feature_extensions_spec.rb +0 -90
  285. data/spec/unit/ogr/feature_spec.rb +0 -363
  286. data/spec/unit/ogr/field_definition_spec.rb +0 -118
  287. data/spec/unit/ogr/field_spec.rb +0 -195
  288. data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +0 -25
  289. data/spec/unit/ogr/geometries/geometry_collection_spec.rb +0 -188
  290. data/spec/unit/ogr/geometries/line_string_25d_spec.rb +0 -25
  291. data/spec/unit/ogr/geometries/line_string_spec.rb +0 -107
  292. data/spec/unit/ogr/geometries/linear_ring_spec.rb +0 -92
  293. data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +0 -25
  294. data/spec/unit/ogr/geometries/multi_line_string_spec.rb +0 -16
  295. data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +0 -25
  296. data/spec/unit/ogr/geometries/multi_point_spec.rb +0 -16
  297. data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +0 -25
  298. data/spec/unit/ogr/geometries/multi_polygon_spec.rb +0 -43
  299. data/spec/unit/ogr/geometries/none_geometry_spec.rb +0 -14
  300. data/spec/unit/ogr/geometries/point_25d_spec.rb +0 -25
  301. data/spec/unit/ogr/geometries/point_spec.rb +0 -307
  302. data/spec/unit/ogr/geometries/polygon_25d_spec.rb +0 -25
  303. data/spec/unit/ogr/geometries/polygon_spec.rb +0 -19
  304. data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +0 -12
  305. data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -73
  306. data/spec/unit/ogr/geometry_spec.rb +0 -711
  307. data/spec/unit/ogr/internal_helpers_spec.rb +0 -70
  308. data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +0 -90
  309. data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +0 -155
  310. data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +0 -434
  311. data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +0 -22
  312. data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +0 -44
  313. data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +0 -14
  314. data/spec/unit/ogr/layer_spec.rb +0 -98
  315. data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +0 -48
  316. data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +0 -151
  317. data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +0 -40
  318. data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +0 -38
  319. data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +0 -105
  320. data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +0 -159
  321. data/spec/unit/ogr/spatial_reference_spec.rb +0 -44
  322. data/spec/unit/ogr/style_table_spec.rb +0 -108
  323. data/spec/unit/ogr/style_tool_spec.rb +0 -159
  324. data/spec/unit/version_info_spec.rb +0 -50
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ext/error_symbols'
5
-
6
- RSpec.describe Symbol do
7
- describe '#handle_result' do
8
- context ':OGRERR_NONE' do
9
- subject { :OGRERR_NONE.handle_result }
10
- it { is_expected.to eq true }
11
- end
12
-
13
- context ':OGRERR_NOT_ENOUGH_DATA' do
14
- it 'raises an OGR::NotEnoughData exception' do
15
- expect { :OGRERR_NOT_ENOUGH_DATA.handle_result }.
16
- to raise_exception OGR::NotEnoughData
17
- end
18
- end
19
-
20
- context ':OGRERR_NOT_ENOUGH_MEMORY' do
21
- it 'raises an NoMemoryError exception' do
22
- expect { :OGRERR_NOT_ENOUGH_MEMORY.handle_result }.
23
- to raise_exception NoMemoryError
24
- end
25
- end
26
-
27
- context ':OGRERR_UNSUPPORTED_GEOMETRY_TYPE' do
28
- it 'raises an OGR::UnsupportedGeometryType exception' do
29
- expect { :OGRERR_UNSUPPORTED_GEOMETRY_TYPE.handle_result }.
30
- to raise_exception OGR::UnsupportedGeometryType
31
- end
32
- end
33
-
34
- context ':OGRERR_UNSUPPORTED_OPERATION' do
35
- it 'raises an OGR::UnsupportedOperation exception' do
36
- expect { :OGRERR_UNSUPPORTED_OPERATION.handle_result }.
37
- to raise_exception OGR::UnsupportedOperation
38
- end
39
- end
40
-
41
- context ':OGRERR_CORRUPT_DATA' do
42
- it 'raises an OGR::CorruptData exception' do
43
- expect { :OGRERR_CORRUPT_DATA.handle_result }.
44
- to raise_exception OGR::CorruptData
45
- end
46
- end
47
-
48
- context ':OGRERR_FAILURE' do
49
- it 'raises an OGR::Failure exception' do
50
- expect { :OGRERR_FAILURE.handle_result }.
51
- to raise_exception OGR::Failure
52
- end
53
- end
54
-
55
- context ':OGRERR_UNSUPPORTED_SRS' do
56
- it 'raises an OGR::UnsupportedSRS exception' do
57
- expect { :OGRERR_UNSUPPORTED_SRS.handle_result }.
58
- to raise_exception OGR::UnsupportedSRS
59
- end
60
- end
61
-
62
- context ':OGRERR_INVALID_HANDLE' do
63
- it 'raises an OGR::InvalidHandle exception' do
64
- expect { :OGRERR_INVALID_HANDLE.handle_result }.
65
- to raise_exception OGR::InvalidHandle
66
- end
67
- end
68
- end
69
- end
@@ -1,115 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Numeric do
6
- let(:integer_data_types) do
7
- %i[GDT_Byte GDT_UInt16 GDT_Int16 GDT_UInt32 GDT_Int32]
8
- end
9
-
10
- let(:float_data_types) do
11
- %i[GDT_Float32 GDT_Float64]
12
- end
13
-
14
- let(:complex_data_types) do
15
- %i[GDT_CInt16 GDT_CInt32 GDT_CFloat32 GDT_CFloat64]
16
- end
17
-
18
- shared_examples_for 'a numeric converted to GDAL' do
19
- context 'integer data types' do
20
- it 'returns an Integer' do
21
- integer_data_types.each do |data_type|
22
- expect(subject.to_data_type(data_type)).to eql 1
23
- expect(subject.to_data_type(data_type)).to be_an Integer
24
- end
25
- end
26
- end
27
-
28
- context 'float data types' do
29
- it 'returns a Float' do
30
- float_data_types.each do |data_type|
31
- expect(subject.to_data_type(data_type)).to eql 1.0
32
- expect(subject.to_data_type(data_type)).to be_a Float
33
- end
34
- end
35
- end
36
-
37
- context 'complex data types' do
38
- it 'returns a Complex' do
39
- complex_data_types.each do |data_type|
40
- expect(subject.to_data_type(data_type)).to eql(1 + 0i).or eql(1.0 + 0i)
41
- expect(subject.to_data_type(data_type)).to be_a Complex
42
- end
43
- end
44
- end
45
- end
46
-
47
- context 'Integers' do
48
- subject { 1 }
49
-
50
- it_behaves_like 'a numeric converted to GDAL'
51
-
52
- context 'unknown data type' do
53
- it 'returns self' do
54
- expect(subject.to_data_type('meow')).to eql 1
55
- expect(subject.to_data_type('meow')).to be_a Integer
56
- end
57
- end
58
- end
59
-
60
- context 'Floats' do
61
- context 'subject round down to 1' do
62
- subject { 1.0 }
63
-
64
- it_behaves_like 'a numeric converted to GDAL'
65
-
66
- context 'unknown data type' do
67
- it 'returns self' do
68
- expect(subject.to_data_type('meow')).to eql subject
69
- expect(subject.to_data_type('meow')).to be_a Float
70
- end
71
- end
72
- end
73
-
74
- context 'subject rounds up to 2' do
75
- subject { 1.8 }
76
-
77
- context 'integer data types' do
78
- it 'returns an Integer' do
79
- integer_data_types.each do |data_type|
80
- expect(subject.to_data_type(data_type)).to eql 1
81
- expect(subject.to_data_type(data_type)).to be_an Integer
82
- end
83
- end
84
- end
85
- end
86
- end
87
-
88
- context 'Complexes' do
89
- context 'subject round down to 1' do
90
- subject { 1 + 0i }
91
-
92
- it_behaves_like 'a numeric converted to GDAL'
93
-
94
- context 'unknown data type' do
95
- it 'returns self' do
96
- expect(subject.to_data_type('meow')).to eql subject
97
- expect(subject.to_data_type('meow')).to be_a Complex
98
- end
99
- end
100
- end
101
-
102
- context 'subject rounds up to 2' do
103
- subject { 1.8 + 0i }
104
-
105
- context 'integer data types' do
106
- it 'returns an Integer' do
107
- integer_data_types.each do |data_type|
108
- expect(subject.to_data_type(data_type)).to eql 1
109
- expect(subject.to_data_type(data_type)).to be_an Integer
110
- end
111
- end
112
- end
113
- end
114
- end
115
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'fakefs/safe'
5
-
6
- RSpec.describe FFI::GDAL do
7
- describe '.find_lib' do
8
- context 'ENV["GDAL_LIBRARY_PATH"] is set' do
9
- before do
10
- allow(ENV).to receive(:[]).with('GDAL_LIBRARY_PATH').and_return '/pants'
11
- end
12
-
13
- it 'returns GDAL_LIBRARY_PATH + libgdal file name' do
14
- expect(Dir).to receive(:[]).with(%r{/pants/stuff\.+}).and_return '/pants/stuff.dylib'
15
- expect(described_class.find_lib('stuff')).to match %r{\A/pants/stuff\.+}
16
- end
17
- end
18
-
19
- context 'ENV["GDAL_LIBRARY_PATH"] is not set' do
20
- before do
21
- allow(described_class).to receive(:search_paths).and_return %w[/pants]
22
- FakeFS.activate!
23
- FileUtils.mkdir 'pants'
24
- FileUtils.touch("/pants/stuff.#{FFI::Platform::LIBSUFFIX}")
25
- end
26
-
27
- after { FakeFS.deactivate! }
28
-
29
- it 'returns the search path + libgdal file name' do
30
- expect(described_class.find_lib('stuff')).to match %r{\A/pants/stuff\.+}
31
- end
32
- end
33
- end
34
-
35
- describe '.search_paths' do
36
- context 'ENV["GDAL_LIBRARY_PATH"] is set' do
37
- before do
38
- allow(ENV).to receive(:[]).with('GDAL_LIBRARY_PATH').and_return '/pants'
39
- end
40
-
41
- it 'returns GDAL_LIBRARY_PATH' do
42
- expect(described_class.search_paths).to match %r{\A\/pants\z}
43
- end
44
- end
45
-
46
- context 'ENV["GDAL_LIBRARY_PATH"] is not set' do
47
- it 'returns a bunch of directories' do
48
- expect(described_class.search_paths.size).to be > 0
49
- end
50
- end
51
- end
52
-
53
- describe '._files_with_constants' do
54
- it 'returns a non-empty Array' do
55
- expect(described_class._files_with_constants).to be_an Array
56
- expect(described_class._files_with_constants).to_not be_empty
57
- end
58
- end
59
-
60
- describe '_file_with_constants' do
61
- context 'valid file' do
62
- it 'returns the path to that file' do
63
- expect(described_class._file_with_constants('gdal.h')).to match '.+gdal\.h\z'
64
- end
65
- end
66
-
67
- context 'invalid file' do
68
- it 'returns nil' do
69
- expect(described_class._file_with_constants('derp')).to be_nil
70
- end
71
- end
72
- end
73
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/color_entry'
5
-
6
- RSpec.describe GDAL::ColorEntry do
7
- pending 'Add some tests!'
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/color_interpretation'
5
-
6
- RSpec.describe GDAL::ColorInterpretation do
7
- pending 'Add some tests!'
8
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/color_table'
5
-
6
- RSpec.describe GDAL::ColorTable do
7
- subject do
8
- described_class.new(:GPI_RGB)
9
- end
10
-
11
- describe '#color_entries_for' do
12
- context 'no colors' do
13
- it 'returns an empty array' do
14
- expect(subject.color_entries_for(1)).to be_empty
15
- end
16
- end
17
-
18
- context 'colors' do
19
- it 'returns all of the color values ColorEntrys for the color number' do
20
- subject.add_color_entry(0, 1, 2, 3, 4)
21
- subject.add_color_entry(1, 10, 20, 30, 40)
22
- expect(subject.color_entries_for(1)).to eq([1, 10])
23
- end
24
- end
25
- end
26
-
27
- describe '#color_entries' do
28
- context 'no colors' do
29
- it 'returns an empty array' do
30
- expect(subject.color_entries).to be_empty
31
- end
32
- end
33
-
34
- context 'colors' do
35
- it 'returns an array of the ColorEntrys' do
36
- subject.add_color_entry(0, 1, 2, 3, 4)
37
- subject.add_color_entry(1, 10, 20, 30, 40)
38
-
39
- expect(subject.color_entries.size).to eq 2
40
- expect(subject.color_entries.first).to be_a GDAL::ColorEntry
41
- end
42
- end
43
- end
44
-
45
- describe '#color_entries_as_rgb' do
46
- context 'no colors' do
47
- it 'returns an empty array' do
48
- expect(subject.color_entries_as_rgb).to be_empty
49
- end
50
- end
51
-
52
- context 'colors' do
53
- it 'returns an array of the ColorEntrys' do
54
- subject.add_color_entry(0, 1, 2, 3, 4)
55
- subject.add_color_entry(1, 10, 20, 30, 40)
56
-
57
- expect(subject.color_entries_as_rgb.size).to eq 2
58
- expect(subject.color_entries_as_rgb.first).to be_a GDAL::ColorEntry
59
- end
60
- end
61
- end
62
- end
@@ -1,146 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/color_table'
5
-
6
- RSpec.describe GDAL::ColorTable do
7
- describe '#initialize' do
8
- context 'with a valid PaletteInterpretation' do
9
- it 'creates a new ColorTable' do
10
- expect(described_class.new(:GPI_RGB)).to be_a(described_class)
11
- end
12
- end
13
-
14
- context 'with an invalid PaletteInterpretation' do
15
- it 'raises an GDAL::InvalidColorTable' do
16
- expect do
17
- described_class.new(:MEOW)
18
- end.to raise_exception(GDAL::InvalidColorTable)
19
- end
20
- end
21
-
22
- context ':GPI_RGB' do
23
- it 'extends the new object with the ColorTableTypes::RGB module' do
24
- expect_any_instance_of(described_class).to receive(:extend).
25
- with(GDAL::ColorTableTypes::RGB)
26
- described_class.new(:GPI_RGB)
27
- end
28
- end
29
-
30
- context ':GPI_Gray' do
31
- it 'extends the new object with the ColorTableTypes::Gray module' do
32
- expect_any_instance_of(described_class).to receive(:extend).
33
- with(GDAL::ColorTableTypes::Gray)
34
- described_class.new(:GPI_Gray)
35
- end
36
- end
37
-
38
- context ':GPI_CMYK' do
39
- it 'extends the new object with the ColorTableTypes::CMYK module' do
40
- expect_any_instance_of(described_class).to receive(:extend).
41
- with(GDAL::ColorTableTypes::CMYK)
42
- described_class.new(:GPI_CMYK)
43
- end
44
- end
45
-
46
- context ':GPI_HLS' do
47
- it 'extends the new object with the ColorTableTypes::HLS module' do
48
- expect_any_instance_of(described_class).to receive(:extend).
49
- with(GDAL::ColorTableTypes::HLS)
50
- described_class.new(:GPI_HLS)
51
- end
52
- end
53
- end
54
-
55
- subject do
56
- described_class.new(:GPI_RGB)
57
- end
58
-
59
- describe '#palette_interpretation' do
60
- it 'equals the symbol that was given during .create' do
61
- expect(subject.palette_interpretation).to eq :GPI_RGB
62
- end
63
- end
64
-
65
- describe '#color_entry_count' do
66
- it 'defaults to 0' do
67
- expect(subject.color_entry_count).to be_zero
68
- end
69
- end
70
-
71
- describe '#color_entry' do
72
- context 'when no entries' do
73
- it 'returns nil' do
74
- expect(subject.color_entry(900)).to be_nil
75
- end
76
- end
77
-
78
- context 'when entries' do
79
- before do
80
- subject.add_color_entry(0)
81
- end
82
-
83
- it 'returns the ColorEntry' do
84
- expect(subject.color_entry(0)).to be_a GDAL::ColorEntry
85
- end
86
- end
87
- end
88
-
89
- describe '#color_entry_as_rgb' do
90
- context 'when no entries' do
91
- it 'returns nil' do
92
- expect(subject.color_entry_as_rgb(900)).to be_nil
93
- end
94
- end
95
-
96
- context 'when entries' do
97
- before do
98
- subject.add_color_entry(0)
99
- end
100
-
101
- it 'returns the ColorEntry' do
102
- expect(subject.color_entry_as_rgb(0)).to be_a GDAL::ColorEntry
103
- end
104
- end
105
- end
106
-
107
- describe '#add_color_entry' do
108
- context 'no values given' do
109
- it 'creates and returns the entry' do
110
- expect(subject.add_color_entry(0)).to be_a GDAL::ColorEntry
111
- end
112
- end
113
-
114
- context 'all values given' do
115
- it 'creates and returns the entry' do
116
- expect(subject.add_color_entry(0, 75, 250, 255)).to be_a GDAL::ColorEntry
117
- end
118
- end
119
-
120
- context 'bad values given' do
121
- it 'creates and returns the entry' do
122
- expect(subject.add_color_entry(0, 300, 250, 255)).to be_a GDAL::ColorEntry
123
- end
124
- end
125
- end
126
-
127
- describe '#create_color_ramp!' do
128
- context 'no color entries' do
129
- it 'returns nil' do
130
- entry0 = GDAL::ColorEntry.new
131
- entry1 = GDAL::ColorEntry.new
132
- expect(subject.create_color_ramp!(0, entry0, 1, entry1)).to be_nil
133
- end
134
- end
135
-
136
- context 'color entries that exist' do
137
- it 'returns nil' do
138
- entry0 = subject.add_color_entry(0, 0, 0, 0, 0)
139
- _entry1 = subject.add_color_entry(1, 10, 10, 10, 10)
140
- entry2 = subject.add_color_entry(2, 100, 100, 100, 100)
141
-
142
- expect(subject.create_color_ramp!(0, entry0, 2, entry2)).to be_nil
143
- end
144
- end
145
- end
146
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/data_type'
5
-
6
- RSpec.describe GDAL::DataType do
7
- describe '.size' do
8
- context 'with valid data type' do
9
- it 'returns the size' do
10
- expect(described_class.size(:GDT_Byte)).to eq 8
11
- end
12
- end
13
-
14
- context 'with invalid data type' do
15
- it 'raises an ArgumentError' do
16
- expect do
17
- described_class.size(:Bob)
18
- end.to raise_exception(ArgumentError)
19
- end
20
- end
21
- end
22
-
23
- describe '.complex?' do
24
- context 'with valid, complex data type' do
25
- it 'returns true' do
26
- expect(described_class.complex?(:GDT_CFloat64)).to eq true
27
- end
28
- end
29
-
30
- context 'with valid, simple data type' do
31
- it 'returns true' do
32
- expect(described_class.complex?(:GDT_Float64)).to eq false
33
- end
34
- end
35
-
36
- context 'with invalid data type' do
37
- it 'raises an ArgumentError' do
38
- expect do
39
- described_class.complex?(:Bob)
40
- end.to raise_exception(ArgumentError)
41
- end
42
- end
43
- end
44
-
45
- describe '.name' do
46
- context 'with valid data type' do
47
- it 'returns the name' do
48
- expect(described_class.name(:GDT_Byte)).to eq 'Byte'
49
- end
50
- end
51
-
52
- context 'with invalid data type' do
53
- it 'raises an ArgumentError' do
54
- expect do
55
- described_class.name(:Bob)
56
- end.to raise_exception(ArgumentError)
57
- end
58
- end
59
- end
60
-
61
- describe '.by_name' do
62
- context 'with valid data type name' do
63
- it 'returns the data type' do
64
- expect(described_class.by_name('Byte')).to eq :GDT_Byte
65
- end
66
- end
67
-
68
- context 'with invalid data type name' do
69
- it 'returns :GDT_Unknown' do
70
- expect(described_class.by_name('Bob')).to eq :GDT_Unknown
71
- end
72
- end
73
- end
74
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal'
5
-
6
- RSpec.describe GDAL::Dataset do
7
- let(:source_file_path) do
8
- File.expand_path('../../../support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif', __dir__)
9
- end
10
-
11
- let(:output_dir) { Dir.mktmpdir(File.basename(__FILE__, '.rb')) }
12
- let(:output_file) { File.join(output_dir, 'reprojected_image.tif') }
13
-
14
- after { FileUtils.rm_rf(output_dir) if Dir.exist?(output_dir) }
15
-
16
- subject { described_class.open(source_file_path, 'r', false) }
17
-
18
- describe '#reproject_image' do
19
- let(:dest_dataset) do
20
- dest_width = subject.raster_x_size / 4
21
- dest_height = subject.raster_y_size / 4
22
- dataset = GDAL::Driver.by_name('GTiff').create_dataset(output_file, dest_width, dest_height,
23
- data_type: subject.raster_band(1).data_type)
24
- dataset.geo_transform = subject.geo_transform.dup
25
- dataset.projection = OGR::SpatialReference.new_from_epsg(3857).to_wkt
26
- dataset
27
- end
28
-
29
- after { dest_dataset.close }
30
-
31
- it 'creates a valid dataset' do
32
- subject.reproject_image(dest_dataset, :GRA_CubicSpline)
33
-
34
- dest_dataset.flush_cache
35
- expect(dest_dataset.projection).to match(/AUTHORITY\[\"EPSG\",\"3857\"\]/)
36
- expect(dest_dataset.raster_count).to eq(subject.raster_count)
37
- end
38
- end
39
-
40
- describe '#create_and_reproject_image' do
41
- let(:output_projection) { OGR::SpatialReference.new_from_epsg(3857).to_wkt }
42
-
43
- it 'creates a valid dataset' do
44
- subject.create_and_reproject_image(output_file, :GRA_NearestNeighbor,
45
- OGR::SpatialReference.new_from_epsg(3857).to_wkt, GDAL::Driver.by_name('GTiff'))
46
-
47
- dest_dataset = GDAL::Dataset.open(output_file, 'r')
48
- expect(dest_dataset.projection).to match(/AUTHORITY\[\"EPSG\",\"3857\"\]/)
49
- expect(dest_dataset.raster_count).to eq(subject.raster_count)
50
-
51
- dest_driver = dest_dataset.driver
52
- expect(dest_driver.long_name).to eq 'GeoTIFF'
53
- end
54
- end
55
- end