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
@@ -28,7 +28,7 @@ module OGR
28
28
  #
29
29
  # This converts the OGR integer into something usable by Ruby's DateTime.
30
30
  #
31
- # @param time_zone [Fixnum]
31
+ # @param time_zone [Integer]
32
32
  def _format_time_zone_for_ruby(time_zone)
33
33
  case time_zone
34
34
  when 0 then nil
@@ -47,7 +47,7 @@ module OGR
47
47
  #
48
48
  # @param time_zone [String]
49
49
  def _format_time_zone_for_ogr(time_zone)
50
- if time_zone =~ /(00:00|GMT)\z/
50
+ if /(00:00|GMT)\z/.match?(time_zone)
51
51
  100
52
52
  elsif time_zone
53
53
  1
data/lib/ogr/layer.rb CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  require_relative '../ogr'
4
4
  require_relative '../gdal'
5
- require_relative 'layer_mixins/extensions'
6
- require_relative 'layer_mixins/capability_methods'
7
5
  require_relative 'layer_mixins/ogr_feature_methods'
8
6
  require_relative 'layer_mixins/ogr_field_methods'
9
7
  require_relative 'layer_mixins/ogr_layer_method_methods'
@@ -14,8 +12,6 @@ module OGR
14
12
  class Layer
15
13
  include GDAL::MajorObject
16
14
  include GDAL::Logger
17
- include LayerMixins::Extensions
18
- include LayerMixins::CapabilityMethods
19
15
  include LayerMixins::OGRFeatureMethods
20
16
  include LayerMixins::OGRFieldMethods
21
17
  include LayerMixins::OGRLayerMethodMethods
@@ -36,16 +32,19 @@ module OGR
36
32
 
37
33
  # @return [String]
38
34
  def name
39
- FFI::OGR::API.OGR_L_GetName(@c_pointer)
35
+ name, ptr = FFI::OGR::API.OGR_L_GetName(@c_pointer)
36
+ ptr.autorelease = false
37
+
38
+ name
40
39
  end
41
40
 
42
41
  # @return [Boolean]
43
42
  # TODO: This seems to occasionally lead to: 28352 illegal hardware
44
43
  # instruction, and sometimes full crashes.
45
44
  def sync_to_disk
46
- ogr_err = FFI::OGR::API.OGR_L_SyncToDisk(@c_pointer)
47
-
48
- ogr_err.handle_result
45
+ OGR::ErrorHandling.handle_ogr_err('Unable to sync layer to disk') do
46
+ FFI::OGR::API.OGR_L_SyncToDisk(@c_pointer)
47
+ end
49
48
  end
50
49
 
51
50
  # Tests if this layer supports the given capability. Must be in the list
@@ -58,6 +57,9 @@ module OGR
58
57
  FFI::OGR::API.OGR_L_TestCapability(@c_pointer, capability.to_s)
59
58
  end
60
59
 
60
+ # NOTE: This SpatialReference is owned by the Layer and should thus not be
61
+ # modified.
62
+ #
61
63
  # @return [OGR::SpatialReference]
62
64
  def spatial_reference
63
65
  spatial_ref_pointer = FFI::OGR::API.OGR_L_GetSpatialRef(@c_pointer)
@@ -67,7 +69,7 @@ module OGR
67
69
  end
68
70
 
69
71
  # @return [OGR::Envelope]
70
- def extent(force = true)
72
+ def extent(force: true)
71
73
  envelope = FFI::OGR::Envelope.new
72
74
  FFI::OGR::API.OGR_L_GetExtent(@c_pointer, envelope, force)
73
75
  return nil if envelope.null?
@@ -76,7 +78,7 @@ module OGR
76
78
  end
77
79
 
78
80
  # @return [OGR::Envelope]
79
- def extent_by_geometry(geometry_field_index, force = true)
81
+ def extent_by_geometry(geometry_field_index, force: true)
80
82
  envelope = FFI::OGR::Envelope.new
81
83
  FFI::OGR::API.OGR_L_GetExtentEx(@c_pointer, geometry_field_index, envelope, force)
