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,434 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/layer'
5
-
6
- RSpec.describe OGR::Layer do
7
- include_context 'OGR::Layer, spatial_reference'
8
-
9
- describe '#create_field + #find_field_index' do
10
- context 'creation not supported' do
11
- before do
12
- expect(subject).to receive(:can_create_field?).and_return false
13
- end
14
-
15
- it 'raises an OGR::UnsupportedOperation' do
16
- expect { subject.create_field(OGR::FieldDefinition.new('test', :OFTInteger)) }.
17
- to raise_exception OGR::UnsupportedOperation
18
- end
19
- end
20
-
21
- context 'creation is supported' do
22
- it 'can create an OFTInteger' do
23
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTInteger))
24
- expect(subject.find_field_index('test field')).to be_zero
25
- end
26
-
27
- it 'can create an OFTIntegerList' do
28
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTIntegerList))
29
- expect(subject.find_field_index('test field')).to be_zero
30
- end
31
-
32
- it 'can create an OFTReal' do
33
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTReal))
34
- expect(subject.find_field_index('test field')).to be_zero
35
- end
36
-
37
- it 'can create an OFTRealList' do
38
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTRealList))
39
- expect(subject.find_field_index('test field')).to be_zero
40
- end
41
-
42
- it 'can create an OFTString' do
43
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTString))
44
- expect(subject.find_field_index('test field')).to be_zero
45
- end
46
-
47
- it 'can create an OFTStringList' do
48
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTStringList))
49
- expect(subject.find_field_index('test field')).to be_zero
50
- end
51
-
52
- it 'can create an OFTWideString' do
53
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTWideString))
54
- expect(subject.find_field_index('test field')).to be_zero
55
- end
56
-
57
- it 'can create an OFTWideStringList' do
58
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTWideStringList))
59
- expect(subject.find_field_index('test field')).to be_zero
60
- end
61
-
62
- it 'can create an OFTBinary' do
63
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTBinary))
64
- expect(subject.find_field_index('test field')).to be_zero
65
- end
66
-
67
- it 'can create an OFTDate' do
68
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTDate))
69
- expect(subject.find_field_index('test field')).to be_zero
70
- end
71
-
72
- it 'can create an OFTTime' do
73
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTTime))
74
- expect(subject.find_field_index('test field')).to be_zero
75
- end
76
-
77
- it 'can create an OFTDateTime' do
78
- subject.create_field(OGR::FieldDefinition.new('test field', :OFTDateTime))
79
- expect(subject.find_field_index('test field')).to be_zero
80
- end
81
- end
82
- end
83
-
84
- describe '#delete_field + #create_field' do
85
- context 'delete not supported' do
86
- before do
87
- expect(subject).to receive(:can_delete_field?).and_return false
88
- end
89
-
90
- it 'raises an OGR::UnsupportedOperation' do
91
- expect { subject.delete_field(0) }.to raise_exception OGR::UnsupportedOperation
92
- end
93
- end
94
-
95
- context 'delete is supported' do
96
- context 'field exists at index' do
97
- before do
98
- fd = OGR::FieldDefinition.new('test field', :OFTInteger)
99
- subject.create_field(fd)
100
- end
101
-
102
- it 'can delete the field' do
103
- expect(subject.delete_field(0)).to eq true
104
- end
105
- end
106
-
107
- context 'field does not exist at index' do
108
- it 'raises a GDAL::UnsupportedOperation' do
109
- expect { subject.delete_field(1) }.to raise_exception GDAL::UnsupportedOperation
110
- end
111
- end
112
- end
113
- end
114
-
115
- describe '#reorder_fields + #create_field' do
116
- context 'reordering not supported' do
117
- before do
118
- expect(subject).to receive(:can_reorder_fields?).and_return false
119
- end
120
-
121
- it 'raises an OGR::UnsupportedOperation' do
122
- expect { subject.reorder_fields(1, 0) }.to raise_exception OGR::UnsupportedOperation
123
- end
124
- end
125
-
126
- context 'reordering is supported' do
127
- context 'field does not exist at one of the given indexes' do
128
- it 'returns false' do
129
- expect(subject.reorder_fields(1, 0)).to eq false
130
- end
131
- end
132
-
133
- context 'no fields given' do
134
- it 'returns false' do
135
- expect(subject.reorder_fields).to eq false
136
- end
137
- end
138
-
139
- context 'fields exist' do
140
- before do
141
- fd0 = OGR::FieldDefinition.new('field0', :OFTInteger)
142
- fd1 = OGR::FieldDefinition.new('field1', :OFTString)
143
- subject.create_field(fd0)
144
- subject.create_field(fd1)
145
- end
146
-
147
- it 'returns true and reorders the fields' do
148
- expect(subject.find_field_index('field0')).to eq 0
149
- expect(subject.find_field_index('field1')).to eq 1
150
-
151
- expect(subject.reorder_fields(1, 0)).to eq true
152
-
153
- expect(subject.find_field_index('field0')).to eq 1
154
- expect(subject.find_field_index('field1')).to eq 0
155
- end
156
-
157
- it "updates the feature definition's field definitions" do
158
- expect(subject.feature_definition.field_definition(0).name).to eq 'field0'
159
- expect(subject.feature_definition.field_definition(1).name).to eq 'field1'
160
- end
161
- end
162
- end
163
- end
164
-
165
- describe '#reorder_field + #create_field' do
166
- context 'reordering not supported' do
167
- before do
168
- expect(subject).to receive(:can_reorder_fields?).and_return false
169
- end
170
-
171
- it 'raises an OGR::UnsupportedOperation' do
172
- expect { subject.reorder_field(1, 0) }.to raise_exception OGR::UnsupportedOperation
173
- end
174
- end
175
-
176
- context 'reordering is supported' do
177
- context 'field does not exist at one of the given indexes' do
178
- it 'raises a GDAL::UnsupportedOperation' do
179
- expect { subject.reorder_field(1, 0) }.to raise_exception GDAL::UnsupportedOperation
180
- end
181
- end
182
-
183
- context 'fields exist' do
184
- before do
185
- fd0 = OGR::FieldDefinition.new('field0', :OFTInteger)
186
- fd1 = OGR::FieldDefinition.new('field1', :OFTString)
187
- subject.create_field(fd0)
188
- subject.create_field(fd1)
189
- end
190
-
191
- it 'returns true and reorders the fields' do
192
- expect(subject.find_field_index('field0')).to eq 0
193
- expect(subject.find_field_index('field1')).to eq 1
194
-
195
- expect(subject.reorder_field(1, 0)).to eq true
196
-
197
- expect(subject.find_field_index('field0')).to eq 1
198
- expect(subject.find_field_index('field1')).to eq 0
199
- end
200
-
201
- it "updates the feature definition's field definitions" do
202
- expect(subject.feature_definition.field_definition(0).name).to eq 'field0'
203
- expect(subject.feature_definition.field_definition(1).name).to eq 'field1'
204
- end
205
- end
206
- end
207
- end
208
-
209
- describe '#alter_field_definition + #create_field' do
210
- context 'altering not supported' do
211
- before do
212
- expect(subject).to receive(:can_alter_field_definition?).and_return false
213
- end
214
-
215
- it 'raises an OGR::UnsupportedOperation' do
216
- expect do
217
- subject.alter_field_definition(123, OGR::FieldDefinition.new('blah', :OFTString), OGR::Layer::ALTER_ALL_FLAG)
218
- end.to raise_exception OGR::UnsupportedOperation
219
- end
220
- end
221
-
222
- context 'altering is supported' do
223
- let(:string_field_def) do
224
- fd = OGR::FieldDefinition.new('StringField', :OFTString)
225
- fd.width = 16
226
-
227
- fd
228
- end
229
-
230
- let(:int_field_def) do
231
- fd = OGR::FieldDefinition.new('IntField', :OFTInteger)
232
- fd.width = 4
233
-
234
- fd
235
- end
236
-
237
- let(:real_field_def) do
238
- fd = OGR::FieldDefinition.new('RealField', :OFTReal)
239
- fd.width = 8
240
-
241
- fd
242
- end
243
-
244
- context 'no field at given index' do
245
- it 'raises a GDAL::UnsupportedOperation' do
246
- expect do
247
- subject.alter_field_definition(123, int_field_def, OGR::Layer::ALTER_ALL_FLAG)
248
- end.to raise_exception GDAL::UnsupportedOperation
249
- end
250
- end
251
-
252
- context 'field exists at given index' do
253
- context 'ALTER_NAME_FLAG' do
254
- before { subject.create_field(string_field_def) }
255
-
256
- it 'only alters the name of the field' do
257
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_NAME_FLAG)
258
-
259
- expect(subject.feature_definition.field_definition(0).name).to eq 'IntField'
260
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTString
261
- expect(subject.feature_definition.field_definition(0).width).to eq 16
262
- end
263
- end
264
-
265
- context 'ALTER_TYPE_FLAG' do
266
- context 'convert OFTString to OFTInteger' do
267
- before { subject.create_field(string_field_def) }
268
-
269
- it 'raises a GDAL::UnsupportedOperation' do
270
- expect do
271
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_TYPE_FLAG)
272
- end.to raise_exception GDAL::UnsupportedOperation
273
- end
274
- end
275
-
276
- context 'convert OFTInteger to OFTString' do
277
- before { subject.create_field(int_field_def) }
278
-
279
- it 'only alters the type of the field' do
280
- subject.alter_field_definition(0, string_field_def, OGR::Layer::ALTER_TYPE_FLAG)
281
-
282
- expect(subject.feature_definition.field_definition(0).name).to eq 'IntField'
283
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTString
284
- expect(subject.feature_definition.field_definition(0).width).to eq 4
285
- end
286
- end
287
-
288
- context 'convert OFTInteger to OFTReal' do
289
- before { subject.create_field(int_field_def) }
290
-
291
- it 'only alters the type of the field' do
292
- subject.alter_field_definition(0, real_field_def, OGR::Layer::ALTER_TYPE_FLAG)
293
-
294
- expect(subject.feature_definition.field_definition(0).name).to eq 'IntField'
295
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTReal
296
- expect(subject.feature_definition.field_definition(0).width).to eq 4
297
- end
298
- end
299
-
300
- context 'convert OFTReal to OFTInteger' do
301
- before { subject.create_field(real_field_def) }
302
-
303
- it 'raises a GDAL::UnsupportedOperation' do
304
- expect do
305
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_TYPE_FLAG)
306
- end.to raise_exception GDAL::UnsupportedOperation
307
- end
308
- end
309
- end
310
-
311
- context 'ALTER_WIDTH_PRECISION_FLAG' do
312
- before { subject.create_field(string_field_def) }
313
-
314
- it 'only alters the width of the field' do
315
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_WIDTH_PRECISION_FLAG)
316
-
317
- expect(subject.feature_definition.field_definition(0).name).to eq 'StringField'
318
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTString
319
- expect(subject.feature_definition.field_definition(0).width).to eq 4
320
- end
321
- end
322
-
323
- context 'ALTER_ALL_FLAG' do
324
- context 'convert OFTString to OFTInteger' do
325
- before { subject.create_field(string_field_def) }
326
-
327
- it 'raises a GDAL::UnsupportedOperation' do
328
- expect do
329
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_ALL_FLAG)
330
- end.to raise_exception GDAL::UnsupportedOperation
331
- end
332
- end
333
-
334
- context 'convert OFTInteger to OFTString' do
335
- before { subject.create_field(int_field_def) }
336
-
337
- it 'alters all attributes of the field' do
338
- subject.alter_field_definition(0, string_field_def, OGR::Layer::ALTER_ALL_FLAG)
339
-
340
- expect(subject.feature_definition.field_definition(0).name).to eq 'StringField'
341
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTString
342
- expect(subject.feature_definition.field_definition(0).width).to eq 16
343
- end
344
- end
345
-
346
- context 'convert OFTInteger to OFTReal' do
347
- before { subject.create_field(int_field_def) }
348
-
349
- it 'alters all attributes of the field' do
350
- subject.alter_field_definition(0, real_field_def, OGR::Layer::ALTER_ALL_FLAG)
351
-
352
- expect(subject.feature_definition.field_definition(0).name).to eq 'RealField'
353
- expect(subject.feature_definition.field_definition(0).type).to eq :OFTReal
354
- expect(subject.feature_definition.field_definition(0).width).to eq 8
355
- end
356
- end
357
-
358
- context 'convert OFTReal to OFTInteger' do
359
- before { subject.create_field(real_field_def) }
360
-
361
- it 'raises a GDAL::UnsupportedOperation' do
362
- expect do
363
- subject.alter_field_definition(0, int_field_def, OGR::Layer::ALTER_ALL_FLAG)
364
- end.to raise_exception GDAL::UnsupportedOperation
365
- end
366
- end
367
- end
368
- end
369
- end
370
- end
371
-
372
- describe '#find_field_index' do
373
- context 'field with name does not exist' do
374
- it 'returns nil' do
375
- expect(subject.find_field_index('meow')).to be_nil
376
- end
377
- end
378
-
379
- context 'field with name exists' do
380
- before { subject.create_field(OGR::FieldDefinition.new('meow', :OFTString)) }
381
-
382
- it 'returns the index' do
383
- expect(subject.find_field_index('meow')).to be_zero
384
- end
385
- end
386
- end
387
-
388
- describe '#create_geometry_field' do
389
- let(:geometry_field_def) { OGR::GeometryFieldDefinition.new('geofield0') }
390
-
391
- context 'creation not supported' do
392
- before do
393
- expect(subject).to receive(:can_create_geometry_field?).and_return false
394
- end
395
-
396
- it 'raises an OGR::UnsupportedOperation' do
397
- expect { subject.create_geometry_field(geometry_field_def) }.
398
- to raise_exception OGR::UnsupportedOperation
399
- end
400
- end
401
-
402
- context 'creation is supported' do
403
- it 'returns true' do
404
- expect(subject.create_geometry_field(geometry_field_def)).to eq true
405
- end
406
- end
407
- end
408
-
409
- describe '#set_ignored_fields' do
410
- context 'no fields given' do
411
- it 'returns false' do
412
- expect(subject.set_ignored_fields).to eq false
413
- end
414
- end
415
-
416
- context 'invalid field names given' do
417
- it 'raises an OGR::Failure' do
418
- expect { subject.set_ignored_fields('meow', 'bobo') }.
419
- to raise_exception OGR::Failure
420
- end
421
- end
422
-
423
- context 'valid field names given' do
424
- before do
425
- subject.create_field(OGR::FieldDefinition.new('meow', :OFTInteger))
426
- subject.create_field(OGR::FieldDefinition.new('bobo', :OFTInteger))
427
- end
428
-
429
- it 'returns true' do
430
- expect(subject.set_ignored_fields('meow', 'bobo')).to eq true
431
- end
432
- end
433
- end
434
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/layer'
5
-
6
- RSpec.describe OGR::Layer do
7
- include_context 'OGR::Layer, spatial_reference'
8
-
9
- describe '#symmetrical_difference' do
10
- let(:other_layer) do
11
- data_source.create_layer 'other layer',
12
- geometry_type: :wkbMultiPoint,
13
- spatial_reference: OGR::SpatialReference.new_from_epsg(4326)
14
- end
15
-
16
- it 'does not die' do
17
- skip 'Figuring out how to init a result pointer'
18
- # expect { subject.symmetrical_difference(other_layer) }.
19
- # to_not raise_exception
20
- end
21
- end
22
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/layer'
5
-
6
- RSpec.describe OGR::Layer do
7
- include_context 'OGR::Layer, spatial_reference'
8
-
9
- describe '#spatial_filter' do
10
- context 'default' do
11
- subject { layer.spatial_filter }
12
- it { is_expected.to be_nil }
13
- end
14
- end
15
-
16
- describe '#spatial_filter= + #spatial_filter' do
17
- it 'assigns the spatial_filter to the new geometry' do
18
- geometry = OGR::Geometry.create_from_wkt('POINT (1 1)')
19
- subject.spatial_filter = geometry
20
- expect(subject.spatial_filter).to eq geometry
21
- end
22
- end
23
-
24
- describe '#set_spatial_filter_ex' do
25
- it 'does not die' do
26
- geometry = OGR::Geometry.create_from_wkt('POINT (1 1)')
27
- expect { subject.set_spatial_filter_ex(0, geometry) }.to_not raise_exception
28
- end
29
- end
30
-
31
- describe '#set_spatial_filter_rectangle' do
32
- it 'does not die' do
33
- expect { subject.set_spatial_filter_rectangle(0, 0, 1000, 1000) }.
34
- to_not raise_exception
35
- end
36
- end
37
-
38
- describe '#set_spatial_filter_rectangle_ex' do
39
- it 'does not die' do
40
- expect { subject.set_spatial_filter_rectangle_ex(0, 0, 0, 1000, 1000) }.
41
- to_not raise_exception
42
- end
43
- end
44
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/layer'
5
-
6
- RSpec.describe OGR::Layer do
7
- include_context 'OGR::Layer, spatial_reference'
8
-
9
- describe '#geometry_column' do
10
- it 'returns a String' do
11
- expect(subject.geometry_column).to be_a String
12
- end
13
- end
14
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/layer'
5
-
6
- RSpec.describe OGR::Layer do
7
- include_context 'OGR::Layer, spatial_reference'
8
-
9
- describe '#name' do
10
- it 'returns the name given to it' do
11
- expect(subject.name).to eq 'spec layer'
12
- end
13
- end
14
-
15
- describe '#geometry_type' do
16
- it 'returns the type it was created with' do
17
- expect(subject.geometry_type).to eq :wkbMultiPoint
18
- end
19
- end
20
-
21
- describe '#sync_to_disk' do
22
- it 'does not die' do
23
- expect { subject.sync_to_disk }.to_not raise_exception
24
- end
25
- end
26
-
27
- describe '#test_capability' do
28
- context 'some supported capabilities to check' do
29
- let(:capabilities) do
30
- %w[OLCRandomRead OLCCreateField OLCCurveGeometries]
31
- end
32
-
33
- # I don't get why these return false...
34
- it 'returns false' do
35
- capabilities.each do |capability|
36
- expect(subject.test_capability(capability)).to eq false
37
- end
38
- end
39
- end
40
-
41
- context 'unsupported capabilities to check' do
42
- it 'returns false' do
43
- expect(subject.test_capability('meow')).to eq false
44
- end
45
- end
46
- end
47
-
48
- describe '#spatial_reference' do
49
- context 'no spatial ref' do
50
- include_context 'OGR::Layer, no spatial_reference'
51
-
52
- it 'returns nil' do
53
- expect(subject.spatial_reference).to be_nil
54
- end
55
- end
56
-
57
- context 'with a spatial ref' do
58
- it 'returns an OGR::SpatialReference' do
59
- expect(subject.spatial_reference).to be_a OGR::SpatialReference
60
- end
61
- end
62
- end
63
-
64
- describe '#extent' do
65
- it 'returns an OGR::Envelope' do
66
- expect(subject.extent).to be_a OGR::Envelope
67
- end
68
- end
69
-
70
- describe '#extent_by_geometry' do
71
- context 'force is false' do
72
- it 'returns an OGR::Envelope' do
73
- expect(subject.extent_by_geometry(0, false)).to be_a OGR::Envelope
74
- end
75
- end
76
-
77
- context 'force is true' do
78
- it 'returns an OGR::Envelope' do
79
- expect(subject.extent_by_geometry(0, true)).to be_a OGR::Envelope
80
- end
81
- end
82
- end
83
-
84
- describe '#style_table= + #style_table' do
85
- context 'one is not set' do
86
- it 'returns nil' do
87
- expect(subject.style_table).to be_nil
88
- end
89
- end
90
-
91
- context 'one is set' do
92
- it 'returns an OGR::StyleTable' do
93
- subject.style_table = OGR::StyleTable.new
94
- expect(subject.style_table).to be_a OGR::StyleTable
95
- end
96
- end
97
- end
98
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/spatial_reference'
5
-
6
- RSpec.describe OGR::SpatialReference do
7
- describe '#set_local_cs' do
8
- it 'sets the LOCAL_CS' do
9
- expect do
10
- subject.set_local_cs('darrel')
11
- end.to change { subject.to_wkt }.from('').to('LOCAL_CS["darrel"]')
12
- end
13
- end
14
-
15
- describe '#set_proj_cs' do
16
- it 'sets the PROJCS' do
17
- expect do
18
- subject.set_proj_cs('darrel')
19
- end.to change { subject.to_wkt }.from('').to('PROJCS["darrel"]')
20
- end
21
- end
22
-
23
- describe '#set_geoc_cs' do
24
- it 'sets the GEOCCS' do
25
- expect do
26
- subject.set_geoc_cs('darrel')
27
- end.to change { subject.to_wkt }.from('').to('GEOCCS["darrel"]')
28
- end
29
- end
30
-
31
- describe '#set_from_user_input' do
32
- context 'valid input' do
33
- it 'sets the GEOCCS' do
34
- expect do
35
- subject.set_from_user_input('GEOCCS["darrel"]')
36
- end.to change { subject.to_wkt }.from('').to('GEOCCS["darrel"]')
37
- end
38
- end
39
-
40
- context 'invalid input' do
41
- it 'sets the GEOCCS' do
42
- expect do
43
- subject.set_from_user_input('darrel')
44
- end.to raise_exception OGR::CorruptData
45
- end
46
- end
47
- end
48
- end