ffi-gdal 1.0.0.beta6 → 1.0.0.beta11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +54 -19
  3. data/.rubocop_todo.yml +65 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -0
  6. data/History.md +74 -0
  7. data/README.md +5 -0
  8. data/Rakefile +11 -1
  9. data/bitbucket-pipelines.yml +16 -0
  10. data/examples/extract_and_colorize.rb +7 -10
  11. data/examples/geometries.rb +68 -1
  12. data/examples/gridding.rb +2 -0
  13. data/examples/ogr_layer_to_layer.rb +2 -0
  14. data/examples/raster_erasing.rb +15 -8
  15. data/examples/remove_small_polygons.rb +2 -0
  16. data/examples/testing_gdal.rb +9 -2
  17. data/examples/warping.rb +23 -5
  18. data/ffi-gdal.gemspec +7 -4
  19. data/lib/ext/error_symbols.rb +2 -0
  20. data/lib/ext/ffi_library_function_checks.rb +2 -0
  21. data/lib/ext/float_ext.rb +2 -0
  22. data/lib/ext/narray_ext.rb +2 -0
  23. data/lib/ext/numeric_as_data_type.rb +2 -0
  24. data/lib/ext/to_bool.rb +5 -3
  25. data/lib/ffi-gdal.rb +2 -0
  26. data/lib/ffi/cpl.rb +2 -0
  27. data/lib/ffi/cpl/conv.rb +4 -2
  28. data/lib/ffi/cpl/error.rb +2 -0
  29. data/lib/ffi/cpl/hash_set.rb +2 -0
  30. data/lib/ffi/cpl/http.rb +2 -0
  31. data/lib/ffi/cpl/http_result.rb +2 -0
  32. data/lib/ffi/cpl/list.rb +2 -0
  33. data/lib/ffi/cpl/mime_part.rb +2 -0
  34. data/lib/ffi/cpl/minixml.rb +2 -0
  35. data/lib/ffi/cpl/port.rb +2 -0
  36. data/lib/ffi/cpl/progress.rb +2 -0
  37. data/lib/ffi/cpl/quad_tree.rb +2 -0
  38. data/lib/ffi/cpl/rect_obj.rb +2 -0
  39. data/lib/ffi/cpl/string.rb +2 -0
  40. data/lib/ffi/cpl/vsi.rb +2 -0
  41. data/lib/ffi/cpl/xml_node.rb +2 -0
  42. data/lib/ffi/gdal.rb +3 -3
  43. data/lib/ffi/gdal/alg.rb +2 -0
  44. data/lib/ffi/gdal/color_entry.rb +2 -0
  45. data/lib/ffi/gdal/exceptions.rb +2 -0
  46. data/lib/ffi/gdal/gcp.rb +2 -0
  47. data/lib/ffi/gdal/gdal.rb +2 -0
  48. data/lib/ffi/gdal/grid.rb +2 -0
  49. data/lib/ffi/gdal/grid_data_metrics_options.rb +2 -0
  50. data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +2 -0
  51. data/lib/ffi/gdal/grid_moving_average_options.rb +2 -0
  52. data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +2 -0
  53. data/lib/ffi/gdal/matching.rb +2 -0
  54. data/lib/ffi/gdal/rpc_info.rb +2 -0
  55. data/lib/ffi/gdal/transformer_info.rb +2 -0
  56. data/lib/ffi/gdal/version.rb +3 -1
  57. data/lib/ffi/gdal/vrt.rb +2 -0
  58. data/lib/ffi/gdal/warp_options.rb +9 -4
  59. data/lib/ffi/gdal/warper.rb +19 -1
  60. data/lib/ffi/ogr.rb +2 -0
  61. data/lib/ffi/ogr/api.rb +2 -0
  62. data/lib/ffi/ogr/contour_writer_info.rb +2 -0
  63. data/lib/ffi/ogr/core.rb +2 -0
  64. data/lib/ffi/ogr/envelope.rb +2 -0
  65. data/lib/ffi/ogr/envelope_3d.rb +2 -0
  66. data/lib/ffi/ogr/featurestyle.rb +2 -0
  67. data/lib/ffi/ogr/field.rb +2 -0
  68. data/lib/ffi/ogr/geocoding.rb +2 -0
  69. data/lib/ffi/ogr/srs_api.rb +3 -0
  70. data/lib/ffi/ogr/style_param.rb +2 -0
  71. data/lib/ffi/ogr/style_value.rb +2 -0
  72. data/lib/gdal.rb +3 -0
  73. data/lib/gdal/color_entry.rb +2 -0
  74. data/lib/gdal/color_entry_mixins/extensions.rb +2 -14
  75. data/lib/gdal/color_interpretation.rb +2 -0
  76. data/lib/gdal/color_table.rb +2 -0
  77. data/lib/gdal/color_table_mixins/extensions.rb +3 -17
  78. data/lib/gdal/color_table_types/cmyk.rb +2 -0
  79. data/lib/gdal/color_table_types/gray.rb +2 -0
  80. data/lib/gdal/color_table_types/hls.rb +2 -0
  81. data/lib/gdal/color_table_types/rgb.rb +2 -0
  82. data/lib/gdal/cpl_error_handler.rb +2 -0
  83. data/lib/gdal/data_type.rb +2 -0
  84. data/lib/gdal/dataset.rb +11 -7
  85. data/lib/gdal/dataset_mixins/algorithm_methods.rb +7 -4
  86. data/lib/gdal/dataset_mixins/extensions.rb +7 -47
  87. data/lib/gdal/dataset_mixins/matching.rb +4 -1
  88. data/lib/gdal/dataset_mixins/warp_methods.rb +52 -11
  89. data/lib/gdal/driver.rb +6 -8
  90. data/lib/gdal/driver_mixins/extensions.rb +2 -0
  91. data/lib/gdal/environment_methods.rb +2 -0
  92. data/lib/gdal/exceptions.rb +2 -0
  93. data/lib/gdal/geo_transform.rb +3 -3
  94. data/lib/gdal/geo_transform_mixins/extensions.rb +2 -17
  95. data/lib/gdal/grid.rb +4 -1
  96. data/lib/gdal/grid_algorithms.rb +2 -0
  97. data/lib/gdal/grid_algorithms/data_metrics_base.rb +2 -0
  98. data/lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb +2 -0
  99. data/lib/gdal/grid_algorithms/metric_average_distance.rb +2 -0
  100. data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +2 -0
  101. data/lib/gdal/grid_algorithms/metric_count.rb +2 -0
  102. data/lib/gdal/grid_algorithms/metric_maximum.rb +2 -0
  103. data/lib/gdal/grid_algorithms/metric_minimum.rb +2 -0
  104. data/lib/gdal/grid_algorithms/metric_range.rb +2 -0
  105. data/lib/gdal/grid_algorithms/moving_average.rb +2 -0
  106. data/lib/gdal/grid_algorithms/nearest_neighbor.rb +2 -0
  107. data/lib/gdal/gridder.rb +11 -3
  108. data/lib/gdal/gridder/point_extracting.rb +3 -2
  109. data/lib/gdal/gridder_options.rb +2 -0
  110. data/lib/gdal/internal_helpers.rb +3 -4
  111. data/lib/gdal/logger.rb +2 -0
  112. data/lib/gdal/major_object.rb +2 -0
  113. data/lib/gdal/merger.rb +2 -0
  114. data/lib/gdal/options.rb +16 -13
  115. data/lib/gdal/raster_attribute_table.rb +2 -0
  116. data/lib/gdal/raster_attribute_table_mixins/extensions.rb +3 -16
  117. data/lib/gdal/raster_band.rb +11 -6
  118. data/lib/gdal/raster_band_classifier.rb +52 -19
  119. data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +2 -0
  120. data/lib/gdal/raster_band_mixins/algorithm_methods.rb +12 -5
  121. data/lib/gdal/raster_band_mixins/coloring_extensions.rb +3 -1
  122. data/lib/gdal/raster_band_mixins/extensions.rb +6 -35
  123. data/lib/gdal/raster_band_mixins/io_extensions.rb +7 -4
  124. data/lib/gdal/rpc_info.rb +2 -0
  125. data/lib/gdal/transformer.rb +2 -0
  126. data/lib/gdal/transformers/approximate_transformer.rb +4 -1
  127. data/lib/gdal/transformers/base_general_image_projection_transformer.rb +4 -1
  128. data/lib/gdal/transformers/gcp_transformer.rb +6 -2
  129. data/lib/gdal/transformers/general_image_projection_transformer.rb +2 -0
  130. data/lib/gdal/transformers/general_image_projection_transformer2.rb +4 -1
  131. data/lib/gdal/transformers/general_image_projection_transformer3.rb +4 -1
  132. data/lib/gdal/transformers/geolocation_transformer.rb +4 -1
  133. data/lib/gdal/transformers/reprojection_transformer.rb +2 -0
  134. data/lib/gdal/transformers/rpc_transformer.rb +4 -1
  135. data/lib/gdal/transformers/tps_transformer.rb +2 -0
  136. data/lib/gdal/version_info.rb +9 -7
  137. data/lib/gdal/virtual_dataset.rb +2 -0
  138. data/lib/gdal/warp_operation.rb +2 -0
  139. data/lib/gdal/warp_options.rb +105 -35
  140. data/lib/ogr.rb +2 -0
  141. data/lib/ogr/coordinate_transformation.rb +2 -0
  142. data/lib/ogr/data_source.rb +5 -9
  143. data/lib/ogr/data_source_extensions.rb +2 -19
  144. data/lib/ogr/data_source_mixins/capability_methods.rb +2 -0
  145. data/lib/ogr/driver.rb +4 -6
  146. data/lib/ogr/driver_mixins/capability_methods.rb +2 -0
  147. data/lib/ogr/envelope.rb +4 -2
  148. data/lib/ogr/envelope_extensions.rb +2 -22
  149. data/lib/ogr/error_handling.rb +3 -1
  150. data/lib/ogr/exceptions.rb +3 -1
  151. data/lib/ogr/feature.rb +17 -9
  152. data/lib/ogr/feature_definition.rb +7 -4
  153. data/lib/ogr/feature_definition_extensions.rb +2 -18
  154. data/lib/ogr/feature_extensions.rb +2 -27
  155. data/lib/ogr/field.rb +5 -1
  156. data/lib/ogr/field_definition.rb +5 -6
  157. data/lib/ogr/geocoder.rb +2 -0
  158. data/lib/ogr/geometries/geometry_collection.rb +2 -0
  159. data/lib/ogr/geometries/geometry_collection_25d.rb +2 -0
  160. data/lib/ogr/geometries/line_string.rb +2 -1
  161. data/lib/ogr/geometries/line_string_25d.rb +2 -0
  162. data/lib/ogr/geometries/linear_ring.rb +2 -0
  163. data/lib/ogr/geometries/multi_line_string.rb +2 -0
  164. data/lib/ogr/geometries/multi_line_string_25d.rb +2 -0
  165. data/lib/ogr/geometries/multi_point.rb +2 -0
  166. data/lib/ogr/geometries/multi_point_25d.rb +2 -0
  167. data/lib/ogr/geometries/multi_polygon.rb +2 -0
  168. data/lib/ogr/geometries/multi_polygon_25d.rb +2 -0
  169. data/lib/ogr/geometries/none_geometry.rb +2 -0
  170. data/lib/ogr/geometries/point.rb +2 -0
  171. data/lib/ogr/geometries/point_25d.rb +2 -0
  172. data/lib/ogr/geometries/polygon.rb +2 -0
  173. data/lib/ogr/geometries/polygon_25d.rb +2 -0
  174. data/lib/ogr/geometries/unknown_geometry.rb +2 -0
  175. data/lib/ogr/geometry.rb +3 -4
  176. data/lib/ogr/geometry_field_definition.rb +3 -4
  177. data/lib/ogr/geometry_mixins/container_mixins.rb +2 -0
  178. data/lib/ogr/geometry_mixins/extensions.rb +10 -39
  179. data/lib/ogr/geometry_types/container.rb +2 -0
  180. data/lib/ogr/geometry_types/curve.rb +3 -1
  181. data/lib/ogr/geometry_types/surface.rb +2 -0
  182. data/lib/ogr/internal_helpers.rb +2 -0
  183. data/lib/ogr/layer.rb +5 -1
  184. data/lib/ogr/layer_mixins/capability_methods.rb +2 -0
  185. data/lib/ogr/layer_mixins/extensions.rb +9 -27
  186. data/lib/ogr/layer_mixins/ogr_feature_methods.rb +6 -12
  187. data/lib/ogr/layer_mixins/ogr_field_methods.rb +10 -14
  188. data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +2 -0
  189. data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +8 -3
  190. data/lib/ogr/layer_mixins/ogr_sql_methods.rb +3 -3
  191. data/lib/ogr/spatial_reference.rb +12 -2
  192. data/lib/ogr/spatial_reference_extensions.rb +2 -26
  193. data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +12 -5
  194. data/lib/ogr/spatial_reference_mixins/exporters.rb +2 -0
  195. data/lib/ogr/spatial_reference_mixins/importers.rb +6 -2
  196. data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -0
  197. data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +2 -0
  198. data/lib/ogr/spatial_reference_mixins/type_checks.rb +2 -0
  199. data/lib/ogr/style_table.rb +2 -0
  200. data/lib/ogr/style_table_extensions.rb +2 -10
  201. data/lib/ogr/style_tool.rb +2 -0
  202. data/spec/ffi-gdal_spec.rb +2 -0
  203. data/spec/integration/gdal/color_table_info_spec.rb +2 -0
  204. data/spec/integration/gdal/dataset_info_spec.rb +15 -13
  205. data/spec/integration/gdal/driver_info_spec.rb +3 -1
  206. data/spec/integration/gdal/geo_transform_info_spec.rb +2 -0
  207. data/spec/integration/gdal/gridder_spec.rb +2 -0
  208. data/spec/integration/gdal/raster_attribute_table_info_spec.rb +2 -0
  209. data/spec/integration/gdal/raster_band_algorithms_spec.rb +2 -0
  210. data/spec/integration/gdal/raster_band_info_spec.rb +37 -15
  211. data/spec/integration/ogr/layer_spec.rb +2 -6
  212. data/spec/spec_helper.rb +3 -1
  213. data/spec/support/images/123.tiff +0 -0
  214. data/spec/support/integration_help.rb +2 -0
  215. data/spec/support/shared_contexts.rb +2 -0
  216. data/spec/support/shared_examples/gdal/major_object_examples.rb +2 -0
  217. data/spec/support/shared_examples/ogr/{a_25D_geometry.rb → a_25d_geometry.rb} +2 -0
  218. data/spec/support/shared_examples/ogr/a_container_geometry.rb +2 -0
  219. data/spec/support/shared_examples/ogr/a_geometry.rb +3 -1
  220. data/spec/support/shared_examples/ogr/a_line_string.rb +2 -0
  221. data/spec/unit/ext/error_symbols_spec.rb +2 -0
  222. data/spec/unit/ext/numeric_as_data_type_spec.rb +2 -0
  223. data/spec/unit/ffi/gdal_spec.rb +3 -0
  224. data/spec/unit/gdal/color_entry_spec.rb +2 -0
  225. data/spec/unit/gdal/color_interpretation_spec.rb +2 -0
  226. data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +2 -0
  227. data/spec/unit/gdal/color_table_spec.rb +2 -0
  228. data/spec/unit/gdal/data_type_spec.rb +2 -0
  229. data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +55 -0
  230. data/spec/unit/gdal/dataset_spec.rb +2 -0
  231. data/spec/unit/gdal/driver_mixins/extensions_spec.rb +2 -0
  232. data/spec/unit/gdal/driver_spec.rb +2 -0
  233. data/spec/unit/gdal/environment_methods_spec.rb +2 -0
  234. data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +2 -0
  235. data/spec/unit/gdal/geo_transform_spec.rb +2 -13
  236. data/spec/unit/gdal/grid_spec.rb +10 -0
  237. data/spec/unit/gdal/gridder/point_extracting_spec.rb +2 -0
  238. data/spec/unit/gdal/gridder_options_spec.rb +2 -0
  239. data/spec/unit/gdal/gridder_spec.rb +42 -0
  240. data/spec/unit/gdal/internal_helpers_spec.rb +2 -0
  241. data/spec/unit/gdal/major_object_spec.rb +2 -0
  242. data/spec/unit/gdal/options_spec.rb +28 -1
  243. data/spec/unit/gdal/raster_attribute_table_spec.rb +2 -0
  244. data/spec/unit/gdal/raster_band_classifier_spec.rb +43 -5
  245. data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +2 -0
  246. data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +2 -0
  247. data/spec/unit/gdal/raster_band_spec.rb +2 -0
  248. data/spec/unit/gdal/rpc_info_spec.rb +2 -0
  249. data/spec/unit/gdal/version_info_spec.rb +2 -0
  250. data/spec/unit/gdal/virtual_dataset_spec.rb +2 -0
  251. data/spec/unit/gdal/warp_operation_spec.rb +2 -0
  252. data/spec/unit/gdal/warp_options_spec.rb +338 -0
  253. data/spec/unit/ogr/coordinate_transformation_spec.rb +2 -0
  254. data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +2 -0
  255. data/spec/unit/ogr/data_source_spec.rb +2 -0
  256. data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +2 -0
  257. data/spec/unit/ogr/driver_spec.rb +3 -1
  258. data/spec/unit/ogr/envelope_spec.rb +2 -0
  259. data/spec/unit/ogr/feature_definition_spec.rb +2 -19
  260. data/spec/unit/ogr/feature_extensions_spec.rb +3 -1
  261. data/spec/unit/ogr/feature_spec.rb +3 -3
  262. data/spec/unit/ogr/field_definition_spec.rb +2 -19
  263. data/spec/unit/ogr/field_spec.rb +3 -1
  264. data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +2 -0
  265. data/spec/unit/ogr/geometries/geometry_collection_spec.rb +2 -0
  266. data/spec/unit/ogr/geometries/line_string_25d_spec.rb +2 -0
  267. data/spec/unit/ogr/geometries/line_string_spec.rb +2 -0
  268. data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -0
  269. data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +2 -0
  270. data/spec/unit/ogr/geometries/multi_line_string_spec.rb +2 -0
  271. data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +2 -0
  272. data/spec/unit/ogr/geometries/multi_point_spec.rb +2 -0
  273. data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +2 -0
  274. data/spec/unit/ogr/geometries/multi_polygon_spec.rb +2 -0
  275. data/spec/unit/ogr/geometries/none_geometry_spec.rb +2 -0
  276. data/spec/unit/ogr/geometries/point_25d_spec.rb +2 -0
  277. data/spec/unit/ogr/geometries/point_spec.rb +2 -0
  278. data/spec/unit/ogr/geometries/polygon_25d_spec.rb +2 -0
  279. data/spec/unit/ogr/geometries/polygon_spec.rb +2 -0
  280. data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +2 -0
  281. data/spec/unit/ogr/geometry_field_definition_spec.rb +2 -16
  282. data/spec/unit/ogr/geometry_spec.rb +2 -0
  283. data/spec/unit/ogr/internal_helpers_spec.rb +2 -0
  284. data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +2 -0
  285. data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +2 -0
  286. data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +2 -0
  287. data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +2 -0
  288. data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +2 -0
  289. data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +2 -0
  290. data/spec/unit/ogr/layer_spec.rb +2 -0
  291. data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +2 -0
  292. data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +19 -15
  293. data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +2 -0
  294. data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +9 -7
  295. data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -0
  296. data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +2 -0
  297. data/spec/unit/ogr/spatial_reference_spec.rb +4 -2
  298. data/spec/unit/ogr/style_table_spec.rb +2 -26
  299. data/spec/unit/ogr/style_tool_spec.rb +2 -0
  300. data/spec/unit/version_info_spec.rb +2 -0
  301. metadata +47 -15
  302. data/lib/ogr/field_definition_extensions.rb +0 -22
  303. data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../geometry_types/container'