82
84
  return nil if envelope.null?
@@ -8,6 +8,8 @@ module OGR
8
8
  # @return [OGR::FeatureDefinition,nil]
9
9
  def definition
10
10
  feature_defn_pointer = FFI::OGR::API.OGR_L_GetLayerDefn(@c_pointer)
11
+ feature_defn_pointer.autorelease = false
12
+
11
13
  return nil if feature_defn_pointer.null?
12
14
 
13
15
  # This object should not be modified.
@@ -23,58 +25,68 @@ module OGR
23
25
  # layer.create_feature(feature)
24
26
  #
25
27
  # @param feature [OGR::Feature] [description]
26
- # @return [Boolean]
28
+ # @raise [OGR::Failure]
27
29
  def create_feature(feature)
28
- raise OGR::UnsupportedOperation, 'This layer does not support feature creation.' unless can_sequential_write?
29
-
30
- ogr_err = FFI::OGR::API.OGR_L_CreateFeature(@c_pointer, feature.c_pointer)
31
-
32
- ogr_err.handle_result
30
+ unless test_capability('SequentialWrite')
31
+ raise OGR::UnsupportedOperation,
32
+ 'This layer does not support feature creation.'
33
+ end
34
+
35
+ OGR::ErrorHandling.handle_ogr_err('Unable to create feature') do
36
+ FFI::OGR::API.OGR_L_CreateFeature(@c_pointer, feature.c_pointer)
37
+ end
33
38
  end
34
39
 
35
40
  # Deletes the feature from the layer.
36
41
  #
37
- # @param feature_id [Fixnum] ID of the Feature to delete.
38
- # @return +true+ if successful, otherwise raises an OGR exception.
42
+ # @param feature_id [Integer] ID of the Feature to delete.
39
43
  # @raise [OGR::Failure] When trying to delete a feature with an ID that
40
44
  # does not exist.
41
45
  def delete_feature(feature_id)
42
- raise OGR::UnsupportedOperation, 'This layer does not support feature deletion.' unless can_delete_feature?
43
-
44
- ogr_err = FFI::OGR::API.OGR_L_DeleteFeature(@c_pointer, feature_id)
45
-
46
- ogr_err.handle_result "Unable to delete feature with ID '#{feature_id}'"
46
+ unless test_capability('DeleteFeature')
47
+ raise OGR::UnsupportedOperation,
48
+ 'This layer does not support feature deletion.'
49
+ end
50
+
51
+ OGR::ErrorHandling.handle_ogr_err("Unable to delete feature with ID '#{feature_id}'") do
52
+ FFI::OGR::API.OGR_L_DeleteFeature(@c_pointer, feature_id)
53
+ end
47
54
  end
48
55
 
49
56
  # The number of features in this layer. If +force+ is false and it would be
50
57
  # expensive to determine the feature count, -1 may be returned.
51
58
  #
52
59
  # @param force [Boolean] Force the calculation even if it's expensive.
53
- # @return [Fixnum]
54
- def feature_count(force = true)
60
+ # @return [Integer]
61
+ def feature_count(force: true)
55
62
  FFI::OGR::API.OGR_L_GetFeatureCount(@c_pointer, force)
56
63
  end
57
64
 
58
65
  # Rewrites an existing feature using the ID within the given Feature.
59
66
  #
60
67
  # @param new_feature [OGR::Feature, FFI::Pointer]
68
+ # @raise [OGR::Failure]
61
69
  def feature=(new_feature)
62
- raise OGR::UnsupportedOperation, '#feature= not supported by this Layer' unless can_random_write?
70
+ raise OGR::UnsupportedOperation, '#feature= not supported by this Layer' unless test_capability('RandomWrite')
63
71
 
64
72
  new_feature_ptr = GDAL._pointer(OGR::Feature, new_feature)
65
73
  raise OGR::InvalidFeature if new_feature_ptr.nil? || new_feature_ptr.null?
66
74
 
