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,135 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/driver'
5
- require 'gdal/raster_band'
6
-
7
- RSpec.describe 'GDAL::RasterBandMixins::IOExtensions' do
8
- let(:driver) { GDAL::Driver.by_name('MEM') }
9
- let(:dataset_byte) { driver.create_dataset('test', 15, 25, data_type: :GDT_Byte) }
10
- let(:dataset_int16) { driver.create_dataset('test', 15, 25, data_type: :GDT_Int16) }
11
- let(:dataset_uint16) { driver.create_dataset('test', 15, 25, data_type: :GDT_UInt16) }
12
- let(:dataset_int32) { driver.create_dataset('test', 15, 25, data_type: :GDT_Int32) }
13
- let(:dataset_uint32) { driver.create_dataset('test', 15, 25, data_type: :GDT_UInt32) }
14
- let(:dataset_float32) { driver.create_dataset('test', 15, 25, data_type: :GDT_Float32) }
15
- let(:dataset_float64) { driver.create_dataset('test', 15, 25, data_type: :GDT_Float64) }
16
-
17
- subject(:raster_band) { dataset_byte.raster_band(1) }
18
-
19
- describe '#write_xy_narray' do
20
- let(:dataset) { driver.create_dataset('test dataset', 64, 4) }
21
- let(:raster_band) { dataset.raster_band 1 }
22
-
23
- it 'writes pixels from the NArray' do
24
- row0 = Array.new(64) { 1 }
25
- row1 = Array.new(64) { 2 }
26
- row2 = Array.new(64) { 3 }
27
- row3 = Array.new(64) { 4 }
28
- narray = NArray[row0, row1, row2, row3]
29
-
30
- raster_band.write_xy_narray(narray)
31
-
32
- pixels = raster_band.to_na
33
- expect(pixels[true, 0]).to eq(NArray.to_na(row0))
34
- expect(pixels[true, 1]).to eq(NArray.to_na(row1))
35
- expect(pixels[true, 2]).to eq(NArray.to_na(row2))
36
- expect(pixels[true, 3]).to eq(NArray.to_na(row3))
37
- end
38
- end
39
-
40
- describe '#set_pixel_value/#pixel_value' do
41
- context 'valid values, GDT_Byte' do
42
- it 'sets and gets the value successfully' do
43
- subject.set_pixel_value(0, 0, 123)
44
- expect(subject.pixel_value(0, 0)).to eq(123)
45
- end
46
- end
47
-
48
- context 'valid values, GDT_Int16' do
49
- subject { dataset_int16.raster_band(1) }
50
-
51
- it 'sets and gets the value successfully' do
52
- subject.set_pixel_value(0, 0, -12_345)
53
- expect(subject.pixel_value(0, 0)).to eq(-12_345)
54
- end
55
- end
56
-
57
- context 'valid values, GDT_UInt16' do
58
- subject { dataset_uint16.raster_band(1) }
59
-
60
- it 'sets and gets the value successfully' do
61
- subject.set_pixel_value(0, 0, 32_123)
62
- expect(subject.pixel_value(0, 0)).to eq(32_123)
63
- end
64
- end
65
-
66
- context 'valid values, GDT_Int32' do
67
- subject { dataset_int32.raster_band(1) }
68
-
69
- it 'sets and gets the value successfully' do
70
- subject.set_pixel_value(0, 0, -123_456_789)
71
- expect(subject.pixel_value(0, 0)).to eq(-123_456_789)
72
- end
73
- end
74
-
75
- context 'valid values, GDT_UInt32' do
76
- subject { dataset_uint32.raster_band(1) }
77
-
78
- it 'sets and gets the value successfully' do
79
- subject.set_pixel_value(0, 0, 4_123_456_789)
80
- expect(subject.pixel_value(0, 0)).to eq(4_123_456_789)
81
- end
82
- end
83
-
84
- context 'valid values, GDT_Float32' do
85
- subject { dataset_float32.raster_band(1) }
86
-
87
- # For some reason, precision of float32 values isn't there past a couple
88
- # decimals when reading back.
89
- it 'sets and gets the value successfully' do
90
- subject.set_pixel_value(0, 0, -123.456)
91
- expect(subject.pixel_value(0, 0)).to be_within(0.001).of(-123.456)
92
- end
93
- end
94
-
95
- context 'valid values, GDT_Float64' do
96
- subject { dataset_float64.raster_band(1) }
97
-
98
- it 'sets and gets the value successfully' do
99
- subject.set_pixel_value(0, 0, -123_456_789_101.456)
100
- expect(subject.pixel_value(0, 0)).to eq(-123_456_789_101.456)
101
- end
102
- end
103
- end
104
-
105
- describe '#block_count' do
106
- it 'returns a Hash of relevant values' do
107
- expect(subject.block_count).to eq(
108
- x: 1,
109
- x_remainder: 0,
110
- y: 25,
111
- y_remainder: 0
112
- )
113
- end
114
- end
115
-
116
- describe '#block_buffer_size' do
117
- subject { raster_band.block_buffer_size }
118
- it { is_expected.to eq(15) }
119
- end
120
-
121
- describe '#read_lines_by_block' do
122
- context 'block is given' do
123
- it 'yields each row of pixels' do
124
- expect { |b| subject.read_lines_by_block(&b) }.
125
- to yield_successive_args(*Array.new(25, Array.new(15, 0)))
126
- end
127
- end
128
-
129
- context 'no block given' do
130
- it 'returns an Enumerator' do
131
- expect(subject.read_lines_by_block).to be_a(Enumerator)
132
- end
133
- end
134
- end
135
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/raster_band'
5
-
6
- RSpec.describe GDAL::RasterBand do
7
- pending 'Add some tests!'
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/rpc_info'
5
-
6
- RSpec.describe GDAL::RPCInfo do
7
- pending 'Add some tests!'
8
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/version_info'
5
-
6
- RSpec.describe GDAL::VersionInfo do
7
- subject { Object.new.extend(described_class) }
8
-
9
- pending 'Add some tests!'
10
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/virtual_dataset'
5
- require 'gdal/dataset'
6
-
7
- RSpec.describe GDAL::VirtualDataset do
8
- subject(:virtual_dataset) { described_class.new(300, 200) }
9
-
10
- describe '#initialize' do
11
- it { is_expected.to be_a GDAL::VirtualDataset }
12
- end
13
-
14
- describe '#flush_cache' do
15
- it 'does something' do
16
- subject.flush_cache
17
- end
18
- end
19
-
20
- describe '#to_xml' do
21
- it 'returns a String' do
22
- expect(subject.to_xml).to be_a String
23
- expect(subject.to_xml.size).to be > 0
24
- end
25
- end
26
-
27
- describe '#add_band' do
28
- context 'valid data type' do
29
- it "lets you add a real dataset's raster band to it" do
30
- expect(subject.add_band(:GDT_Byte)).to eq 0
31
- end
32
- end
33
- end
34
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/warp_operation'
5
-
6
- RSpec.describe GDAL::WarpOperation do
7
- pending 'Add some tests!'
8
- end
@@ -1,338 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'gdal/warp_options'
5
-
6
- RSpec.describe GDAL::WarpOptions do
7
- shared_examples 'a WarpOptions object' do
8
- it 'inits proper types' do
9
- expect(subject.warp_operation_options).to be_a Hash
10
-
11
- expect(subject.source_bands).to be_a Array
12
- expect(subject.destination_bands).to be_a Array
13
-
14
- expect(subject.source_no_data_real).to be_a Array
15
- expect(subject.source_no_data_imaginary).to be_a Array
16
- expect(subject.destination_no_data_real).to be_a Array
17
- expect(subject.destination_no_data_imaginary).to be_a Array
18
-
19
- expect(subject.progress).to be_a FFI::Function
20
- expect(subject.progress_arg).to be_a FFI::Pointer
21
- expect(subject.transformer).to be_a FFI::Function
22
- expect(subject.transformer_arg).to be_a FFI::Pointer
23
-
24
- expect(subject.source_per_band_validity_mask_function).to be_a FFI::Pointer
25
- expect(subject.source_per_band_validity_mask_function_arg).to be_a FFI::Pointer
26
- expect(subject.source_validity_mask_function).to be_a FFI::Function
27
- expect(subject.source_validity_mask_function_arg).to be_a FFI::Pointer
28
- expect(subject.source_density_mask_function).to be_a FFI::Function
29
- expect(subject.source_density_mask_function_arg).to be_a FFI::Pointer
30
-
31
- expect(subject.destination_density_mask_function).to be_a FFI::Function
32
- expect(subject.destination_density_mask_function_arg).to be_a FFI::Pointer
33
- expect(subject.destination_validity_mask_function).to be_a FFI::Function
34
- expect(subject.destination_validity_mask_function_arg).to be_a FFI::Pointer
35
-
36
- expect(subject.pre_warp_chunk_processor).to be_a FFI::Function
37
- expect(subject.pre_warp_processor_arg).to be_a FFI::Pointer
38
- expect(subject.post_warp_chunk_processor).to be_a FFI::Function
39
- expect(subject.post_warp_processor_arg).to be_a FFI::Pointer
40
- end
41
- end
42
-
43
- describe '#initialize' do
44
- context 'with no options' do
45
- it_behaves_like 'a WarpOptions object'
46
-
47
- it 'inits a FFI::GDAL::WarpOptions struct internally, with nothing set' do
48
- expect(subject.warp_operation_options).to eq({})
49
-
50
- expect(subject.warp_memory_limit).to be_zero
51
- expect(subject.resample_alg).to eq(:GRA_NearestNeighbor) # 0 enum
52
- expect(subject.working_data_type).to eq(:GDT_Unknown) # 0 enum
53
-
54
- expect(subject.source_dataset).to be_nil
55
- expect(subject.destination_dataset).to be_nil
56
-
57
- expect(subject.band_count).to be_zero
58
- expect(subject.source_bands).to be_empty
59
- expect(subject.destination_bands).to be_empty
60
-
61
- expect(subject.source_alpha_band).to be_zero
62
- expect(subject.destination_alpha_band).to be_zero
63
-
64
- expect(subject.source_no_data_real).to eq([])
65
- expect(subject.source_no_data_imaginary).to eq([])
66
- expect(subject.destination_no_data_real).to eq([])
67
- expect(subject.destination_no_data_imaginary).to eq([])
68
-
69
- expect(subject.progress).to_not be_null
70
- expect(subject.progress_arg).to be_null
71
-
72
- expect(subject.transformer).to be_null
73
- expect(subject.transformer_arg).to be_null
74
-
75
- expect(subject.source_per_band_validity_mask_function).to be_null
76
- expect(subject.source_per_band_validity_mask_function_arg).to be_null
77
-
78
- expect(subject.source_validity_mask_function).to be_null
79
- expect(subject.source_validity_mask_function_arg).to be_null
80
-
81
- expect(subject.source_density_mask_function).to be_null
82
- expect(subject.source_density_mask_function_arg).to be_null
83
-
84
- expect(subject.destination_density_mask_function).to be_null
85
- expect(subject.destination_density_mask_function_arg).to be_null
86
-
87
- expect(subject.destination_validity_mask_function).to be_null
88
- expect(subject.destination_validity_mask_function_arg).to be_null
89
-
90
- expect(subject.pre_warp_chunk_processor).to be_null
91
- expect(subject.pre_warp_processor_arg).to be_null
92
- expect(subject.post_warp_chunk_processor).to be_null
93
- expect(subject.post_warp_processor_arg).to be_null
94
-
95
- expect(subject.cutline).to be_nil
96
- expect(subject.cutline_blend_distance).to eq(0.0)
97
- end
98
- end
99
-
100
- context 'passing in options that are also accessor methods' do
101
- let(:warp_operation_options) do
102
- {
103
- init_dest: 'NODATA',
104
- write_flush: 'YES',
105
- skip_nosource: 'NO',
106
- sample_grid: 'YES'
107
- }
108
- end
109
-
110
- let(:memory_driver) { GDAL::Driver.by_name('MEM') }
111
- let(:source_dataset) { memory_driver.create_dataset 'source', 10, 20 }
112
- let(:dest_dataset) { memory_driver.create_dataset 'dest', 20, 30 }
113
- let(:cutline) { OGR::LineString.new }
114
- let(:spb_validity_mask_function1) { proc { true } }
115
- let(:spb_validity_mask_function2) { proc { false } }
116
-
117
- after do
118
- source_dataset.close
119
- dest_dataset.close
120
- end
121
-
122
- subject do
123
- described_class.new warp_operation_options: warp_operation_options,
124
- source_dataset: source_dataset,
125
- destination_dataset: dest_dataset,
126
- source_bands: [1, 2, 3],
127
- destination_bands: [2, 4, 6],
128
- cutline: cutline,
129
- source_no_data_real: [123.456, 78.9, -999.9],
130
- source_no_data_imaginary: [1.2, 3.4, -5.6],
131
- destination_no_data_real: [11.1, 22.2, 33.3],
132
- destination_no_data_imaginary: [-44.4, -55.5, -66.6],
133
- source_per_band_validity_mask_function: [
134
- spb_validity_mask_function1,
135
- spb_validity_mask_function2
136
- ]
137
- end
138
-
139
- it_behaves_like 'a WarpOptions object'
140
-
141
- it 'sets warp_operation_options' do
142
- expect(subject.warp_operation_options).to eq(warp_operation_options)
143
- end
144
-
145
- it' sets source_dataset and the internal pointer' do
146
- expect(subject.source_dataset).to eq(source_dataset)
147
- expect(subject.c_struct[:source_dataset]).to eq(source_dataset.c_pointer)
148
- end
149
-
150
- it' sets destination_dataset' do
151
- expect(subject.destination_dataset).to eq(dest_dataset)
152
- expect(subject.c_struct[:destination_dataset]).to eq(dest_dataset.c_pointer)
153
- end
154
-
155
- it 'sets source_bands' do
156
- expect(subject.source_bands).to eq([1, 2, 3])
157
- end
158
-
159
- it 'sets destination_bands' do
160
- expect(subject.destination_bands).to eq([2, 4, 6])
161
- end
162
-
163
- it 'sets band_count and the internal to 3' do
164
- expect(subject.band_count).to eq 3
165
- expect(subject.c_struct[:band_count]).to eq 3
166
- end
167
-
168
- it 'sets cutline and its internal pointer' do
169
- expect(subject.cutline).to eq(cutline)
170
- expect(subject.c_struct[:cutline]).to eq(cutline.c_pointer)
171
- end
172
-
173
- it 'sets source_no_data_real' do
174
- expect(subject.source_no_data_real).to eq([123.456, 78.9, -999.9])
175
- end
176
-
177
- it 'sets source_no_data_imaginary' do
178
- expect(subject.source_no_data_imaginary).to eq([1.2, 3.4, -5.6])
179
- end
180
-
181
- it 'sets destination_no_data_real' do
182
- expect(subject.destination_no_data_real).to eq([11.1, 22.2, 33.3])
183
- end
184
-
185
- it 'sets destination_no_data_imaginary' do
186
- expect(subject.destination_no_data_imaginary).to eq([-44.4, -55.5, -66.6])
187
- end
188
-
189
- it 'sets source_per_band_validity_mask_function' do
190
- function_ptr = subject.source_per_band_validity_mask_function
191
- expect(function_ptr).to be_a(FFI::Pointer)
192
-
193
- function = function_ptr.read_pointer
194
- expect(function).to_not be_null
195
- end
196
- end
197
-
198
- context 'passing in options that are NOT accessor methods' do
199
- def make_int_pointer(int)
200
- i = FFI::MemoryPointer.new(:int)
201
- i.write_int(int)
202
- i
203
- end
204
-
205
- let(:progress) { proc { true } }
206
- let(:test_mask_function) { proc { true } }
207
-
208
- let(:source_per_band_validity_mask_function_arg) { make_int_pointer(5) }
209
- let(:source_validity_mask_function_arg) { make_int_pointer(3) }
210
- let(:source_density_mask_function_arg) { make_int_pointer(2) }
211
- let(:destination_validity_mask_function_arg) { make_int_pointer(4) }
212
- let(:destination_density_mask_function_arg) { make_int_pointer(11) }
213
- let(:pre_warp_processor_arg) { make_int_pointer(7) }
214
- let(:post_warp_processor_arg) { make_int_pointer(9) }
215
-
216
- subject do
217
- described_class.new warp_memory_limit: 123,
218
- resample_alg: :GRA_Lanczos,
219
- working_data_type: :GDT_CInt32,
220
- band_count: 3,
221
- source_alpha_band: 1,
222
- destination_alpha_band: 5,
223
- progress: progress,
224
- progress_arg: FFI::CPL::Progress::ScaledProgress,
225
- source_per_band_validity_mask_function_arg: source_per_band_validity_mask_function_arg,
226
- source_validity_mask_function: test_mask_function,
227
- source_validity_mask_function_arg: source_validity_mask_function_arg,
228
- source_density_mask_function: test_mask_function,
229
- source_density_mask_function_arg: source_density_mask_function_arg,
230
- destination_validity_mask_function: test_mask_function,
231
- destination_validity_mask_function_arg: destination_validity_mask_function_arg,
232
- destination_density_mask_function: test_mask_function,
233
- destination_density_mask_function_arg: destination_density_mask_function_arg,
234
- pre_warp_chunk_processor: proc { :CE_Warning },
235
- pre_warp_processor_arg: pre_warp_processor_arg,
236
- post_warp_chunk_processor: proc { :CE_Failure },
237
- post_warp_processor_arg: post_warp_processor_arg,
238
- cutline_blend_distance: 3.3
239
- end
240
-
241
- it_behaves_like 'a WarpOptions object'
242
-
243
- it 'sets warp_memory_limit' do
244
- expect(subject.warp_memory_limit).to eq(123)
245
- end
246
-
247
- it 'sets resample_alg' do
248
- expect(subject.resample_alg).to eq(:GRA_Lanczos)
249
- end
250
-
251
- it 'sets working_data_type' do
252
- expect(subject.working_data_type).to eq(:GDT_CInt32)
253
- end
254
-
255
- it 'sets band_count' do
256
- expect(subject.band_count).to eq(3)
257
- end
258
-
259
- it 'sets source_alpha_band' do
260
- expect(subject.source_alpha_band).to eq(1)
261
- end
262
-
263
- it 'sets destination_alpha_band' do
264
- expect(subject.destination_alpha_band).to eq(5)
265
- end
266
-
267
- it 'sets progress_arg' do
268
- expect(subject.progress_arg).to eq(FFI::CPL::Progress::ScaledProgress)
269
- end
270
-
271
- it 'sets source_per_band_validity_mask_function_arg' do
272
- pointer = subject.source_per_band_validity_mask_function_arg
273
- pointer.autorelease = false
274
- expect(pointer.read_int).to eq 5
275
- end
276
-
277
- it 'sets source_validity_mask_function' do
278
- expect(subject.source_validity_mask_function).to_not be_null
279
- end
280
-
281
- it 'sets source_validity_mask_function_arg' do
282
- pointer = subject.source_validity_mask_function_arg
283
- pointer.autorelease = false
284
- expect(pointer.read_int).to eq 3
285
- end
286
-
287
- it 'sets source_density_mask_function' do
288
- expect(subject.source_density_mask_function).to_not be_null
289
- end
290
-
291
- it 'sets source_density_mask_function_arg' do
292
- pointer = subject.source_density_mask_function_arg
293
- pointer.autorelease = false
294
- expect(pointer.read_int).to eq 2
295
- end
296
-
297
- it 'sets destination_validity_mask_function' do
298
- expect(subject.destination_validity_mask_function).to_not be_null
299
- end
300
-
301
- it 'sets destination_validity_mask_function_arg' do
302
- pointer = subject.destination_validity_mask_function_arg
303
- pointer.autorelease = false
304
- expect(pointer.read_int).to eq 4
305
- end
306
-
307
- it 'sets destination_density_mask_function' do
308
- expect(subject.destination_density_mask_function).to_not be_null
309
- end
310
-
311
- it 'sets destination_density_mask_function_arg' do
312
- pointer = subject.destination_density_mask_function_arg
313
- pointer.autorelease = false
314
- expect(pointer.read_int).to eq 11
315
- end
316
-
317
- it 'sets pre_warp_chunk_processor' do
318
- expect(subject.pre_warp_chunk_processor.call(nil, nil)).to eq(:CE_Warning)
319
- end
320
-
321
- it 'sets pre_warp_chunk_processor_arg' do
322
- expect(subject.pre_warp_processor_arg).to_not be_null
323
- end
324
-
325
- it 'sets post_warp_chunk_processor' do
326
- expect(subject.post_warp_chunk_processor.call(nil, nil)).to eq(:CE_Failure)
327
- end
328
-
329
- it 'sets post_warp_chunk_processor_arg' do
330
- expect(subject.post_warp_processor_arg).to_not be_null
331
- end
332
-
333
- it 'sets cutline_blend_distance' do
334
- expect(subject.cutline_blend_distance).to eq(3.3)
335
- end
336
- end
337
- end
338
- end
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/coordinate_transformation'
5
-
6
- RSpec.describe OGR::CoordinateTransformation do
7
- let(:source_srs) { OGR::SpatialReference.new_from_epsg(3857) }
8
- let(:dest_srs) { OGR::SpatialReference.new_from_epsg(4326) }
9
-
10
- # From https://epsg.io/3857
11
- let(:epsg4326_y_bounds) { [-85.06, 85.06] }
12
- let(:epsg4326_x_bounds) { [-180.0, 180.0] }
13
- let(:epsg3857_y_bounds) { [-20_048_966.10, 20_048_966.10] }
14
- let(:epsg3857_x_bounds) { [-20_026_376.39, 20_026_376.39] }
15
-
16
- subject { described_class.new(source_srs, dest_srs) }
17
-
18
- describe '.proj4_normalize' do
19
- context 'OCTProj4Normalize not supported' do
20
- it 'raises a OGR::UnsupportedOperation' do
21
- expect { described_class.proj4_normalize('asdf') }.to raise_exception(OGR::UnsupportedOperation)
22
- end
23
- end
24
- end
25
-
26
- describe '#initialize' do
27
- context 'source_srs is not an OGR::SpatialReference' do
28
- it 'raises an OGR::Failure' do
29
- expect { described_class.new(123, dest_srs) }.to raise_exception(OGR::Failure)
30
- end
31
- end
32
-
33
- context 'dest_srs is not an OGR::SpatialReference' do
34
- it 'raises an OGR::Failure' do
35
- expect { described_class.new(source_srs, 123) }.to raise_exception(OGR::Failure)
36
- end
37
- end
38
-
39
- context 'source_srs and dest_srs are valid OGR::SpatialReference objects' do
40
- it 'creates a new object with @c_pointer set' do
41
- instance = described_class.new(source_srs, dest_srs)
42
- expect(instance).to be_a described_class
43
- expect(instance.c_pointer).to be_a FFI::Pointer
44
- end
45
- end
46
- end
47
-
48
- describe '#destroy!' do
49
- it 'sets @c_pointer to nil' do
50
- subject.destroy!
51
- expect(subject.c_pointer).to be_nil
52
- end
53
- end
54
-
55
- describe '#transform' do
56
- context 'no z_vertices, valid x and y vertices' do
57
- it 'transforms the points' do
58
- result = subject.transform(epsg3857_x_bounds, epsg3857_y_bounds)
59
-
60
- transformed_x_points = result.first
61
- transformed_y_points = result.last
62
-
63
- expect(transformed_x_points.first).to be_within(0.11).of(epsg4326_x_bounds.first)
64
- expect(transformed_x_points.last).to be_within(0.11).of(epsg4326_x_bounds.last)
65
- expect(transformed_y_points.first).to be_within(0.001).of(epsg4326_y_bounds.first)
66
- expect(transformed_y_points.last).to be_within(0.001).of(epsg4326_y_bounds.last)
67
- end
68
- end
69
-
70
- context 'valid x, y, and z vertices' do
71
- it 'transforms the points' do
72
- result = subject.transform(epsg3857_x_bounds, epsg3857_y_bounds, [10_000, -299])
73
-
74
- transformed_x_points = result.first
75
- transformed_y_points = result[1]
76
- transformed_z_points = result.last
77
-
78
- expect(transformed_x_points.first).to be_within(0.11).of(epsg4326_x_bounds.first)
79
- expect(transformed_x_points.last).to be_within(0.11).of(epsg4326_x_bounds.last)
80
- expect(transformed_y_points.first).to be_within(0.001).of(epsg4326_y_bounds.first)
81
- expect(transformed_y_points.last).to be_within(0.001).of(epsg4326_y_bounds.last)
82
- expect(transformed_z_points.first).to eq(10_000)
83
- expect(transformed_z_points.last).to eq(-299)
84
- end
85
- end
86
- end
87
-
88
- describe '#transform_ex' do
89
- context 'no z_vertices, valid x and y vertices' do
90
- it 'transforms the points' do
91
- result = subject.transform_ex(epsg3857_x_bounds, epsg3857_y_bounds)
92
-
93
- transformed_x_points = result[:points].first
94
- transformed_y_points = result[:points].last
95
-
96
- expect(transformed_x_points.first).to be_within(0.11).of(epsg4326_x_bounds.first)
97
- expect(transformed_x_points.last).to be_within(0.11).of(epsg4326_x_bounds.last)
98
- expect(transformed_y_points.first).to be_within(0.001).of(epsg4326_y_bounds.first)
99
- expect(transformed_y_points.last).to be_within(0.001).of(epsg4326_y_bounds.last)
100
- expect(result[:successes]).to eq([true, false])
101
- end
102
- end
103
- end
104
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'ogr/data_source'
5
-
6
- RSpec.describe OGR::DataSource do
7
- context 'Memory datasource' do
8
- subject(:data_source) do
9
- OGR::Driver.by_name('Memory').create_data_source('test')
10
- end
11
-
12
- describe '#can_create_layer?' do
13
- subject { data_source.can_create_layer? }
14
- it { is_expected.to eq true }
15
- end
16
-
17
- describe '#can_delete_layer?' do
18
- subject { data_source.can_delete_layer? }
19
- it { is_expected.to eq true }
20
- end
21
-
22
- describe '#can_create_geometry_field_after_create_layer?' do
23
- subject { data_source.can_create_geometry_field_after_create_layer? }
24
- it { is_expected.to eq true }
25
- end
26
-
27
- describe '#supports_curve_geometries?' do
28
- subject { data_source.supports_curve_geometries? }
29
- it { is_expected.to eq true }
30
- end
31
- end
32
- end