2
4
  require_relative '../geometry_types/surface'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'multi_polygon'
2
4
 
3
5
  module OGR
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  class NoneGeometry
3
5
  include OGR::Geometry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  class Point
3
5
  include OGR::Geometry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'point'
2
4
 
3
5
  module OGR
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../geometry_types/container'
2
4
  require_relative '../geometry_types/surface'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'polygon'
2
4
 
3
5
  module OGR
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  class UnknownGeometry
3
5
  include OGR::Geometry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../ogr'
2
4
  require_relative 'geometry_mixins/extensions'
3
5
  require_relative '../gdal'
@@ -240,7 +242,6 @@ module OGR
240
242
  end
241
243
 
242
244
  # @return [Fixnum]
243
- # @todo This regularly crashes, so disabling it.
244
245
  def centroid
245
246
  point = is_3d? ? OGR::Point25D.new : OGR::Point.new
246
247
 
@@ -618,9 +619,7 @@ module OGR
618
619
 
619
620
  linear_ring = OGR::LinearRing.new
620
621
 
621
- if line_string.spatial_reference
622
- linear_ring.spatial_reference = line_string.spatial_reference.clone
623
- end
622
+ linear_ring.spatial_reference = line_string.spatial_reference.clone if line_string.spatial_reference
624
623
 