67
- ogr_err = FFI::OGR::API.OGR_L_SetFeature(@c_pointer, new_feature_ptr)
68
-
69
- ogr_err.handle_result
75
+ OGR::ErrorHandling.handle_ogr_err('Unable to set feature') do
76
+ FFI::OGR::API.OGR_L_SetFeature(@c_pointer, new_feature_ptr)
77
+ end
70
78
  end
71
79
 
72
- # @param index [Fixnum] The 0-based index of the feature to get. It should
80
+ # @param index [Integer] The 0-based index of the feature to get. It should
73
81
  # be <= +feature_count+, but no checking is done to ensure.
74
82
  # @return [OGR::Feature, nil]
75
83
  def feature(index)
76
- raise OGR::UnsupportedOperation, '#feature(index) not supported by this Layer' unless can_random_read?
84
+ unless test_capability('RandomRead')
85
+ raise OGR::UnsupportedOperation,
86
+ '#feature(index) not supported by this Layer'
87
+ end
77
88
 
89
+ # This feature needs to be Destroyed.
78
90
  feature_pointer = FFI::OGR::API.OGR_L_GetFeature(@c_pointer, index)
79
91
  return nil if feature_pointer.null?
80
92
 
@@ -98,16 +110,16 @@ module OGR
98
110
 
99
111
  # Sets the index for #next_feature.
100
112
  #
101
- # @param feature_index [Fixnum]
102
- # @return [Boolean]
113
+ # @param feature_index [Integer]
114
+ # @raise [OGR::Failure]
103
115
  def next_feature_index=(feature_index)
104
- ogr_err = FFI::OGR::API.OGR_L_SetNextByIndex(@c_pointer, feature_index)
105
-
106
- ogr_err.handle_result "Unable to set next feature index to #{feature_index}"
116
+ OGR::ErrorHandling.handle_ogr_err("Unable to set next feature index to #{feature_index}") do
117
+ FFI::OGR::API.OGR_L_SetNextByIndex(@c_pointer, feature_index)
118
+ end
107
119
  end
108
120
  alias set_next_by_index next_feature_index=
109
121
 
110
- # @return [Fixnum]
122
+ # @return [Integer]
111
123
  def features_read
112
124
  FFI::OGR::API.OGR_L_GetFeaturesRead(@c_pointer)
113
125
  end
@@ -10,75 +10,90 @@ module OGR
10
10
  # @param field_definition [OGR::FieldDefinition]
11
11
  # @param approx_ok [Boolean] If +true+ the field may be created in a slightly
12
12
  # different form, depending on the limitations of the format driver.
13
- # @return [Boolean]
14
- def create_field(field_definition, approx_ok = false)
15
- raise OGR::UnsupportedOperation, 'This layer does not support field creation.' unless can_create_field?
13
+ # @raise [OGR::Failure]
14
+ def create_field(field_definition, approx_ok: false)
15
+ unless test_capability('CreateField')
16
+ raise OGR::UnsupportedOperation,
17
+ 'This layer does not support field creation.'
18
+ end
16
19
 
17
20
  field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, field_definition)
18
- ogr_err = FFI::OGR::API.OGR_L_CreateField(@c_pointer, field_definition_ptr, approx_ok)
19
21
 
20
- ogr_err.handle_result
22
+ OGR::ErrorHandling.handle_ogr_err('Unable to create field') do
23
+ FFI::OGR::API.OGR_L_CreateField(@c_pointer, field_definition_ptr, approx_ok)
24
+ end
21
25
  end
22
26
 
23
27
  # Deletes the field definition from the layer.
24
28
  #
25
- # @return +true+ if successful, otherwise raises an OGR exception.
29
+ # @raise [OGR::Failure]
26
30
  def delete_field(field_id)
27
- raise OGR::UnsupportedOperation, 'This driver does not support field deletion.' unless can_delete_field?
28
-
29
- ogr_err = FFI::OGR::API.OGR_L_DeleteField(@c_pointer, field_id)
31
+ unless test_capability('DeleteField')
32
+ raise OGR::UnsupportedOperation,
33
+ 'This driver does not support field deletion.'
34
+ end
30
35
 
