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,331 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/gridder'
5
- require 'ogr/data_source'
6
-
7
- RSpec.describe 'GDAL::Gridder', type: :integration do
8
- let(:shapefile_path) { File.expand_path('../../../spec/support/shapefiles/states_21basic', __dir__) }
9
- let(:source_data_source) { OGR::DataSource.open(shapefile_path, 'r') }
10
- let(:source_layer) { source_data_source.layer(0) }
11
- let(:dataset) { GDAL::Dataset.open(output_file_name, 'w', true) }
12
-
13
- after do
14
- source_data_source.close if source_data_source.c_pointer
15
- dataset.close if File.exist?(output_file_name)
16
-
17
- Dir.glob("#{output_file_name}*").each do |file|
18
- File.unlink(file) if File.exist?(file)
19
- end
20
- end
21
-
22
- describe 'Inverse Distance to a Power' do
23
- let(:gridder_options) do
24
- gridder_options = GDAL::GridderOptions.new(:inverse_distance_to_a_power)
25
-
26
- gridder_options.algorithm_options[:angle] = 10
27
- gridder_options.algorithm_options[:max_points] = 5
28
- gridder_options.algorithm_options[:min_points] = 1
29
- gridder_options.algorithm_options[:no_data_value] = -9999
30
- gridder_options.algorithm_options[:power] = 2
31
- gridder_options.algorithm_options[:radius1] = 20
32
- gridder_options.algorithm_options[:radius2] = 15
33
- gridder_options.algorithm_options[:smoothing] = 5
34
-
35
- gridder_options.input_field_name = 'STATE_FIPS'
36
- gridder_options.output_size = { width: 300, height: 200 }
37
- gridder_options.output_data_type = :GDT_UInt16
38
-
39
- gridder_options
40
- end
41
-
42
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-idtap.tif', __dir__) }
43
-
44
- it 'results in a raster with relevant data to the grid algorithm' do
45
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
46
- gridder.grid!
47
-
48
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
49
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
50
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
51
- expect(dataset.raster_band(1).x_size).to eq 300
52
- expect(dataset.raster_band(1).y_size).to eq 200
53
- expect(dataset.raster_band(1).data_type).to eq :GDT_UInt16
54
-
55
- stats = dataset.raster_band(1).statistics
56
- expect(stats[:minimum]).to eq 0.0
57
- expect(stats[:maximum]).to eq 55.0
58
- expect(stats[:mean]).to be_within(0.000000000001).of 25.549166666667
59
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 19.127859747926
60
- end
61
- end
62
-
63
- describe 'Nearest Neighbor' do
64
- let(:gridder_options) do
65
- gridder_options = GDAL::GridderOptions.new(:nearest_neighbor)
66
-
67
- gridder_options.algorithm_options[:angle] = 3
68
- gridder_options.algorithm_options[:no_data_value] = -9999
69
- gridder_options.algorithm_options[:radius1] = 2
70
- gridder_options.algorithm_options[:radius2] = 1
71
-
72
- gridder_options.input_field_name = 'STATE_FIPS'
73
- gridder_options.output_size = { width: 10, height: 15 }
74
- gridder_options.output_data_type = :GDT_Int16
75
-
76
- gridder_options
77
- end
78
-
79
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-nearest_neighbor.tif', __dir__) }
80
-
81
- it 'results in a raster with relevant data to the grid algorithm' do
82
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
83
- gridder.grid!
84
-
85
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
86
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
87
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
88
- expect(dataset.raster_band(1).x_size).to eq 10
89
- expect(dataset.raster_band(1).y_size).to eq 15
90
- expect(dataset.raster_band(1).data_type).to eq :GDT_Int16
91
-
92
- stats = dataset.raster_band(1).statistics
93
- expect(stats[:minimum]).to eq 2.0
94
- expect(stats[:maximum]).to eq 56.0
95
- expect(stats[:mean]).to be_within(0.00000000001).of 16.972222222222
96
- expect(stats[:standard_deviation]).to be_within(0.00000000001).of 16.308631169331
97
- end
98
- end
99
-
100
- describe 'Metric Average Distance' do
101
- let(:gridder_options) do
102
- gridder_options = GDAL::GridderOptions.new(:metric_average_distance)
103
-
104
- gridder_options.algorithm_options[:angle] = 30
105
- gridder_options.algorithm_options[:no_data_value] = -9999
106
- gridder_options.algorithm_options[:radius1] = 20
107
- gridder_options.algorithm_options[:radius2] = 15
108
- gridder_options.algorithm_options[:min_points] = 1000
109
-
110
- gridder_options.input_field_name = 'STATE_FIPS'
111
- gridder_options.output_size = { width: 100, height: 150 }
112
- gridder_options.output_data_type = :GDT_UInt32
113
-
114
- gridder_options
115
- end
116
-
117
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_average_distance.tif', __dir__) }
118
-
119
- it 'results in a raster with relevant data to the grid algorithm' do
120
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
121
- gridder.grid!
122
-
123
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
124
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
125
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
126
- expect(dataset.raster_band(1).x_size).to eq 100
127
- expect(dataset.raster_band(1).y_size).to eq 150
128
- expect(dataset.raster_band(1).data_type).to eq :GDT_UInt32
129
-
130
- stats = dataset.raster_band(1).statistics
131
- expect(stats[:minimum]).to eq 0.0
132
- expect(stats[:maximum]).to eq 17.0
133
- expect(stats[:mean]).to be_within(0.000000000001).of 6.211
134
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 5.9461944973235
135
- end
136
- end
137
-
138
- describe 'Metric Average Distance Between Points' do
139
- let(:gridder_options) do
140
- gridder_options = GDAL::GridderOptions.new(:metric_average_distance_pts)
141
-
142
- gridder_options.algorithm_options[:angle] = 0.1
143
- gridder_options.algorithm_options[:no_data_value] = -9999
144
- gridder_options.algorithm_options[:radius1] = 0.2
145
- gridder_options.algorithm_options[:radius2] = 0.3
146
- gridder_options.algorithm_options[:min_points] = 1
147
-
148
- gridder_options.input_field_name = 'STATE_FIPS'
149
- gridder_options.output_size = { width: 50, height: 250 }
150
- gridder_options.output_data_type = :GDT_Float32
151
-
152
- gridder_options
153
- end
154
-
155
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_average_distance_pts.tif', __dir__) }
156
-
157
- it 'results in a raster with relevant data to the grid algorithm' do
158
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
159
- gridder.grid!
160
-
161
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
162
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
163
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
164
- expect(dataset.raster_band(1).x_size).to eq 50
165
- expect(dataset.raster_band(1).y_size).to eq 250
166
- expect(dataset.raster_band(1).data_type).to eq :GDT_Float32
167
-
168
- stats = dataset.raster_band(1).statistics
169
- expect(stats[:minimum]).to eq 0.0
170
- expect(stats[:maximum]).to be_within(0.000000000001).of 0.43194779753685
171
- expect(stats[:mean]).to be_within(0.000000000001).of 0.11661225064791
172
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 0.081518691345895
173
- end
174
- end
175
-
176
- describe 'Metric Count' do
177
- let(:gridder_options) do
178
- gridder_options = GDAL::GridderOptions.new(:metric_count)
179
-
180
- gridder_options.algorithm_options[:angle] = 0.5
181
- gridder_options.algorithm_options[:no_data_value] = -9999
182
- gridder_options.algorithm_options[:radius1] = 0.1
183
- gridder_options.algorithm_options[:radius2] = 0.2
184
- gridder_options.algorithm_options[:min_points] = 1
185
-
186
- gridder_options.input_field_name = 'STATE_FIPS'
187
- gridder_options.output_size = { width: 50, height: 50 }
188
- gridder_options.output_data_type = :GDT_Int32
189
-
190
- gridder_options
191
- end
192
-
193
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_count.tif', __dir__) }
194
-
195
- it 'results in a raster with relevant data to the grid algorithm' do
196
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
197
- gridder.grid!
198
-
199
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
200
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
201
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
202
- expect(dataset.raster_band(1).x_size).to eq 50
203
- expect(dataset.raster_band(1).y_size).to eq 50
204
- expect(dataset.raster_band(1).data_type).to eq :GDT_Int32
205
-
206
- stats = dataset.raster_band(1).statistics
207
- expect(stats[:minimum]).to eq 1.0
208
- expect(stats[:maximum]).to eq 18.0
209
- expect(stats[:mean]).to be_within(0.000000000001).of 3.9318181818182
210
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 3.7135974182892
211
- end
212
- end
213
-
214
- describe 'Metric Maximum' do
215
- let(:gridder_options) do
216
- gridder_options = GDAL::GridderOptions.new(:metric_maximum)
217
-
218
- gridder_options.algorithm_options[:angle] = 30
219
- gridder_options.algorithm_options[:no_data_value] = -9999
220
- gridder_options.algorithm_options[:radius1] = 90
221
- gridder_options.algorithm_options[:radius2] = 0.1
222
- gridder_options.algorithm_options[:min_points] = 1
223
-
224
- gridder_options.input_field_name = 'STATE_FIPS'
225
- gridder_options.output_size = { width: 50, height: 50 }
226
- gridder_options.output_data_type = :GDT_Byte
227
-
228
- gridder_options
229
- end
230
-
231
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_maximum.tif', __dir__) }
232
-
233
- it 'results in a raster with relevant data to the grid algorithm' do
234
- skip 'AGDEV-13650 figure out why this test causes a crash'
235
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
236
- gridder.grid!
237
-
238
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
239
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
240
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
241
- expect(dataset.raster_band(1).x_size).to eq 50
242
- expect(dataset.raster_band(1).y_size).to eq 50
243
- expect(dataset.raster_band(1).data_type).to eq :GDT_Byte
244
-
245
- stats = dataset.raster_band(1).statistics
246
- expect(stats[:minimum]).to eq 0.0
247
- expect(stats[:maximum]).to eq 56.0
248
- expect(stats[:mean]).to be_within(0.000000000001).of 26.3916
249
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 24.779859754244
250
- end
251
- end
252
-
253
- describe 'Metric Minimum' do
254
- let(:gridder_options) do
255
- gridder_options = GDAL::GridderOptions.new(:metric_minimum)
256
-
257
- gridder_options.algorithm_options[:angle] = 30
258
- gridder_options.algorithm_options[:no_data_value] = -9999
259
- gridder_options.algorithm_options[:radius1] = 90
260
- gridder_options.algorithm_options[:radius2] = 0.1
261
- gridder_options.algorithm_options[:min_points] = 1
262
-
263
- gridder_options.input_field_name = 'STATE_FIPS'
264
- gridder_options.output_size = { width: 50, height: 50 }
265
- gridder_options.output_data_type = :GDT_CInt16
266
-
267
- gridder_options
268
- end
269
-
270
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_minimum.tif', __dir__) }
271
-
272
- it 'results in a raster with relevant data to the grid algorithm' do
273
- skip 'AGDEV-13650 figure out why this test causes a crash'
274
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
275
- gridder.grid!
276
-
277
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
278
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
279
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
280
- expect(dataset.raster_band(1).x_size).to eq 50
281
- expect(dataset.raster_band(1).y_size).to eq 50
282
- expect(dataset.raster_band(1).data_type).to eq :GDT_CInt16
283
-
284
- stats = dataset.raster_band(1).statistics
285
- expect(stats[:minimum]).to eq 1.0
286
- expect(stats[:maximum]).to eq 53.0
287
- expect(stats[:mean]).to be_within(0.000000000001).of 9.1150793650794
288
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 12.575393694871
289
- end
290
- end
291
-
292
- # TODO: This test seems particularly prone to ruby malloc errors.
293
- describe 'Metric Range' do
294
- let(:gridder_options) do
295
- gridder_options = GDAL::GridderOptions.new(:metric_range)
296
-
297
- gridder_options.algorithm_options[:angle] = 10
298
- gridder_options.algorithm_options[:no_data_value] = -9999
299
- gridder_options.algorithm_options[:radius1] = 40
300
- gridder_options.algorithm_options[:radius2] = 10
301
- gridder_options.algorithm_options[:min_points] = 1
302
-
303
- gridder_options.input_field_name = 'STATE_FIPS'
304
- gridder_options.output_size = { width: 50, height: 50 }
305
- gridder_options.output_data_type = :GDT_CFloat64
306
-
307
- gridder_options
308
- end
309
-
310
- let(:output_file_name) { File.expand_path('../../../tmp/gridder_spec-metric_range.tif', __dir__) }
311
-
312
- it 'results in a raster with relevant data to the grid algorithm' do
313
- skip 'AGDEV-13650 figure out why this test causes a crash'
314
- gridder = GDAL::Gridder.new(source_layer, output_file_name, gridder_options)
315
- gridder.grid!
316
-
317
- expect(dataset.spatial_reference.authority_code.to_i).to eq 4269
318
- expect(dataset.raster_band(1)).to be_a GDAL::RasterBand
319
- expect(dataset.raster_band(1).no_data_value[:value]).to eq(-9999)
320
- expect(dataset.raster_band(1).x_size).to eq 50
321
- expect(dataset.raster_band(1).y_size).to eq 50
322
- expect(dataset.raster_band(1).data_type).to eq :GDT_CFloat64
323
-
324
- stats = dataset.raster_band(1).statistics
325
- expect(stats[:minimum]).to eq 0.0
326
- expect(stats[:maximum]).to eq 55.0
327
- expect(stats[:mean]).to be_within(0.000000000001).of 28.216176470588234
328
- expect(stats[:standard_deviation]).to be_within(0.000000000001).of 24.681864682477947
329
- end
330
- end
331
- end
@@ -1,229 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ffi-gdal'
5
- require 'gdal'
6
-
7
- RSpec.describe 'Raster Attribute Table Info', type: :integration do
8
- let(:file) { make_temp_test_file(original_source_tiff) }
9
-
10
- let(:original_source_tiff) do
11
- path = '../../../spec/support/images/osgeo/gdal/data/hfa/float-rle.img'
12
- File.expand_path(path, __dir__)
13
- end
14
-
15
- let(:dataset) { GDAL::Dataset.open(file, 'r') }
16
- after { dataset.close }
17
-
18
- subject do
19
- band = dataset.raster_band(1)
20
- band.default_raster_attribute_table
21
- end
22
-
23
- describe '#changes_written_to_file?' do
24
- context 'no changes to file' do
25
- it 'is true' do
26
- expect(subject.changes_written_to_file?).to eq true
27
- end
28
- end
29
- end
30
-
31
- describe '#column_count' do
32
- it 'retrieves the column count' do
33
- expect(subject.column_count).to eq 1
34
- end
35
- end
36
-
37
- describe '#column_name' do
38
- it 'retrieves the column name' do
39
- expect(subject.column_name(0)).to eq 'Histogram'
40
- end
41
- end
42
-
43
- describe '#column_usage' do
44
- it 'retrieves the column usage' do
45
- expect(subject.column_usage(0)).to eq :GFU_PixelCount
46
- end
47
- end
48
-
49
- describe '#column_type' do
50
- context 'column number exists' do
51
- it 'retrieves the column type' do
52
- expect(subject.column_type(0)).to eq :GFT_Real
53
- end
54
- end
55
-
56
- context 'column number does not exist' do
57
- it 'returns :GFT_Integer' do
58
- expect(subject.column_type(110)).to eq :GFT_Integer
59
- end
60
- end
61
- end
62
-
63
- describe '#column_of_usage' do
64
- context 'column with usage type exists' do
65
- it 'retrieves the index of column' do
66
- expect(subject.column_of_usage(:GFU_PixelCount)).to eq 0
67
- end
68
- end
69
-
70
- context 'column with usage type does not exist' do
71
- it 'returns nil' do
72
- expect(subject.column_of_usage(:GFU_Name)).to be_nil
73
- end
74
- end
75
-
76
- context 'column with invalid usage type' do
77
- it 'returns nil' do
78
- expect { subject.column_of_usage(:GFU_Meow) }.to raise_exception ArgumentError
79
- end
80
- end
81
- end
82
-
83
- describe '#create_column' do
84
- context 'valid params, dataset not opened in write mode' do
85
- it 'raises a GDAL::NoWriteAccess' do
86
- expect { subject.create_column('things', :GFT_String, :GFU_Name) }.
87
- to raise_exception GDAL::NoWriteAccess
88
- end
89
- end
90
-
91
- context 'valid params' do
92
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
93
-
94
- it 'adds the column' do
95
- subject.create_column('things', :GFT_Integer, :GFU_Red)
96
- expect(subject.column_name(1)).to eq 'Red'
97
- expect(subject.column_usage(1)).to eq :GFU_Red
98
- expect(subject.column_type(1)).to eq :GFT_Integer
99
- end
100
- end
101
- end
102
-
103
- describe '#row_count' do
104
- it 'returns the number of rows' do
105
- expect(subject.row_count).to eq 256
106
- end
107
- end
108
-
109
- describe '#row_count=' do
110
- context 'dataset not opened in write mode' do
111
- it 'raises a GDAL::NoWriteAccess' do
112
- expect { subject.row_count = 1 }.to raise_exception GDAL::NoWriteAccess
113
- end
114
- end
115
-
116
- context 'dataset opened in write mode' do
117
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
118
-
119
- it 'sets the number of rows' do
120
- subject.row_count = 2
121
- expect(subject.row_count).to eq 2
122
- end
123
- end
124
- end
125
-
126
- describe '#row_of_value' do
127
- context 'a row exists for the given pixel value' do
128
- it 'returns the row index' do
129
- expect(subject.row_of_value(58_595)).to eq 253
130
- end
131
- end
132
-
133
- context 'a row does not exist for the given pixel value' do
134
- it 'returns nil' do
135
- expect(subject.row_of_value(123_456)).to eq nil
136
- end
137
- end
138
- end
139
-
140
- describe '#set_value_as_string' do
141
- context 'dataset not opened in write mode' do
142
- it 'raises a GDAL::NoWriteAccess' do
143
- expect { subject.set_value_as_string(0, 0, 'test') }.to raise_exception GDAL::NoWriteAccess
144
- end
145
- end
146
-
147
- context 'column is a double' do
148
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
149
-
150
- it 'sets the value' do
151
- subject.set_value_as_string(0, 0, 'test')
152
- expect(subject.value_as_string(0, 0)).to eq '0'
153
- end
154
- end
155
- end
156
-
157
- describe '#set_value_as_double' do
158
- context 'dataset not opened in write mode' do
159
- it 'raises a GDAL::NoWriteAccess' do
160
- expect { subject.set_value_as_double(0, 0, 1.2) }.to raise_exception GDAL::NoWriteAccess
161
- end
162
- end
163
-
164
- context 'column is a double' do
165
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
166
-
167
- it 'sets the value' do
168
- subject.set_value_as_double(0, 0, 1.2)
169
- expect(subject.value_as_double(0, 0)).to eq 1.2
170
- end
171
- end
172
- end
173
-
174
- describe '#set_value_as_integer' do
175
- context 'dataset not opened in write mode' do
176
- it 'raises a GDAL::NoWriteAccess' do
177
- expect { subject.set_value_as_integer(0, 0, 1) }.to raise_exception GDAL::NoWriteAccess
178
- end
179
- end
180
-
181
- context 'column is a double' do
182
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
183
-
184
- it 'sets the value' do
185
- subject.set_value_as_integer(0, 0, 1)
186
- expect(subject.value_as_integer(0, 0)).to eq 1
187
- end
188
- end
189
- end
190
-
191
- describe '#linear_binning' do
192
- it 'returns a Hash that contains binning info' do
193
- expect(subject.linear_binning).to eq(row_0_minimum: 0.0, bin_size: 230.79607843137254)
194
- end
195
- end
196
-
197
- describe '#set_linear_binning' do
198
- context 'dataset not opened in write mode' do
199
- it 'raises a GDAL::NoWriteAccess' do
200
- expect { subject.set_linear_binning(0, 0) }.to raise_exception GDAL::NoWriteAccess
201
- end
202
- end
203
-
204
- context 'valid binning params' do
205
- let(:dataset) { GDAL::Dataset.open(file, 'w') }
206
-
207
- it 'returns a Hash that contains binning info' do
208
- subject.set_linear_binning(1, 20)
209
- expect(subject.linear_binning).to eq(row_0_minimum: 1.0, bin_size: 20.0)
210
- end
211
- end
212
- end
213
-
214
- describe '#to_color_table' do
215
- it 'returns nil' do
216
- expect(subject.to_color_table).to be_nil
217
- end
218
- end
219
-
220
- describe '#dump_readable' do
221
- let(:output_path) { File.expand_path('tmp/raster_attribute_table_info') }
222
- after { File.unlink(output_path) if File.exist?(output_path) }
223
-
224
- it 'writes to the file' do
225
- subject.dump_readable(output_path)
226
- expect(File.exist?(output_path)).to eq true
227
- end
228
- end
229
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/dataset'
5
- require 'gdal/raster_band'
6
-
7
- RSpec.describe GDAL::RasterBand, type: :integration do
8
- describe '#sieve_filter!' do
9
- let(:source_image_path) { 'spec/support/images/osgeo/geotiff/zi_imaging/image0.tif' }
10
- let(:dest_image_path) { 'tmp/image0.tif' }
11
-
12
- before do
13
- FileUtils.rm(dest_image_path) if File.exist?(dest_image_path)
14
- FileUtils.cp(source_image_path, dest_image_path)
15
- end
16
-
17
- it 'removes some polygons' do
18
- dataset = GDAL::Dataset.open(dest_image_path, 'w')
19
- band = dataset.raster_band(1)
20
-
21
- ogr_driver = OGR::Driver.by_name('Memory')
22
- data_source = ogr_driver.create_data_source('meow')
23
- layer_before = data_source.create_layer('before', spatial_reference: dataset.spatial_reference)
24
- band.polygonize(layer_before)
25
-
26
- band.sieve_filter!(1000, 4)
27
- layer_after = data_source.create_layer('after', spatial_reference: dataset.spatial_reference)
28
- band.polygonize(layer_after)
29
-
30
- expect(layer_before.feature_count).to eq 62
31
- expect(layer_after.feature_count).to eq 15
32
- dataset.close
33
- end
34
- end
35
- end