625
624
  linear_ring.import_from_wkt(line_string.to_wkt.tr('LINESTRING', 'LINEARRING'))
626
625
  linear_ring.close_rings! if close_rings
@@ -1,9 +1,7 @@
1
- require_relative 'geometry_field_definition_extensions'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module OGR
4
4
  class GeometryFieldDefinition
5
- include GeometryFieldDefinitionExtensions
6
-
7
5
  # @return [FFI::Pointer]
8
6
  attr_reader :c_pointer
9
7
 
@@ -83,7 +81,8 @@ module OGR
83
81
 
84
82
  FFI::OGR::API.OGR_GFld_SetSpatialRef(
85
83
  @c_pointer,
86
- spatial_ref_ptr)
84
+ spatial_ref_ptr
85
+ )
87
86
  end
88
87
 
89
88
  # @return [Boolean]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module GeometryMixins
3
5
  module ContainerMixins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module OGR
@@ -7,18 +9,18 @@ module OGR
7
9
  def utm_zone
8
10
  return unless spatial_reference
9
11
 
10
- if spatial_reference.authority_code == '4326'.freeze
11
- self_as_4326 = self
12
+ if spatial_reference.authority_code == '4326'
13
+ self_as4326 = self
12
14
  else
13
- self_as_4326 = dup
14
- self_as_4326.transform_to!(OGR::SpatialReference.new_from_epsg(4326))
15
+ self_as4326 = dup
16
+ self_as4326.transform_to!(OGR::SpatialReference.new_from_epsg(4326))
15
17
  end