31
- ogr_err.handle_result
36
+ OGR::ErrorHandling.handle_ogr_err('Unable to delete field') do
37
+ FFI::OGR::API.OGR_L_DeleteField(@c_pointer, field_id)
38
+ end
32
39
  end
33
40
 
34
- # @param new_order [Array<Fixnum>] An array that orders field indexes by
41
+ # @param new_order [Array<Integer>] An array that orders field indexes by
35
42
  # which they should be reordered. I.e. [0, 2, 3, 1, 4].
36
- # @return [Boolean]
43
+ # @raise [OGR::Failure]
37
44
  def reorder_fields(*new_order)
38
- raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
45
+ unless test_capability('ReorderFields')
46
+ raise OGR::UnsupportedOperation,
47
+ 'This driver does not support field reordering.'
48
+ end
39
49
 
40
- return false if new_order.empty?
41
- return false if new_order.any? { |i| i > feature_definition.field_count }
50
+ return false if new_order.empty? || new_order.any? { |i| i > feature_definition.field_count }
42
51
 
43
52
  map_array_ptr = FFI::MemoryPointer.new(:int, new_order.size).write_array_of_int(new_order)
44
- ogr_err = FFI::OGR::API.OGR_L_ReorderFields(@c_pointer, map_array_ptr)
45
53
 
46
- ogr_err.handle_result
54
+ OGR::ErrorHandling.handle_ogr_err("Unable to reorder fields using order: #{new_order}") do
55
+ FFI::OGR::API.OGR_L_ReorderFields(@c_pointer, map_array_ptr)
56
+ end
47
57
  end
48
58
 
49
59
  # Puts the field whose index is +old_position+ into index at +new_position+
50
60
  # and shuffles the other indexes accordingly.
51
61
  #
52
- # @param old_position [Fixnum]
53
- # @param new_position [Fixnum]
62
+ # @param old_position [Integer]
63
+ # @param new_position [Integer]
64
+ # @raise [OGR::Failure]
54
65
  def reorder_field(old_position, new_position)
55
- raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
56
-
57
- ogr_err = FFI::OGR::API.OGR_L_ReorderField(@c_pointer, old_position, new_position)
66
+ unless test_capability('ReorderFields')
67
+ raise OGR::UnsupportedOperation,
68
+ 'This driver does not support field reordering.'
69
+ end
58
70
 
59
- ogr_err.handle_result
71
+ OGR::ErrorHandling.handle_ogr_err("Unable to reorder field: #{old_position} to #{new_position}") do
72
+ FFI::OGR::API.OGR_L_ReorderField(@c_pointer, old_position, new_position)
73
+ end
60
74
  end
61
75
 
62
- # @param field_index [Fixnum]
76
+ # @param field_index [Integer]
63
77
  # @param new_field_definition [OGR::FieldDefinition] The definition for
64
78
  # which to base the Field at +field_index+ off of.
65
- # @param flags [Fixnum] ALTER_NAME_FLAG, ALTER_TYPE_FLAG,
79
+ # @param flags [Integer] ALTER_NAME_FLAG, ALTER_TYPE_FLAG,
66
80
  # ALTER_WIDTH_PRECISION_FLAG, or ALTER_ALL_FLAG.
81
+ # @raise [OGR::Failure]
67
82
  def alter_field_definition(field_index, new_field_definition, flags)
68
- unless can_alter_field_definition?
83
+ unless test_capability('AlterFieldDefn')
69
84
  raise OGR::UnsupportedOperation, 'This layer does not support field definition altering.'
70
85
  end
71
86
 
72
87
  new_field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, new_field_definition)
73
88
 
