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,223 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/data_source'
5
- require 'ogr/spatial_reference'
6
-
7
- RSpec.describe OGR::DataSource do
8
- describe '.open' do
9
- context 'not a data source' do
10
- it 'raises an OGR::OpenFailure' do
11
- expect do
12
- described_class.open('blarg', 'r')
13
- end.to raise_exception OGR::OpenFailure
14
- end
15
- end
16
-
17
- context 'block given' do
18
- let(:data_source) { instance_double 'OGR::DataSource' }
19
-
20
- it 'yields then closes the opened DataSource' do
21
- allow(described_class).to receive(:new).and_return data_source
22
-
23
- expect(data_source).to receive(:close)
24
- expect { |b| described_class.open('blarg', 'r', &b) }.
25
- to yield_with_args(data_source)
26
- end
27
- end
28
- end
29
-
30
- let(:driver) { OGR::Driver.by_name 'Memory' }
31
-
32
- subject(:data_source) do
33
- driver.create_data_source('spec')
34
- end
35
-
36
- describe '#name' do
37
- subject { data_source.name }
38
- it { is_expected.to eq 'spec' }
39
- end
40
-
41
- describe '#driver' do
42
- subject { data_source.driver.name }
43
- it { is_expected.to eq 'Memory' }
44
- end
45
-
46
- describe '#layer_count' do
47
- subject { data_source.layer_count }
48
- it { is_expected.to be_zero }
49
- end
50
-
51
- describe '#layer' do
52
- context 'no layers' do
53
- subject { data_source.layer(0) }
54
- it { is_expected.to be_nil }
55
- end
56
-
57
- context '1 layer' do
58
- before { data_source.create_layer 'unknown layer' }
59
- subject { data_source.layer(0) }
60
- it { is_expected.to be_a OGR::Layer }
61
- end
62
- end
63
-
64
- describe '#layer_by_name' do
65
- context 'no layers' do
66
- subject { data_source.layer_by_name 'meow' }
67
- it { is_expected.to be_nil }
68
- end
69
-
70
- context '1 layer' do
71
- before { data_source.create_layer 'unknown layer' }
72
- subject { data_source.layer_by_name 'unknown layer' }
73
- it { is_expected.to be_a OGR::Layer }
74
- end
75
- end
76
-
77
- describe '#create_layer' do
78
- context 'cannot create layer' do
79
- before do
80
- expect(subject).to receive(:can_create_layer?).and_return false
81
- end
82
-
83
- it 'raises an OGR::UnsupportedOperation' do
84
- expect { subject.create_layer('test') }.to raise_exception OGR::UnsupportedOperation
85
- end
86
- end
87
-
88
- context 'can create layer' do
89
- context 'geometry type is :wkbUnknown' do
90
- it 'adds a new OGR::Layer to @layers' do
91
- expect do
92
- data_source.create_layer('unknown layer')
93
- end.to change { data_source.layers.size }.by 1
94
- end
95
-
96
- it 'has a layer that is the given geometry type' do
97
- layer = data_source.create_layer('unknown layer', geometry_type: :wkbUnknown)
98
- expect(layer.geometry_type).to eq :wkbUnknown
99
- end
100
- end
101
-
102
- context 'geometry type is *not* :wkbUnknown' do
103
- it 'adds a new OGR::Layer to @layers' do
104
- expect do
105
- data_source.create_layer('polygon layer', geometry_type: :wkbPolygon)
106
- end.to change { data_source.layers.size }.by 1
107
- end
108
-
109
- it 'has a layer that is the given geometry type' do
110
- layer = data_source.create_layer('polygon layer', geometry_type: :wkbPolygon)
111
- expect(layer.geometry_type).to eq :wkbPolygon
112
- end
113
- end
114
-
115
- context 'spatial reference is passed in' do
116
- let(:spatial_reference) { OGR::SpatialReference.new_from_epsg(4326) }
117
-
118
- it 'adds a new OGR::Layer to @layers' do
119
- expect do
120
- data_source.create_layer('polygon layer', spatial_reference: spatial_reference)
121
- end.to change { data_source.layers.size }.by 1
122
- end
123
-
124
- it 'has a layer that uses that spatial reference' do
125
- layer = data_source.create_layer('polygon layer', spatial_reference: spatial_reference)
126
- expect(layer.spatial_reference.to_wkt).to eq spatial_reference.to_wkt
127
- end
128
- end
129
- end
130
- end
131
-
132
- describe '#copy_layer' do
133
- let!(:unknown_layer) { subject.create_layer 'unknown layer' }
134
-
135
- it 'adds a new OGR::Layer to @layers' do
136
- expect do
137
- subject.copy_layer(unknown_layer, 'meow layer')
138
- end.to change { subject.layers.size }.by 1
139
- end
140
-
141
- it 'makes a copy of the layer' do
142
- copied_layer = subject.copy_layer(unknown_layer, 'meow layer')
143
- expect(copied_layer.geometry_type).to eq unknown_layer.geometry_type
144
- end
145
- end
146
-
147
- describe '#delete_layer' do
148
- context 'deleting not supported' do
149
- before do
150
- expect(subject).to receive(:can_delete_layer?).and_return false
151
- end
152
-
153
- it 'raises an OGR::UnsupportedOperation' do
154
- expect { subject.delete_layer(0) }.to raise_exception OGR::UnsupportedOperation
155
- end
156
- end
157
-
158
- context 'deleting is supported' do
159
- context 'no layers' do
160
- it 'raises a OGR::Failure' do
161
- expect do
162
- data_source.delete_layer(0)
163
- end.to raise_exception OGR::Failure
164
- end
165
- end
166
-
167
- context '1 layer' do
168
- before { data_source.create_layer 'unknown layer' }
169
- subject { data_source.delete_layer(0) }
170
- it { is_expected.to eq true }
171
- end
172
- end
173
- end
174
-
175
- describe '#style_table' do
176
- context 'no associated style table' do
177
- subject { data_source.style_table }
178
- it { is_expected.to be_nil }
179
- end
180
- end
181
-
182
- describe '#style_table=' do
183
- context 'no style table associated' do
184
- let(:style_table) do
185
- st = OGR::StyleTable.new
186
- st.add_style('test', '#123456')
187
- st
188
- end
189
-
190
- it 'assigns the new style table' do
191
- subject.style_table = style_table
192
- expect(subject.style_table.find('test')).to eq '#123456'
193
- end
194
- end
195
- end
196
-
197
- describe '#test_capability' do
198
- context 'supported capabilities to check' do
199
- let(:capabilities) do
200
- %w[ODsCCreateLayer ODsCDeleteLayer ODsCCreateGeomFieldAfterCreateLayer ODsCCurveGeometries]
201
- end
202
-
203
- # I don't get why these return false...
204
- it 'returns false' do
205
- capabilities.each do |capability|
206
- expect(subject.test_capability(capability)).to eq false
207
- end
208
- end
209
- end
210
-
211
- context 'unsupported capabilities to check' do
212
- it 'returns false' do
213
- expect(subject.test_capability('meow')).to eq false
214
- end
215
- end
216
- end
217
-
218
- describe '#sync_to_disk' do
219
- it 'returns true' do
220
- expect(subject.sync_to_disk).to eq true
221
- end
222
- end
223
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/driver'
5
-
6
- RSpec.describe OGR::Driver do
7
- context 'Memory driver' do
8
- subject(:driver) { OGR::Driver.by_name('Memory') }
9
-
10
- describe '#can_create_data_source?' do
11
- subject { driver.can_create_data_source? }
12
- it { is_expected.to eq true }
13
- end
14
-
15
- describe '#can_delete_data_source?' do
16
- subject { driver.can_delete_data_source? }
17
- it { is_expected.to eq false }
18
- end
19
- end
20
- end
@@ -1,152 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/driver'
5
-
6
- RSpec.describe OGR::Driver do
7
- describe '.count' do
8
- subject { described_class.count }
9
- it { is_expected.to be_a Integer }
10
- end
11
-
12
- describe '.by_name' do
13
- it 'can return an OGR::Driver' do
14
- expect(described_class.by_name('Memory')).to be_a OGR::Driver
15
- end
16
- end
17
-
18
- describe '.at_index' do
19
- context 'valid index' do
20
- it 'returns an OGR::Driver' do
21
- expect(described_class.at_index(0)).to be_a OGR::Driver
22
- end
23
- end
24
-
25
- context 'invalid index' do
26
- it 'raises an OGR::DriverNotFound' do
27
- expect { described_class.at_index(123_456) }.
28
- to raise_exception OGR::DriverNotFound
29
- end
30
- end
31
- end
32
-
33
- describe '.names' do
34
- it 'returns an Array of Strings' do
35
- expect(described_class.names).to be_an Array
36
- expect(described_class.names.first).to be_a String
37
- end
38
- end
39
-
40
- subject(:memory_driver) { described_class.by_name('Memory') }
41
- let(:shapefile_driver) { described_class.by_name('ESRI Shapefile') }
42
-
43
- describe '#name' do
44
- subject { memory_driver.name }
45
- it { is_expected.to eq 'Memory' }
46
- end
47
-
48
- describe '#open' do
49
- context 'data source at path does not exist' do
50
- context 'with write flag' do
51
- it 'raises an OGR::InvalidDataSource' do
52
- expect { subject.open('spec source', 'w') }.
53
- to raise_exception OGR::InvalidDataSource
54
- end
55
- end
56
-
57
- context 'with read flag' do
58
- it 'raises an OGR::InvalidDataSource' do
59
- expect { subject.open('spec source', 'r') }.
60
- to raise_exception OGR::InvalidDataSource
61
- end
62
- end
63
- end
64
-
65
- context 'data source at path exists' do
66
- let(:shapefile_path) do
67
- 'spec/support/shapefiles/states_21basic/states.shp'
68
- end
69
-
70
- context 'with write flag' do
71
- it 'returns an OGR::DataSource' do
72
- data_source = shapefile_driver.open(shapefile_path, 'w')
73
- expect(data_source).to be_a OGR::DataSource
74
- end
75
- end
76
-
77
- context 'with read flag' do
78
- it 'returns an OGR::DataSource' do
79
- data_source = shapefile_driver.open(shapefile_path, 'r')
80
- expect(data_source).to be_a OGR::DataSource
81
- end
82
- end
83
-
84
- context 'using a driver that does not support the file type' do
85
- it 'raises an OGR::InvalidDataSource' do
86
- expect { memory_driver.open(shapefile_path, 'r') }.
87
- to raise_exception OGR::InvalidDataSource
88
- end
89
- end
90
- end
91
- end
92
-
93
- describe '#create_data_source' do
94
- context 'creation not supported' do
95
- before do
96
- expect(subject).to receive(:can_create_data_source?).and_return false
97
- end
98
-
99
- it 'raises an OGR::UnsupportedOperation' do
100
- expect { subject.create_data_source('test') }.to raise_exception OGR::UnsupportedOperation
101
- end
102
- end
103
-
104
- context 'creation supported' do
105
- context 'block given' do
106
- it 'yields the new DataSource to the block' do
107
- expect do |b|
108
- subject.create_data_source('test source', &b)
109
- end.to yield_with_args OGR::DataSource
110
- end
111
- end
112
-
113
- context 'no block given' do
114
- it 'returns the new data source' do
115
- expect(subject.create_data_source('test source')).
116
- to be_a OGR::DataSource
117
- end
118
- end
119
- end
120
- end
121
-
122
- describe '#delete_data_source' do
123
- context 'does not support deleting' do
124
- context 'data source does not exist' do
125
- it "raises a OGR::UnsupportedOperation (Memory driver doesn't support)" do
126
- expect { subject.delete_data_source('we no here') }.to raise_exception OGR::UnsupportedOperation
127
- end
128
- end
129
- end
130
- end
131
-
132
- describe '#copy_data_source' do
133
- context 'source data source does not exist' do
134
- it 'raises an OGR::InvalidDataSource' do
135
- expect do
136
- subject.copy_data_source('not a pointer', 'bobo')
137
- end.to raise_exception OGR::InvalidDataSource
138
- end
139
- end
140
-
141
- context 'source data source exists' do
142
- let(:data_source) do
143
- subject.create_data_source('datasource1')
144
- end
145
-
146
- it 'returns the new OGR::DataSource' do
147
- expect(subject.copy_data_source(data_source, 'datasource2')).
148
- to be_a OGR::DataSource
149
- end
150
- end
151
- end
152
- end
@@ -1,324 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/envelope'
5
- require 'gdal/geo_transform'
6
-
7
- RSpec.describe OGR::Envelope do
8
- describe '#x_min' do
9
- context 'default value' do
10
- subject { described_class.new.x_min }
11
- it { is_expected.to eq(0.0) }
12
- end
13
- end
14
-
15
- describe '#x_min= + #x_min' do
16
- it 'sets the x_min value' do
17
- subject.x_min = 123
18
- expect(subject.x_min).to eq 123.0
19
- end
20
- end
21
-
22
- describe '#x_max' do
23
- context 'default value' do
24
- subject { described_class.new.x_max }
25
- it { is_expected.to eq(0.0) }
26
- end
27
- end
28
-
29
- describe '#x_max= + #x_max' do
30
- it 'sets the x_max value' do
31
- subject.x_max = 123
32
- expect(subject.x_max).to eq 123.0
33
- end
34
- end
35
-
36
- describe '#y_min' do
37
- context 'default value' do
38
- subject { described_class.new.y_min }
39
- it { is_expected.to eq(0.0) }
40
- end
41
- end
42
-
43
- describe '#y_min= + #y_min' do
44
- it 'sets the y_min value' do
45
- subject.y_min = 123
46
- expect(subject.y_min).to eq 123.0
47
- end
48
- end
49
-
50
- describe '#y_max' do
51
- context 'default value' do
52
- subject { described_class.new.y_max }
53
- it { is_expected.to eq(0.0) }
54
- end
55
- end
56
-
57
- describe '#y_max= + #y_max' do
58
- it 'sets the y_max value' do
59
- subject.y_max = 123
60
- expect(subject.y_max).to eq 123.0
61
- end
62
- end
63
-
64
- context '2d' do
65
- describe '#z_min' do
66
- context 'default value' do
67
- subject { described_class.new.z_min }
68
- it { is_expected.to be_nil }
69
- end
70
- end
71
-
72
- describe '#z_min= + #z_min' do
73
- it 'sets the z_min value' do
74
- subject.z_min = 123
75
- expect(subject.z_min).to be_nil
76
- end
77
- end
78
-
79
- describe '#z_max' do
80
- context 'default value' do
81
- subject { described_class.new.z_max }
82
- it { is_expected.to be_nil }
83
- end
84
- end
85
-
86
- describe '#z_max= + #z_max' do
87
- it 'sets the z_max value' do
88
- subject.z_max = 123
89
- expect(subject.z_max).to be_nil
90
- end
91
- end
92
- end
93
-
94
- context '3d' do
95
- subject { described_class.new(three_d: true) }
96
-
97
- describe '#z_min' do
98
- context 'default value' do
99
- subject { described_class.new.z_min }
100
- it { is_expected.to be_nil }
101
- end
102
- end
103
-
104
- describe '#z_min= + #z_min' do
105
- it 'sets the z_min value' do
106
- subject.z_min = 123
107
- expect(subject.z_min).to eq 123.0
108
- end
109
- end
110
-
111
- describe '#z_max' do
112
- context 'default value' do
113
- subject { described_class.new.z_max }
114
- it { is_expected.to be_nil }
115
- end
116
- end
117
-
118
- describe '#z_max= + #z_max' do
119
- it 'sets the z_max value' do
120
- subject.z_max = 123
121
- expect(subject.z_max).to eq 123.0
122
- end
123
- end
124
- end
125
-
126
- describe '#world_to_pixels' do
127
- let(:geo_transform) do
128
- GDAL::GeoTransform.from_world_file('spec/support/worldfiles/SR_50M/SR_50M', '.tfw')
129
- end
130
-
131
- before do
132
- subject.x_min = 10
133
- subject.x_max = 20
134
- subject.y_min = -10
135
- subject.y_max = 0
136
- end
137
-
138
- context 'as integers' do
139
- it 'returns a Hash of translated values' do
140
- result = subject.world_to_pixels(geo_transform)
141
- expect(result).to eq(
142
- x_min: 5700,
143
- y_min: -2700,
144
- x_max: 6000,
145
- y_max: -3000
146
- )
147
- end
148
- end
149
- end
150
-
151
- describe '#==' do
152
- subject do
153
- envelope = described_class.new
154
- envelope.x_min = 10
155
- envelope.y_min = -100
156
- envelope.x_max = 50
157
- envelope.y_max = -50
158
-
159
- envelope
160
- end
161
-
162
- context 'envelopes are equal' do
163
- let(:other_envelope) do
164
- envelope = described_class.new
165
- envelope.x_min = 10
166
- envelope.y_min = -100
167
- envelope.x_max = 50
168
- envelope.y_max = -50
169
-
170
- envelope
171
- end
172
-
173
- it 'returns true' do
174
- expect(subject == other_envelope).to eq true
175
- end
176
- end
177
-
178
- context 'envelopes not equal' do
179
- let(:other_envelope) do
180
- envelope = described_class.new
181
- envelope.x_min = 0
182
- envelope.y_min = -100
183
- envelope.x_max = 50
184
- envelope.y_max = -50
185
-
186
- envelope
187
- end
188
-
189
- it 'returns false' do
190
- expect(subject == other_envelope).to eq false
191
- end
192
- end
193
- end
194
-
195
- describe '#merge' do
196
- subject do
197
- envelope = described_class.new
198
- envelope.x_min = 10
199
- envelope.y_min = -100
200
- envelope.x_max = 50
201
- envelope.y_max = -50
202
-
203
- envelope
204
- end
205
-
206
- let(:other_envelope) do
207
- envelope = described_class.new
208
- envelope.x_min = 0
209
- envelope.y_min = 0
210
- envelope.x_max = 500
211
- envelope.y_max = 250
212
-
213
- envelope
214
- end
215
-
216
- it 'returns a new OGR::Envelope' do
217
- expect(subject.merge(other_envelope)).to be_a OGR::Envelope
218
- end
219
-
220
- it 'has an x_min that equals the most minimum value between the two envelopes' do
221
- expect(subject.merge(other_envelope).x_min).to eq 0
222
- end
223
-
224
- it 'has an y_min that equals the most minimum value between the two envelopes' do
225
- expect(subject.merge(other_envelope).y_min).to eq(-100)
226
- end
227
-
228
- it 'has an x_max that equals the most maximum value between the two envelopes' do
229
- expect(subject.merge(other_envelope).x_max).to eq 500
230
- end
231
-
232
- it 'has an y_max that equals the most maximum value between the two envelopes' do
233
- expect(subject.merge(other_envelope).y_max).to eq 250
234
- end
235
- end
236
-
237
- describe '#intersects?' do
238
- subject do
239
- envelope = described_class.new
240
- envelope.x_min = 0
241
- envelope.x_max = 1
242
- envelope.y_min = 0
243
- envelope.y_max = 1
244
-
245
- envelope
246
- end
247
-
248
- context 'envelopes intersect' do
249
- let(:other_envelope) do
250
- envelope = described_class.new
251
- envelope.x_min = 0
252
- envelope.x_max = 1
253
- envelope.y_min = 0
254
- envelope.y_max = 1
255
-
256
- envelope
257
- end
258
-
259
- it 'returns true' do
260
- expect(subject.intersects?(other_envelope)).to eq true
261
- end
262
- end
263
-
264
- context 'envelopes do not intersect' do
265
- let(:other_envelope) do
266
- envelope = described_class.new
267
- envelope.x_min = 500
268
- envelope.y_min = 500
269
- envelope.x_max = 1000
270
- envelope.y_max = 1000
271
-
272
- envelope
273
- end
274
-
275
- it 'returns false' do
276
- expect(subject.intersects?(other_envelope)).to eq false
277
- end
278
- end
279
- end
280
-
281
- describe '#contains?' do
282
- subject do
283
- envelope = described_class.new
284
- envelope.x_min = 0
285
- envelope.x_max = 10
286
- envelope.y_min = 0
287
- envelope.y_max = 10
288
-
289
- envelope
290
- end
291
-
292
- context 'subject contains other envelope' do
293
- let(:other_envelope) do
294
- envelope = described_class.new
295
- envelope.x_min = 1
296
- envelope.x_max = 9
297
- envelope.y_min = 1
298
- envelope.y_max = 9
299
-
300
- envelope
301
- end
302
-
303
- it 'returns true' do
304
- expect(subject.contains?(other_envelope)).to eq true
305
- end
306
- end
307
-
308
- context 'subject does not contain other envelope' do
309
- let(:other_envelope) do
310
- envelope = described_class.new
311
- envelope.x_min = 500
312
- envelope.y_min = 500
313
- envelope.x_max = 1000
314
- envelope.y_max = 1000
315
-
316
- envelope
317
- end
318
-
319
- it 'returns false' do
320
- expect(subject.contains?(other_envelope)).to eq false
321
- end
322
- end
323
- end
324
- end