16
18
 
17
- self_as_4326 = self_as_4326.buffer(0) unless self_as_4326.valid?
19
+ self_as4326 = self_as4326.buffer(0) unless self_as4326.valid?
18
20
 
19
- return unless self_as_4326.point_on_surface.x
21
+ return unless self_as4326.point_on_surface.x
20
22
 
21
- ((self_as_4326.point_on_surface.x + 180) / 6.to_f).floor + 1
23
+ ((self_as4326.point_on_surface.x + 180) / 6.to_f).floor + 1
22
24
  end
23
25
 
24
26
  # @return [Boolean]
@@ -53,35 +55,6 @@ module OGR
53
55
  !valid?
54
56
  end
55
57
 
56
- # @return [Hash]
57
- def as_json(options = nil)
58
- json = {
59
- coordinate_dimension: coordinate_dimension,
60
- geometry_count: geometry_count,
61
- dimension: dimension,
62
- is_empty: empty?,
63
- is_ring: ring?,
64
- is_simple: simple?,
65
- is_valid: valid?,
66
- name: name,
67
- point_count: point_count,
68
- spatial_reference: spatial_reference.nil? ? nil : spatial_reference.as_json(options),
69
- type: type_to_name,
70
- wkb_size: wkb_size
71
- }
72
-
73
- json[:area] = area if respond_to? :area
74
- json[:length] = length if respond_to? :length
75
- json[:points] = points if respond_to? :points
76
-
77
- json
78
- end
79
-
80
- # @return [String]
81
- def to_json(options = nil)
82
- as_json(options).to_json
83
- end
84
-
85
58
  def collection?