74
- ogr_err = FFI::OGR::API.OGR_L_AlterFieldDefn(
75
- @c_pointer,
76
- field_index,
77
- new_field_definition_ptr,
78
- flags
79
- )
80
-
81
- ogr_err.handle_result
89
+ OGR::ErrorHandling.handle_ogr_err("Unable to alter field definition at field index #{field_index}") do
90
+ FFI::OGR::API.OGR_L_AlterFieldDefn(
91
+ @c_pointer,
92
+ field_index,
93
+ new_field_definition_ptr,
94
+ flags
95
+ )
96
+ end
82
97
  end
83
98
 
84
99
  # Finds the index of a field in this Layer.
@@ -86,11 +101,11 @@ module OGR
86
101
  # @param field_name [String]
87
102
  # @param exact_match [Boolean] If +false+ and the field doesn't exist in the
88
103
  # given form, the driver will try to make changes to make a match.
89
- # @return [Fixnum] Index of the field or +nil+ if the field doesn't exist.
90
- def find_field_index(field_name, exact_match = true)
104
+ # @return [Integer] Index of the field or +nil+ if the field doesn't exist.
105
+ def find_field_index(field_name, exact_match: true)
91
106
  result = FFI::OGR::API.OGR_L_FindFieldIndex(@c_pointer, field_name, exact_match)
92
107
 
93
- result < 0 ? nil : result
108
+ result.negative? ? nil : result
94
109
  end
95
110
 
96
111
  # Creates and writes a new geometry to the layer. Note: not all drivers
@@ -99,21 +114,21 @@ module OGR
99
114
  # @param geometry_field_def [OGR::GeometryFieldDefinition] The definition
100
115
  # to use for creating the new field.
101
116
  # @param approx_ok [Boolean]
102
- # @return [Boolean]
103
- def create_geometry_field(geometry_field_def, approx_ok = false)
104
- unless can_create_geometry_field?
117
+ # @raise [OGR::Failure]
118
+ def create_geometry_field(geometry_field_def, approx_ok: false)
119
+ unless test_capability('CreateGeomField')
105
120
  raise OGR::UnsupportedOperation, 'This layer does not support geometry field creation'
106
121
  end
107
122
 
108
123
  geometry_field_definition_ptr = GDAL._pointer(OGR::GeometryFieldDefinition, geometry_field_def)
109
124
 
110
- ogr_err = FFI::OGR::API.OGR_L_CreateGeomField(
111
- @c_pointer,
112
- geometry_field_definition_ptr,
113
- approx_ok
114
- )
115
-
116
- ogr_err.handle_result
125
+ OGR::ErrorHandling.handle_ogr_err('Unable to create geometry field') do
126
+ FFI::OGR::API.OGR_L_CreateGeomField(
127
+ @c_pointer,
128
+ geometry_field_definition_ptr,
129
+ approx_ok
130
+ )
131
+ end
117
132
  end
118
133
 
119
134
  # If the driver supports this functionality, it will not fetch the
@@ -121,14 +136,15 @@ module OGR
121
136
  # thus save some processing time and/or bandwidth.
122
137
  #
123
138
  # @param field_names [Array<String>]
124
- # @return [Boolean]
139
+ # @raise [OGR::Failure]
125
140
  def set_ignored_fields(*field_names)
126
141
  return false if field_names.empty?
127
142
 
128
143
  fields_ptr = GDAL._string_array_to_pointer(field_names)
129
- ogr_err = FFI::OGR::API.OGR_L_SetIgnoredFields(@c_pointer, fields_ptr)
130
144
 
131
- ogr_err.handle_result "Unable to ignore fields with names: #{field_names}"
145
+ OGR::ErrorHandling.handle_ogr_err("Unable to ignore fields with names: #{field_names}") do
146
+ FFI::OGR::API.OGR_L_SetIgnoredFields(@c_pointer, fields_ptr)
147
+ end
132
148
  end
133
149
  end
134
150
  end
@@ -22,6 +22,7 @@ module OGR
22
22
  # that will be created from the fields of the input Layer.
23
23
  # @option options [String] method_prefix Set a prefix for the field names
24
24
  # that will be created from the fields of the method Layer.
25
+ # @raise [OGR::Failure]
25
26
  def clip(method_layer, output_layer, **options, &progress)
26
27
  run_layer_method(:OGR_L_Clip, method_layer, output_layer, **options, &progress)
27
28
  end
@@ -42,6 +43,7 @@ module OGR
42
43
  # that will be created from the fields of the input Layer.
43
44
  # @option options [String] method_prefix Set a prefix for the field names
44
45
  # that will be created from the fields of the method Layer.
46
+ # @raise [OGR::Failure]
45
47
  def erase(method_layer, output_layer, **options, &progress)
46
48
  run_layer_method(:OGR_L_Erase, method_layer, output_layer, **options, &progress)
47
49
  end
@@ -60,6 +62,7 @@ module OGR
60
62
  # that will be created from the fields of the input Layer.
61
63
  # @option options [String] method_prefix Set a prefix for the field names
62
64
  # that will be created from the fields of the method Layer.
65
+ # @raise [OGR::Failure]
63
66
  def identity(method_layer, output_layer, **options, &progress)
64
67
  run_layer_method(:OGR_L_Identity, method_layer, output_layer, **options, &progress)
65
68
  end
@@ -76,6 +79,7 @@ module OGR
76
79
  # that will be created from the fields of the input Layer.
77
80
  # @option options [String] method_prefix Set a prefix for the field names
78
81
  # that will be created from the fields of the method Layer.
82
+ # @raise [OGR::Failure]
79
83
  def intersection(method_layer, output_layer, **options, &progress)
80
84
  run_layer_method(:OGR_L_Intersection, method_layer, output_layer, **options, &progress)
81
85
  end
@@ -97,6 +101,7 @@ module OGR
97
101
  # that will be created from the fields of the input Layer.
98
102
  # @option options [String] method_prefix Set a prefix for the field names
99
103
  # that will be created from the fields of the method Layer.
104
+ # @raise [OGR::Failure]
100
105
  def symmetrical_difference(method_layer, output_layer, **options, &progress)
101
106
  run_layer_method(:OGR_L_SymDifference, method_layer, output_layer, **options, &progress)
102
107
  end
@@ -117,6 +122,7 @@ module OGR
117
122
  # that will be created from the fields of the input Layer.
118
123
  # @option options [String] method_prefix Set a prefix for the field names
119
124
  # that will be created from the fields of the method Layer.
125
+ # @raise [OGR::Failure]
120
126
  def union(method_layer, output_layer, **options, &progress)
121
127
  run_layer_method(:OGR_L_Union, method_layer, output_layer, **options, &progress)
122
128
  end
@@ -138,25 +144,28 @@ module OGR
138
144
  # that will be created from the fields of the input Layer.
139
145
  # @option options [String] method_prefix Set a prefix for the field names
140
146
  # that will be created from the fields of the method Layer.
147
+ # @raise [OGR::Failure]
141
148
  def update(method_layer, output_layer, **options, &progress)
142
149
  run_layer_method(:OGR_L_Update, method_layer, output_layer, **options, &progress)
143
150
  end
144
151
 
145
152
  private
146
153
 
154
+ # @raise [OGR::Failure]
147
155
  def run_layer_method(method_name, method_layer, output_layer, **options, &progress)
148
156
  method_layer_ptr = GDAL._pointer(OGR::Layer, method_layer)
149
157
  options_ptr = GDAL::Options.pointer(options)
150
158
  result_layer_ptr = output_layer.c_pointer
151
159
 
152
- ogr_err = FFI::OGR::API.send(method_name,
153
- @c_pointer,
154
- method_layer_ptr,
155
- result_layer_ptr,
156
- options_ptr,
157
- progress,
158
- nil)
159
- ogr_err.handle_result
160
+ OGR::ErrorHandling.handle_ogr_err("Unable to run layer method '#{method_name}'") do
161
+ FFI::OGR::API.send(method_name,
162
+ @c_pointer,
163
+ method_layer_ptr,
164
+ result_layer_ptr,
165
+ options_ptr,
166
+ progress,
167
+ nil)
168
+ end
160
169
 
161
170
  output_layer