86
59
  false
87
60
  end
@@ -97,9 +70,7 @@ module OGR
97
70
  # field = FieldDefinition.new('Name', :OFTString)
98
71
  # field.width = 32
99
72
 
100
- unless layer
101
- raise OGR::InvalidLayer, "Unable to create layer '#{layer_name}'."
102
- end
73
+ raise OGR::InvalidLayer, "Unable to create layer '#{layer_name}'." unless layer
103
74
 
104
75
  feature = layer.create_feature(layer_name)
105
76
  feature.geometry = self
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../geometry_mixins/container_mixins'
2
4
 
3
5
  module OGR
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module GeometryTypes
3
5
  module Curve
@@ -102,7 +104,7 @@ module OGR
102
104
  y_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size)
103
105
  z_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size) if coordinate_dimension == 3
104
106
 
105
- FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
107
+ num_points = FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
106
108
  x_buffer, x_stride, y_buffer,
107
109
  y_stride, z_buffer, z_stride)
108
110
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module GeometryTypes
3
5
  module Surface
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
 
3
5
  module OGR
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../ogr'
2
4
  require_relative '../gdal'
3
5
  require_relative 'layer_mixins/extensions'
@@ -20,7 +22,9 @@ module OGR
20
22
  include LayerMixins::OGRQueryFilterMethods
21
23
  include LayerMixins::OGRSQLMethods
22
24
 
23
- class_eval FFI::OGR::Core::OGR_ALTER.to_ruby
25
+ FFI::OGR::Core::OGR_ALTER.constants.each do |_name, obj|
26
+ const_set(obj.ruby_name, obj.value.to_i(16))
27
+ end
24
28
 
25
29
  # @return [FFI::Pointer] C pointer to the C Layer.
26
30
  attr_reader :c_pointer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module LayerMixins
3
5
  # Helper methods for checking what the Layer is capable of.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'json'
2
4
 
3
5
  module OGR
@@ -22,7 +24,7 @@ module OGR
22
24
 
23
25
  begin
24
26
  yield feature
25
- rescue
27
+ rescue StandardError
26
28
  feature.destroy!
27
29
  raise
28
30
  end
@@ -50,7 +52,7 @@ module OGR
50
52
 
51
53
  begin
52
54
  yield feature_ptr
53
- rescue
55
+ rescue StandardError
54
56
  FFI::OGR::API.OGR_F_Destroy(feature_ptr)
55
57
  raise
56
58
  end
@@ -66,7 +68,7 @@ module OGR
66
68
  #
67
69
  # @return [Array<OGR::Feature>]
68
70
  def features
69
- each_feature.map { |f| f.clone }
71
+ each_feature.map(&:clone)
70
72
  end