162
171
  end
@@ -23,7 +23,7 @@ module OGR
23
23
 
24
24
  # Only feature which intersect the filter geometry will be returned.
25
25
  #
26
- # @param geometry_field_index [Fixnum] The spatial filter operates on this
26
+ # @param geometry_field_index [Integer] The spatial filter operates on this
27
27
  # geometry field.
28
28
  # @param geometry [OGR::Geometry] Use this geometry as the filtering
29
29
  # region.
@@ -60,7 +60,7 @@ module OGR
60
60
  # from #set_spatial_filter_rectangle). To clear the filter, set
61
61
  # #spatial_filter = nil.
62
62
  #
63
- # @param geometry_field_index [Fixnum]
63
+ # @param geometry_field_index [Integer]
64
64
  # @param min_x [Float]
65
65
  # @param min_y [Float]
66
66
  # @param max_x [Float]
@@ -82,10 +82,11 @@ module OGR
82
82
  #
83
83
  # @param query [String]
84
84
  # @see http://ogdi.sourceforge.net/prop/6.2.CapabilitiesMetadata.html
85
- def set_attribute_filter(query)
86
- ogr_err = FFI::OGR::API.OGR_L_SetAttributeFilter(@c_pointer, query)
87
-
88
- ogr_err.handle_result
85
+ # @raise [OGR::Failure]
86
+ def set_attribute_filter(query) # rubocop:disable Naming/AccessorMethodName
87
+ OGR::ErrorHandling.handle_ogr_err("Unable to set attribute filter: #{query}") do
88
+ FFI::OGR::API.OGR_L_SetAttributeFilter(@c_pointer, query)
89
+ end
89
90
  end
90
91
  end
91
92
  end
@@ -3,17 +3,17 @@
3
3
  module OGR
4
4
  module LayerMixins
5
5
  module OGRSQLMethods
6
- # @return [Boolean]
6
+ # @raise [OGR::Failure]
7
7
  def start_transaction
8
8
  transact { FFI::OGR::API.OGR_L_StartTransaction(@c_pointer) }
9
9
  end
10
10
 
11
- # @return [Boolean]
11
+ # @raise [OGR::Failure]
12
12
  def commit_transaction
13
13
  transact { FFI::OGR::API.OGR_L_CommitTransaction(@c_pointer) }
14
14
  end
15
15
 
16
- # @return [Boolean]
16
+ # @raise [OGR::Failure]
17
17
  def rollback_transaction
18
18
  transact { FFI::OGR::API.OGR_L_RollbackTransaction(@c_pointer) }
19
19
  end
@@ -22,7 +22,10 @@ module OGR
22
22
  #
23
23
  # @return [String]
24
24
  def fid_column
25
- FFI::OGR::API.OGR_L_GetFIDColumn(@c_pointer)
25
+ name, ptr = FFI::OGR::API.OGR_L_GetFIDColumn(@c_pointer)
26
+ ptr.autorelease = false
27
+
28
+ name
26
29
  end
27
30
 
28
31
  # The name of the underlying database column being used as the geometry
@@ -30,18 +33,23 @@ module OGR
30
33
  #
31
34
  # @return [String]
32
35
  def geometry_column
33
- FFI::OGR::API.OGR_L_GetGeometryColumn(@c_pointer)
36
+ name, ptr = FFI::OGR::API.OGR_L_GetGeometryColumn(@c_pointer)
37
+ ptr.autorelease = false
38
+
39
+ name
34
40
  end
35
41
 
36
42
  private
37
43
 
38
- # @return [Boolean]
44
+ # @raise [OGR::Failure]
39
45
  def transact
40
46
  raise OGR::UnsupportedOperation, 'This layer does not support transactions.' unless supports_transactions?
41
47
 
42
48
  ogr_err = yield
43
49
 
44
- ogr_err.handle_result
50
+ OGR::ErrorHandling.handle_ogr_err('Unable to set geometry directly on feature') do
51
+ ogr_err
52
+ end
45
53
  end
46
54
  end
47
55
  end