71
73
 
72
74
  # @return [OGR::Polygon] A polygon derived from a LinearRing that connects
@@ -122,6 +124,10 @@ module OGR
122
124
  x_ptr = FFI::MemoryPointer.new(:double)
123
125
  y_ptr = FFI::MemoryPointer.new(:double)
124
126
 
127
+ # This block is intentionally long simply for the sake of performance.
128
+ # I've tried refactoring chunks of this out to separate methods and
129
+ # performance suffers greatly. Since this is a key part of gridding (at
130
+ # least at this point), it needs to be as fast as possible.
125
131
  each_feature_pointer do |feature_ptr|
126
132
  field_values = field_indices.map.with_index do |j, attribute_index|
127
133
  FFI::OGR::API.send("OGR_F_GetFieldAs#{with_attributes.values[attribute_index].capitalize}", feature_ptr, j)
@@ -229,30 +235,6 @@ module OGR
229
235
  found_z_geom
230
236
  end
231
237
 
232
- # @return [Hash]
233
- def as_json(options = nil)
234
- {
235
- layer: {
236
- extent: extent.as_json(options),
237
- feature_count: feature_count,
238
- feature_definition: feature_definition.as_json(options),
239
- features: each_feature.map { |f| f.as_json(options) },
240
- fid_column: fid_column,
241
- geometry_column: geometry_column,
242
- geometry_type: geometry_type,
243
- name: name,
244
- spatial_reference: spatial_reference ? spatial_reference.as_json(options) : nil,
245
- style_table: style_table ? style_table.as_json(options) : nil
246
- },
247
- metadata: nil # all_metadata
248
- }
249
- end
250
-
251
- # @return [String]
252
- def to_json(options = nil)
253
- as_json(options).to_json
254
- end
255
-
256
238
  private
257
239
 
258
240
  # @param geometry_ptr [FFI::Pointer]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module LayerMixins
3
5
  module OGRFeatureMethods
@@ -23,9 +25,7 @@ module OGR
23
25
  # @param feature [OGR::Feature] [description]
24
26
  # @return [Boolean]
25
27
  def create_feature(feature)
26
- unless can_sequential_write?
27
- raise OGR::UnsupportedOperation, 'This layer does not support feature creation.'
28
- end
28
+ raise OGR::UnsupportedOperation, 'This layer does not support feature creation.' unless can_sequential_write?
29
29
 
30
30
  ogr_err = FFI::OGR::API.OGR_L_CreateFeature(@c_pointer, feature.c_pointer)
31
31
 
@@ -39,9 +39,7 @@ module OGR
39
39
  # @raise [OGR::Failure] When trying to delete a feature with an ID that
40
40
  # does not exist.
41
41
  def delete_feature(feature_id)
42
- unless can_delete_feature?
43
- raise OGR::UnsupportedOperation, 'This layer does not support feature deletion.'
44
- end
42
+ raise OGR::UnsupportedOperation, 'This layer does not support feature deletion.' unless can_delete_feature?
45
43
 
46
44
  ogr_err = FFI::OGR::API.OGR_L_DeleteFeature(@c_pointer, feature_id)
47
45
 
@@ -61,9 +59,7 @@ module OGR
61
59
  #
62
60
  # @param new_feature [OGR::Feature, FFI::Pointer]
63
61
  def feature=(new_feature)
64
- unless can_random_write?
65
- raise OGR::UnsupportedOperation, '#feature= not supported by this Layer'
66
- end
62
+ raise OGR::UnsupportedOperation, '#feature= not supported by this Layer' unless can_random_write?
67
63
 
68
64
  new_feature_ptr = GDAL._pointer(OGR::Feature, new_feature)
69
65
  raise OGR::InvalidFeature if new_feature_ptr.nil? || new_feature_ptr.null?
@@ -77,9 +73,7 @@ module OGR
77
73
  # be <= +feature_count+, but no checking is done to ensure.
78
74
  # @return [OGR::Feature, nil]
79
75
  def feature(index)
80
- unless can_random_read?
81
- raise OGR::UnsupportedOperation, '#feature(index) not supported by this Layer'
82
- end
76
+ raise OGR::UnsupportedOperation, '#feature(index) not supported by this Layer' unless can_random_read?
83
77
 
84
78
  feature_pointer = FFI::OGR::API.OGR_L_GetFeature(@c_pointer, index)
85
79
  return nil if feature_pointer.null?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module LayerMixins
3
5
  module OGRFieldMethods
@@ -10,9 +12,7 @@ module OGR
10
12
  # different form, depending on the limitations of the format driver.
11
13
  # @return [Boolean]
12
14
  def create_field(field_definition, approx_ok = false)
13
- unless can_create_field?
14
- raise OGR::UnsupportedOperation, 'This layer does not support field creation.'
15
- end
15
+ raise OGR::UnsupportedOperation, 'This layer does not support field creation.' unless can_create_field?
16
16
 
17
17
  field_definition_ptr = GDAL._pointer(OGR::FieldDefinition, field_definition)
18
18
  ogr_err = FFI::OGR::API.OGR_L_CreateField(@c_pointer, field_definition_ptr, approx_ok)
@@ -24,9 +24,7 @@ module OGR
24
24
  #
25
25
  # @return +true+ if successful, otherwise raises an OGR exception.
26
26
  def delete_field(field_id)
27
- unless can_delete_field?
28
- raise OGR::UnsupportedOperation, 'This driver does not support field deletion.'
29
- end
27
+ raise OGR::UnsupportedOperation, 'This driver does not support field deletion.' unless can_delete_field?
30
28
 
31
29
  ogr_err = FFI::OGR::API.OGR_L_DeleteField(@c_pointer, field_id)
32
30
 
@@ -37,9 +35,7 @@ module OGR
37
35
  # which they should be reordered. I.e. [0, 2, 3, 1, 4].
38
36
  # @return [Boolean]
39
37
  def reorder_fields(*new_order)
40
- unless can_reorder_fields?
41
- raise OGR::UnsupportedOperation, 'This driver does not support field reordering.'
42
- end
38
+ raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
43
39
 
44
40
  return false if new_order.empty?
45
41
  return false if new_order.any? { |i| i > feature_definition.field_count }
@@ -56,9 +52,7 @@ module OGR
56
52
  # @param old_position [Fixnum]
57
53
  # @param new_position [Fixnum]
58
54
  def reorder_field(old_position, new_position)
59
- unless can_reorder_fields?
60
- raise OGR::UnsupportedOperation, 'This driver does not support field reordering.'
61
- end
55
+ raise OGR::UnsupportedOperation, 'This driver does not support field reordering.' unless can_reorder_fields?
62
56
 
63
57
  ogr_err = FFI::OGR::API.OGR_L_ReorderField(@c_pointer, old_position, new_position)
64
58
 
@@ -81,7 +75,8 @@ module OGR
81
75
  @c_pointer,
82
76
  field_index,
83
77
  new_field_definition_ptr,
84
- flags)
78
+ flags
79
+ )
85
80
 
86
81
  ogr_err.handle_result
87
82
  end
@@ -115,7 +110,8 @@ module OGR
115
110
  ogr_err = FFI::OGR::API.OGR_L_CreateGeomField(
116
111
  @c_pointer,
117
112
  geometry_field_definition_ptr,
118
- approx_ok)
113
+ approx_ok
114
+ )
119
115
 
120
116
  ogr_err.handle_result
121
117
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module LayerMixins
3
5
  # OGR::Layer methods: Ruby methods that operate on a OGR::Layer using a
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OGR
2
4
  module LayerMixins
3
5
  module OGRQueryFilterMethods
@@ -29,7 +31,8 @@ module OGR
29
31
  geometry_ptr = GDAL._pointer(OGR::Geometry, geometry)
30
32
 
31
33
  FFI::OGR::API.OGR_L_SetSpatialFilterEx(
32
- @c_pointer, geometry_field_index, geometry_ptr)
34
+ @c_pointer, geometry_field_index, geometry_ptr
35
+ )
33
36
  end
34
37
 
35
38
  # Only features that geometrically intersect the given rectangle will be
@@ -47,7 +50,8 @@ module OGR
47
50
  min_x,
48
51
  min_y,
49
52
  max_x,
50
- max_y)
53
+ max_y
54
+ )
51
55
  end
52
56
 
53
57
  # Only features that geometrically intersect the given rectangle will be
@@ -68,7 +72,8 @@ module OGR
68
72
  min_x,
69
73
  min_y,
70
74
  max_x,
71
- max_y)
75
+ max_y
76
+ )
72
77
  end
73
78
 
74
79
  # Sets the attribute query string to be used when fetching Features using