ffi-gdal 1.0.0.beta5 → 1.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -3
  3. data/.rubocop.yml +7 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +1 -1
  6. data/History.md +143 -1
  7. data/README.md +5 -11
  8. data/Rakefile +2 -60
  9. data/TODO.md +10 -0
  10. data/examples/geometries.rb +4 -6
  11. data/examples/gridding.rb +99 -98
  12. data/examples/ogr_layer_to_layer.rb +0 -2
  13. data/examples/raster_erasing.rb +47 -0
  14. data/examples/remove_small_polygons.rb +62 -0
  15. data/examples/testing_gdal.rb +0 -3
  16. data/examples/warping.rb +140 -0
  17. data/ffi-gdal.gemspec +5 -2
  18. data/lib/ext/error_symbols.rb +1 -1
  19. data/lib/ext/ffi_library_function_checks.rb +3 -2
  20. data/lib/ext/float_ext.rb +2 -2
  21. data/lib/ext/narray_ext.rb +1 -1
  22. data/lib/ext/numeric_as_data_type.rb +1 -1
  23. data/lib/ext/to_bool.rb +2 -2
  24. data/lib/ffi/cpl/conv.rb +1 -3
  25. data/lib/ffi/cpl/error.rb +0 -3
  26. data/lib/ffi/cpl/minixml.rb +17 -21
  27. data/lib/ffi/cpl/progress.rb +27 -0
  28. data/lib/ffi/cpl/string.rb +0 -8
  29. data/lib/ffi/cpl/vsi.rb +0 -1
  30. data/lib/ffi/cpl/xml_node.rb +0 -1
  31. data/lib/ffi/cpl.rb +15 -0
  32. data/lib/ffi/gdal/alg.rb +72 -54
  33. data/lib/ffi/gdal/gdal.rb +669 -672
  34. data/lib/ffi/gdal/grid.rb +141 -24
  35. data/lib/ffi/gdal/grid_data_metrics_options.rb +1 -1
  36. data/lib/ffi/gdal/grid_moving_average_options.rb +1 -1
  37. data/lib/ffi/gdal/matching.rb +0 -2
  38. data/lib/ffi/gdal/transformer_info.rb +1 -1
  39. data/lib/ffi/gdal/version.rb +1 -1
  40. data/lib/ffi/gdal/vrt.rb +0 -2
  41. data/lib/ffi/gdal/warp_options.rb +12 -14
  42. data/lib/ffi/gdal/warper.rb +61 -6
  43. data/lib/ffi/gdal.rb +18 -3
  44. data/lib/ffi/ogr/api.rb +10 -21
  45. data/lib/ffi/ogr/core.rb +9 -12
  46. data/lib/ffi/ogr/featurestyle.rb +0 -5
  47. data/lib/ffi/ogr/geocoding.rb +0 -1
  48. data/lib/ffi/ogr/srs_api.rb +0 -4
  49. data/lib/ffi/ogr/style_value.rb +1 -2
  50. data/lib/ffi/ogr.rb +15 -12
  51. data/lib/ffi-gdal.rb +5 -3
  52. data/lib/gdal/color_entry.rb +1 -0
  53. data/lib/gdal/color_interpretation.rb +2 -2
  54. data/lib/gdal/color_table.rb +14 -14
  55. data/lib/gdal/color_table_mixins/extensions.rb +4 -4
  56. data/lib/gdal/cpl_error_handler.rb +12 -14
  57. data/lib/gdal/data_type.rb +13 -12
  58. data/lib/gdal/dataset.rb +170 -94
  59. data/lib/gdal/dataset_mixins/algorithm_methods.rb +47 -21
  60. data/lib/gdal/dataset_mixins/extensions.rb +32 -61
  61. data/lib/gdal/dataset_mixins/matching.rb +0 -2
  62. data/lib/gdal/dataset_mixins/warp_methods.rb +42 -0
  63. data/lib/gdal/driver.rb +62 -47
  64. data/lib/gdal/driver_mixins/extensions.rb +2 -7
  65. data/lib/gdal/environment_methods.rb +13 -10
  66. data/lib/gdal/exceptions.rb +24 -2
  67. data/lib/gdal/geo_transform.rb +10 -16
  68. data/lib/gdal/geo_transform_mixins/extensions.rb +58 -3
  69. data/lib/gdal/grid.rb +62 -109
  70. data/lib/gdal/{grid_types → grid_algorithms}/data_metrics_base.rb +1 -3
  71. data/lib/gdal/{grid_types → grid_algorithms}/inverse_distance_to_a_power.rb +2 -4
  72. data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance.rb +2 -2
  73. data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance_pts.rb +2 -2
  74. data/lib/gdal/{grid_types → grid_algorithms}/metric_count.rb +2 -2
  75. data/lib/gdal/{grid_types → grid_algorithms}/metric_maximum.rb +2 -2
  76. data/lib/gdal/{grid_types → grid_algorithms}/metric_minimum.rb +2 -2
  77. data/lib/gdal/{grid_types → grid_algorithms}/metric_range.rb +2 -2
  78. data/lib/gdal/{grid_types → grid_algorithms}/moving_average.rb +2 -4
  79. data/lib/gdal/{grid_types → grid_algorithms}/nearest_neighbor.rb +2 -4
  80. data/lib/gdal/grid_algorithms.rb +22 -0
  81. data/lib/gdal/gridder/point_extracting.rb +89 -0
  82. data/lib/gdal/gridder.rb +294 -0
  83. data/lib/gdal/gridder_options.rb +273 -0
  84. data/lib/gdal/internal_helpers.rb +132 -23
  85. data/lib/gdal/major_object.rb +13 -10
  86. data/lib/gdal/merger.rb +130 -0
  87. data/lib/gdal/options.rb +3 -2
  88. data/lib/gdal/raster_attribute_table.rb +74 -51
  89. data/lib/gdal/raster_attribute_table_mixins/extensions.rb +21 -3
  90. data/lib/gdal/raster_band.rb +139 -167
  91. data/lib/gdal/raster_band_classifier.rb +19 -18
  92. data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +107 -0
  93. data/lib/gdal/raster_band_mixins/algorithm_methods.rb +79 -40
  94. data/lib/gdal/raster_band_mixins/coloring_extensions.rb +84 -0
  95. data/lib/gdal/raster_band_mixins/extensions.rb +34 -169
  96. data/lib/gdal/raster_band_mixins/io_extensions.rb +180 -0
  97. data/lib/gdal/rpc_info.rb +1 -2
  98. data/lib/gdal/transformer.rb +1 -6
  99. data/lib/gdal/transformers/approximate_transformer.rb +0 -4
  100. data/lib/gdal/transformers/base_general_image_projection_transformer.rb +0 -6
  101. data/lib/gdal/transformers/gcp_transformer.rb +2 -6
  102. data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -7
  103. data/lib/gdal/transformers/general_image_projection_transformer2.rb +1 -1
  104. data/lib/gdal/transformers/geolocation_transformer.rb +0 -4
  105. data/lib/gdal/transformers/reprojection_transformer.rb +0 -8
  106. data/lib/gdal/transformers/rpc_transformer.rb +0 -4
  107. data/lib/gdal/transformers/tps_transformer.rb +1 -3
  108. data/lib/gdal/version_info.rb +7 -8
  109. data/lib/gdal/virtual_dataset.rb +2 -4
  110. data/lib/gdal/warp_operation.rb +17 -14
  111. data/lib/gdal/warp_options.rb +132 -0
  112. data/lib/gdal.rb +41 -2
  113. data/lib/ogr/coordinate_transformation.rb +79 -32
  114. data/lib/ogr/data_source.rb +17 -14
  115. data/lib/ogr/data_source_extensions.rb +1 -5
  116. data/lib/ogr/driver.rb +11 -14
  117. data/lib/ogr/envelope.rb +1 -1
  118. data/lib/ogr/envelope_extensions.rb +23 -6
  119. data/lib/ogr/error_handling.rb +3 -3
  120. data/lib/ogr/exceptions.rb +6 -0
  121. data/lib/ogr/feature.rb +25 -38
  122. data/lib/ogr/feature_definition.rb +6 -8
  123. data/lib/ogr/feature_definition_extensions.rb +2 -6
  124. data/lib/ogr/feature_extensions.rb +71 -41
  125. data/lib/ogr/field.rb +16 -15
  126. data/lib/ogr/field_definition.rb +4 -4
  127. data/lib/ogr/geocoder.rb +5 -5
  128. data/lib/ogr/geometries/geometry_collection.rb +4 -1
  129. data/lib/ogr/geometries/geometry_collection_25d.rb +12 -0
  130. data/lib/ogr/geometries/line_string.rb +30 -8
  131. data/lib/ogr/geometries/line_string_25d.rb +21 -0
  132. data/lib/ogr/geometries/linear_ring.rb +10 -1
  133. data/lib/ogr/geometries/multi_line_string.rb +2 -1
  134. data/lib/ogr/geometries/multi_line_string_25d.rb +13 -0
  135. data/lib/ogr/geometries/multi_point.rb +2 -1
  136. data/lib/ogr/geometries/multi_point_25d.rb +14 -0
  137. data/lib/ogr/geometries/multi_polygon.rb +3 -2
  138. data/lib/ogr/geometries/multi_polygon_25d.rb +13 -0
  139. data/lib/ogr/geometries/point.rb +20 -23
  140. data/lib/ogr/geometries/point_25d.rb +48 -0
  141. data/lib/ogr/geometries/polygon.rb +4 -1
  142. data/lib/ogr/geometries/polygon_25d.rb +14 -0
  143. data/lib/ogr/geometry.rb +125 -93
  144. data/lib/ogr/geometry_field_definition.rb +7 -5
  145. data/lib/ogr/geometry_mixins/container_mixins.rb +23 -0
  146. data/lib/ogr/geometry_mixins/extensions.rb +111 -0
  147. data/lib/ogr/geometry_types/container.rb +10 -3
  148. data/lib/ogr/geometry_types/curve.rb +68 -23
  149. data/lib/ogr/geometry_types/surface.rb +0 -9
  150. data/lib/ogr/internal_helpers.rb +3 -3
  151. data/lib/ogr/layer.rb +4 -5
  152. data/lib/ogr/layer_mixins/extensions.rb +242 -17
  153. data/lib/ogr/layer_mixins/ogr_feature_methods.rb +11 -11
  154. data/lib/ogr/layer_mixins/ogr_field_methods.rb +6 -11
  155. data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +18 -18
  156. data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +0 -2
  157. data/lib/ogr/layer_mixins/ogr_sql_methods.rb +1 -1
  158. data/lib/ogr/spatial_reference.rb +12 -37
  159. data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +53 -55
  160. data/lib/ogr/spatial_reference_mixins/exporters.rb +18 -49
  161. data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +10 -29
  162. data/lib/ogr/style_table.rb +2 -2
  163. data/lib/ogr/style_table_extensions.rb +3 -1
  164. data/lib/ogr/style_tool.rb +8 -14
  165. data/lib/ogr.rb +39 -1
  166. data/spec/ffi-gdal_spec.rb +18 -1
  167. data/spec/integration/gdal/color_table_info_spec.rb +49 -33
  168. data/spec/integration/gdal/dataset_info_spec.rb +294 -45
  169. data/spec/integration/gdal/driver_info_spec.rb +139 -31
  170. data/spec/integration/gdal/geo_transform_info_spec.rb +197 -26
  171. data/spec/integration/gdal/gridder_spec.rb +329 -0
  172. data/spec/integration/gdal/raster_attribute_table_info_spec.rb +216 -11
  173. data/spec/integration/gdal/raster_band_algorithms_spec.rb +33 -0
  174. data/spec/integration/gdal/raster_band_info_spec.rb +240 -271
  175. data/spec/integration/ogr/layer_spec.rb +3 -1
  176. data/spec/spec_helper.rb +15 -6
  177. data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
  178. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +31 -0
  179. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
  180. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
  181. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +10 -0
  182. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
  183. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +84 -0
  184. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +45 -0
  185. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
  186. data/spec/support/integration_help.rb +32 -2
  187. data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -6
  188. data/spec/support/shared_examples/ogr/a_geometry.rb +1 -1
  189. data/spec/unit/ffi/gdal_spec.rb +1 -1
  190. data/spec/unit/gdal/color_entry_spec.rb +1 -0
  191. data/spec/unit/gdal/color_interpretation_spec.rb +1 -0
  192. data/spec/unit/gdal/dataset_spec.rb +53 -2
  193. data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +67 -0
  194. data/spec/unit/gdal/geo_transform_spec.rb +1 -1
  195. data/spec/unit/gdal/grid_spec.rb +83 -0
  196. data/spec/unit/gdal/gridder/point_extracting_spec.rb +99 -0
  197. data/spec/unit/gdal/gridder_options_spec.rb +183 -0
  198. data/spec/unit/gdal/gridder_spec.rb +140 -0
  199. data/spec/unit/gdal/internal_helpers_spec.rb +166 -2
  200. data/spec/unit/gdal/major_object_spec.rb +2 -0
  201. data/spec/unit/gdal/options_spec.rb +1 -0
  202. data/spec/unit/gdal/raster_band_classifier_spec.rb +70 -12
  203. data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +71 -0
  204. data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +133 -0
  205. data/spec/unit/gdal/raster_band_spec.rb +1 -0
  206. data/spec/unit/gdal/rpc_info_spec.rb +1 -0
  207. data/spec/unit/gdal/version_info_spec.rb +2 -0
  208. data/spec/unit/gdal/warp_operation_spec.rb +1 -0
  209. data/spec/unit/ogr/coordinate_transformation_spec.rb +102 -0
  210. data/spec/unit/ogr/data_source_spec.rb +12 -0
  211. data/spec/unit/ogr/feature_extensions_spec.rb +88 -0
  212. data/spec/unit/ogr/feature_spec.rb +30 -46
  213. data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +23 -0
  214. data/spec/unit/ogr/geometries/geometry_collection_spec.rb +3 -3
  215. data/spec/unit/ogr/geometries/line_string_25d_spec.rb +23 -0
  216. data/spec/unit/ogr/geometries/line_string_spec.rb +2 -2
  217. data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -2
  218. data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +23 -0
  219. data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +23 -0
  220. data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +23 -0
  221. data/spec/unit/ogr/geometries/point_25d_spec.rb +23 -0
  222. data/spec/unit/ogr/geometries/point_spec.rb +14 -24
  223. data/spec/unit/ogr/geometries/polygon_25d_spec.rb +23 -0
  224. data/spec/unit/ogr/geometries/polygon_spec.rb +1 -1
  225. data/spec/unit/ogr/geometry_field_definition_spec.rb +1 -1
  226. data/spec/unit/ogr/geometry_spec.rb +196 -30
  227. data/spec/unit/ogr/internal_helpers_spec.rb +20 -9
  228. data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +14 -6
  229. data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +9 -1
  230. data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -1
  231. data/spec/unit/ogr/style_table_spec.rb +1 -1
  232. data/tmp/.keep +0 -0
  233. metadata +121 -19
  234. data/examples/points.txt +0 -127
  235. data/lib/gdal/grid_types.rb +0 -22
  236. data/lib/ogr/geometries/point_extensions.rb +0 -32
  237. data/lib/ogr/geometry_extensions.rb +0 -59
@@ -0,0 +1,31 @@
1
+ Geotiff_Information:
2
+ Version: 1
3
+ Key_Revision: 1.0
4
+ Tagged_Information:
5
+ ModelTiepointTag (2,3):
6
+ 50.5 50.5 0
7
+ 9.00105738 52.001376 0
8
+ ModelPixelScaleTag (1,3):
9
+ 2.77777778e-005 2.77777778e-005 1
10
+ End_Of_Tags.
11
+ Keyed_Information:
12
+ GTModelTypeGeoKey (Short,1): ModelTypeGeographic
13
+ GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
14
+ GeographicTypeGeoKey (Short,1): User-Defined
15
+ GeogGeodeticDatumGeoKey (Short,1): User-Defined
16
+ GeogAngularUnitsGeoKey (Short,1): Angular_Degree
17
+ GeogEllipsoidGeoKey (Short,1): Ellipse_Bessel_1841
18
+ Unknown-2062 (Double,7): 598.1 73.7 418.2
19
+ 0.202 0.045 -2.455
20
+ 6.7
21
+ End_Of_Keys.
22
+ End_Of_Geotiff.
23
+
24
+ Ellipsoid: 7004/(unknown) (0.00,0.00)
25
+
26
+ Corner Coordinates:
27
+ Upper Left ( 8d59'58.76"E, 52d 0'10.00"N)
28
+ Lower Left ( 8d59'58.76"E, 51d59'59.90"N)
29
+ Upper Right ( 9d 0' 8.86"E, 52d 0'10.00"N)
30
+ Lower Right ( 9d 0' 8.86"E, 51d59'59.90"N)
31
+ Center ( 9d 0' 3.81"E, 52d 0' 4.95"N)
@@ -0,0 +1,10 @@
1
+ GeogToWGS84GeoKey5.tif is an sample GeoTIFF file for the GeogToWGS84GeoKey
2
+ geo key. After datum transformation to the WGS84 reference system the center
3
+ of the image (marked by a red pixel) should be exactly at N 52� E 9� in a
4
+ geographic coordinate system.
5
+
6
+ The output of listgeo is included as GeogToWGS84GeoKey5.lgo.
7
+
8
+ The files are placed in the public domain.
9
+
10
+ Christian Zietz <czietz@gmx.net>
@@ -0,0 +1,84 @@
1
+ Cyldindrical Equal Area
2
+ -----------------------
3
+
4
+ Frank Warmerdam
5
+ warmerdam@pobox.com
6
+
7
+ Created by reprojecting utm11-27.tif in pci_eg directory.
8
+
9
+ Geotiff_Information:
10
+ Version: 1
11
+ Key_Revision: 1.0
12
+ Tagged_Information:
13
+ ModelTiepointTag (2,3):
14
+ 0 0 0
15
+ -28493.1668 4255884.54 0
16
+ ModelPixelScaleTag (1,3):
17
+ 60.022137 60.022137 0
18
+ End_Of_Tags.
19
+ Keyed_Information:
20
+ GTModelTypeGeoKey (Short,1): ModelTypeProjected
21
+ GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
22
+ GTCitationGeoKey (Ascii,8): "unnamed"
23
+ GeographicTypeGeoKey (Short,1): GCS_NAD27
24
+ GeogCitationGeoKey (Ascii,6): "NAD27"
25
+ GeogAngularUnitsGeoKey (Short,1): Angular_Degree
26
+ ProjectedCSTypeGeoKey (Short,1): User-Defined
27
+ ProjectionGeoKey (Short,1): User-Defined
28
+ ProjCoordTransGeoKey (Short,1): CT_CylindricalEqualArea
29
+ ProjLinearUnitsGeoKey (Short,1): Linear_Meter
30
+ ProjStdParallel1GeoKey (Double,1): 33.75
31
+ ProjNatOriginLongGeoKey (Double,1): -117.333333
32
+ ProjFalseEastingGeoKey (Double,1): 0
33
+ ProjFalseNorthingGeoKey (Double,1): 0
34
+ End_Of_Keys.
35
+ End_Of_Geotiff.
36
+
37
+ Projection Method: CT_CylindricalEqualArea
38
+ ProjStdParallel1GeoKey: 33.750000 ( 33d45' 0.00"N)
39
+ ProjNatOriginLongGeoKey: -117.333333 (117d20' 0.00"W)
40
+ ProjFalseEastingGeoKey: 0.000000 m
41
+ ProjFalseNorthingGeoKey: 0.000000 m
42
+ GCS: 4267/NAD27
43
+ Datum: 6267/North American Datum 1927
44
+ Ellipsoid: 7008/Clarke 1866 (6378206.40,6356583.80)
45
+ Prime Meridian: 8901/Greenwich (0.000000/ 0d 0' 0.00"E)
46
+ Projection Linear Units: 9001/metre (1.000000m)
47
+
48
+ Corner Coordinates:
49
+ Upper Left ( -28493.167, 4255884.544) (117d38'28.21"W, 33d54'13.08"N)
50
+ Lower Left ( -28493.167, 4224973.143) (117d38'28.21"W, 33d37'30.66"N)
51
+ Upper Right ( 2358.212, 4255884.544) (117d18'28.28"W, 33d54'13.08"N)
52
+ Lower Right ( 2358.212, 4224973.143) (117d18'28.28"W, 33d37'30.66"N)
53
+ Center ( -13067.478, 4240428.844) (117d28'28.24"W, 33d45'51.47"N)
54
+
55
+ From gdalinfo:
56
+
57
+ Driver: GTiff/GeoTIFF
58
+ Size is 514, 515
59
+ Coordinate System is:
60
+ PROJCS["unnamed",
61
+ GEOGCS["NAD27",
62
+ DATUM["North_American_Datum_1927",
63
+ SPHEROID["Clarke 1866",6378206.4,294.9786982138982,
64
+ AUTHORITY["EPSG","7008"]],
65
+ AUTHORITY["EPSG","6267"]],
66
+ PRIMEM["Greenwich",0],
67
+ UNIT["degree",0.0174532925199433],
68
+ AUTHORITY["EPSG","4267"]],
69
+ PROJECTION["Cylindrical_Equal_Area"],
70
+ PARAMETER["standard_parallel_1",33.75],
71
+ PARAMETER["central_meridian",-117.333333333333],
72
+ PARAMETER["false_easting",0],
73
+ PARAMETER["false_northing",0],
74
+ UNIT["metre",1,
75
+ AUTHORITY["EPSG","9001"]]]
76
+ Origin = (-28493.166784,4255884.543802)
77
+ Pixel Size = (60.02213698,-60.02213698)
78
+ Corner Coordinates:
79
+ Upper Left ( -28493.167, 4255884.544) (117d38'28.21"W, 33d54'13.08"N)
80
+ Lower Left ( -28493.167, 4224973.143) (117d38'28.21"W, 33d37'30.66"N)
81
+ Upper Right ( 2358.212, 4255884.544) (117d18'28.28"W, 33d54'13.08"N)
82
+ Lower Right ( 2358.212, 4224973.143) (117d18'28.28"W, 33d37'30.66"N)
83
+ Center ( -13067.478, 4240428.844) (117d28'28.24"W, 33d45'51.47"N)
84
+ Band 1 Block=514x15 Type=Byte, ColorInterp=Gray
@@ -0,0 +1,45 @@
1
+ Geotiff_Information:
2
+ Version: 1
3
+ Key_Revision: 1.2
4
+ Tagged_Information:
5
+ ModelTransformationTag (4,4):
6
+ 0 0.18505098 0 -12.511
7
+ -0.300184211 0 0 109.036
8
+ 0 0 1 0
9
+ 0 0 0 1
10
+ End_Of_Tags.
11
+ Keyed_Information:
12
+ GTModelTypeGeoKey (Short,1): ModelTypeProjected
13
+ GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
14
+ ProjCoordTransGeoKey (Short,1): CT_Mercator
15
+ ProjectionGeoKey (Short,1): User-Defined
16
+ GeogGeodeticDatumGeoKey (Short,1): Datum_WGS84
17
+ GeogEllipsoidGeoKey (Short,1): Ellipse_WGS_84
18
+ ProjNatOriginLongGeoKey (Double,1): 0
19
+ ProjNatOriginLatGeoKey (Double,1): 0
20
+ ProjFalseEastingGeoKey (Double,1): 0
21
+ ProjFalseNorthingGeoKey (Double,1): 0
22
+ ProjCenterLatGeoKey (Double,1): 0
23
+ ProjScaleAtNatOriginGeoKey (Double,1): 1
24
+ PCSCitationGeoKey (Ascii,23): "Mercator; WGS84; WGS84"
25
+ ProjectedCSTypeGeoKey (Short,1): User-Defined
26
+ ProjLinearUnitsGeoKey (Short,1): Linear_Meter
27
+ End_Of_Keys.
28
+ End_Of_Geotiff.
29
+
30
+ Projection Method: CT_Mercator
31
+ ProjNatOriginLatGeoKey: 0.000000 ( 0d 0' 0.00"N)
32
+ ProjNatOriginLongGeoKey: 0.000000 ( 0d 0' 0.00"E)
33
+ ProjScaleAtNatOriginGeoKey: 1.000000
34
+ ProjFalseEastingGeoKey: 0.000000
35
+ ProjFalseNorthingGeoKey: 0.000000
36
+ Datum: 6326/World Geodetic System 1984
37
+ Ellipsoid: 7030/WGS 84 (6378137.00,6356752.31)
38
+ Projection Linear Units: 9001/metre (1.000000m)
39
+
40
+ Corner Coordinates:
41
+ Upper Left ( -12.511, 109.036) ( 0d 0' 0.40"W, 0d 0' 3.55"N)
42
+ Lower Left ( 129.053, 109.036) ( 0d 0' 4.17"E, 0d 0' 3.55"N)
43
+ Upper Right ( -12.511, -5.034) ( 0d 0' 0.40"W, 0d 0' 0.16"S)
44
+ Lower Right ( 129.053, -5.034) ( 0d 0' 4.17"E, 0d 0' 0.16"S)
45
+ Center ( 58.271, 52.001) ( 0d 0' 1.88"E, 0d 0' 1.69"N)
@@ -1,2 +1,32 @@
1
- TIF_FILES = Dir.glob('spec/support/images/osgeo/**/*.tif')
2
- warn 'No Tiff files for integration specs!' if TIF_FILES.empty?
1
+ require 'fileutils'
2
+
3
+ # Helper methods for integration specs.
4
+ module IntegrationHelp
5
+ def test_files
6
+ @test_files ||= []
7
+ end
8
+
9
+ def cleanup_test_files
10
+ test_files.each do |f|
11
+ FileUtils.rm(f) if File.exist?(f)
12
+ end
13
+ end
14
+
15
+ # @param original_path [String]
16
+ # @return [String]
17
+ def make_temp_test_file(original_path)
18
+ file_name = File.basename(original_path)
19
+ relative_tmp_path = File.join(temp_base_dir, file_name)
20
+ tmp_path = File.expand_path(relative_tmp_path, __dir__)
21
+
22
+ return tmp_path if test_files.include?(tmp_path)
23
+ FileUtils.cp(original_path, tmp_path)
24
+ test_files << tmp_path
25
+
26
+ tmp_path
27
+ end
28
+
29
+ def temp_base_dir
30
+ File.join(%w[.. .. tmp])
31
+ end
32
+ end
@@ -49,12 +49,6 @@ RSpec.shared_examples 'a major object' do
49
49
 
50
50
  describe '#description=' do
51
51
  context 'new description is a string' do
52
- around :example do |example|
53
- original_description = subject.description
54
- example.run
55
- subject.description = original_description
56
- end
57
-
58
52
  it 'sets the items description' do
59
53
  subject.description = 'a test description'
60
54
  expect(subject.description).to eq 'a test description'
@@ -1,5 +1,5 @@
1
1
  RSpec.shared_examples 'a geometry' do
2
- require 'ogr/spatial_reference'
2
+ require 'ogr'
3
3
 
4
4
  describe '#coordinate_dimension' do
5
5
  subject { geometry.coordinate_dimension }
@@ -36,7 +36,7 @@ RSpec.describe FFI::GDAL do
36
36
  end
37
37
 
38
38
  it 'returns GDAL_LIBRARY_PATH' do
39
- expect(described_class.search_paths).to match /\A\/pants\z/
39
+ expect(described_class.search_paths).to match %r{\A\/pants\z}
40
40
  end
41
41
  end
42
42
 
@@ -2,4 +2,5 @@ require 'spec_helper'
2
2
  require 'gdal/color_entry'
3
3
 
4
4
  RSpec.describe GDAL::ColorEntry do
5
+ pending 'Add some tests!'
5
6
  end
@@ -2,4 +2,5 @@ require 'spec_helper'
2
2
  require 'gdal/color_interpretation'
3
3
 
4
4
  RSpec.describe GDAL::ColorInterpretation do
5
+ pending 'Add some tests!'
5
6
  end
@@ -7,7 +7,31 @@ RSpec.describe GDAL::Dataset do
7
7
  end
8
8
 
9
9
  subject do
10
- described_class.open(file_path, 'r')
10
+ described_class.open(file_path, 'r', false)
11
+ end
12
+
13
+ it_behaves_like 'a major object'
14
+
15
+ describe '.open' do
16
+ context 'not a dataset' do
17
+ it 'raises an GDAL::OpenFailure' do
18
+ expect do
19
+ described_class.open('blarg', 'r')
20
+ end.to raise_exception GDAL::OpenFailure
21
+ end
22
+ end
23
+
24
+ context 'block given' do
25
+ let(:dataset) { instance_double 'GDAL::Dataset' }
26
+
27
+ it 'yields then closes the opened DataSource' do
28
+ allow(described_class).to receive(:new).and_return dataset
29
+
30
+ expect(dataset).to receive(:close)
31
+ expect { |b| described_class.open('blarg', 'r', &b) }.
32
+ to yield_with_args(dataset)
33
+ end
34
+ end
11
35
  end
12
36
 
13
37
  describe '#access_flag' do
@@ -74,8 +98,15 @@ RSpec.describe GDAL::Dataset do
74
98
  end
75
99
 
76
100
  describe '#projection' do
101
+ let(:expected_wkt) do
102
+ 'GEOGCS["unknown",DATUM["unknown",SPHEROID["Bessel 1841",' \
103
+ '6377397.155,299.1528128000008,AUTHORITY["EPSG","7004"]],' \
104
+ 'TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.7]],' \
105
+ 'PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'
106
+ end
107
+
77
108
  it 'returns the projection string' do
78
- expect(subject.projection).to eq %(GEOGCS[\"unknown\",DATUM[\"unknown\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128000008,AUTHORITY[\"EPSG\",\"7004\"]],TOWGS84[598.1,73.7,418.2,0.202,0.045,-2.455,6.7]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]])
109
+ expect(subject.projection).to eq expected_wkt
79
110
  end
80
111
  end
81
112
 
@@ -92,4 +123,24 @@ RSpec.describe GDAL::Dataset do
92
123
  expect(subject.geo_transform).to be_a GDAL::GeoTransform
93
124
  end
94
125
  end
126
+
127
+ describe '#parse_mask_flag_symbols' do
128
+ context 'empty params' do
129
+ it 'returns 0' do
130
+ expect(subject.send(:parse_mask_flag_symbols, nil)).to eq 0
131
+ end
132
+ end
133
+
134
+ context ':GMF_ALL_VALID' do
135
+ it 'returns 1' do
136
+ expect(subject.send(:parse_mask_flag_symbols, :GMF_ALL_VALID)).to eq 1
137
+ end
138
+ end
139
+
140
+ context ':GMF_ALL_VALID, :GMF_NODATA' do
141
+ it 'returns 1' do
142
+ expect(subject.send(:parse_mask_flag_symbols, :GMF_ALL_VALID, :GMF_NODATA)).to eq 9
143
+ end
144
+ end
145
+ end
95
146
  end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+ require 'gdal/geo_transform'
3
+ require 'gdal/geo_transform_mixins/extensions'
4
+
5
+ RSpec.describe GDAL::GeoTransformMixins::Extensions do
6
+ let(:subject_class) do
7
+ Class.new do |c|
8
+ c.send :include, GDAL::GeoTransformMixins::Extensions
9
+ c
10
+ end
11
+ end
12
+
13
+ subject do
14
+ gt = GDAL::GeoTransform.new
15
+ gt.x_origin = 90
16
+ gt.y_origin = -90
17
+ gt.pixel_width = 0
18
+ gt.pixel_height = 0
19
+
20
+ gt
21
+ end
22
+
23
+ describe '.new_from_envelope' do
24
+ let(:envelope) { instance_double 'OGR::Envelope' }
25
+
26
+ it 'builds a new GeoTransform using the extent values from the Envelope' do
27
+ expect(envelope).to receive(:x_min).and_return(90)
28
+ expect(envelope).to receive(:y_min).and_return(-90)
29
+ expect(envelope).to receive(:x_size).and_return(1.5)
30
+ expect(envelope).to receive(:y_size).and_return(0.5)
31
+
32
+ gt = subject_class.new_from_envelope(envelope, 300, 200)
33
+ expect(gt).to be_a_instance_of(GDAL::GeoTransform)
34
+ expect(gt.x_origin).to eq(90)
35
+ expect(gt.y_origin).to eq(-90)
36
+ expect(gt.x_rotation).to eq(0)
37
+ expect(gt.y_rotation).to eq(0)
38
+ expect(gt.pixel_width).to eq(0.005)
39
+ expect(gt.pixel_height).to eq(0.0025)
40
+ end
41
+ end
42
+
43
+ describe '#world_to_pixel' do
44
+ context 'non-zero pixel width and height' do
45
+ subject do
46
+ gt = GDAL::GeoTransform.new
47
+ gt.x_origin = 90
48
+ gt.y_origin = -90
49
+ gt.pixel_width = 1
50
+ gt.pixel_height = 0.5
51
+
52
+ gt
53
+ end
54
+
55
+ it 'returns a pixel: and line: Hash with according values' do
56
+ expect(subject.world_to_pixel(0, 0)).to eq(pixel: -90, line: -180)
57
+ end
58
+ end
59
+
60
+ context 'zero pixel width and height' do
61
+ it 'returns a pixel: and line: Hash with according values' do
62
+ expect { subject.world_to_pixel(0, 0) }.
63
+ to raise_exception GDAL::InvalidGeoTransform
64
+ end
65
+ end
66
+ end
67
+ end
@@ -227,7 +227,7 @@ RSpec.describe GDAL::GeoTransform do
227
227
  end
228
228
 
229
229
  it 'returns an inverted y_origin' do
230
- expect(subject.y_origin).to eq (-1600.0)
230
+ expect(subject.y_origin).to eq(-1600.0)
231
231
  end
232
232
 
233
233
  it 'returns an inverted pixel_height' do
@@ -2,4 +2,87 @@ require 'spec_helper'
2
2
  require 'gdal/grid'
3
3
 
4
4
  RSpec.describe GDAL::Grid do
5
+ subject(:grid) { described_class.new(:metric_count) }
6
+
7
+ describe 'attributes' do
8
+ it { is_expected.to respond_to :data_type }
9
+ it { is_expected.to respond_to :data_type= }
10
+ it { is_expected.to respond_to :algorithm_options }
11
+ it { is_expected.to respond_to :algorithm_type }
12
+ it { is_expected.to respond_to :algorithm_type }
13
+ end
14
+
15
+ describe '#make_points_pointer' do
16
+ context 'array has values' do
17
+ let(:points) { [1, 2, 3, 4] }
18
+
19
+ it 'creates a FFI::MemoryPointer from the given array of points' do
20
+ pointer = subject.send(:make_points_pointer, points)
21
+ expect(pointer).to be_an_instance_of FFI::MemoryPointer
22
+ expect(pointer.read_array_of_double(points.length)).to eq(points)
23
+ end
24
+ end
25
+
26
+ context 'array has only nil values' do
27
+ let(:points) { [nil, nil] }
28
+
29
+ it 'raises a GDAL::Error' do
30
+ expect { subject.send(:make_points_pointer, points) }.to raise_error GDAL::Error
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '#init_algorithm' do
36
+ context 'inverse_distance_to_a_power' do
37
+ subject { grid.send(:init_algorithm, :inverse_distance_to_a_power) }
38
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::InverseDistanceToAPower) }
39
+ end
40
+
41
+ context 'moving_average' do
42
+ subject { grid.send(:init_algorithm, :moving_average) }
43
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MovingAverage) }
44
+ end
45
+
46
+ context 'nearest_neighbor' do
47
+ subject { grid.send(:init_algorithm, :nearest_neighbor) }
48
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::NearestNeighbor) }
49
+ end
50
+
51
+ context 'metric_average_distance' do
52
+ subject { grid.send(:init_algorithm, :metric_average_distance) }
53
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricAverageDistance) }
54
+ end
55
+
56
+ context 'metric_average_distance_pts' do
57
+ subject { grid.send(:init_algorithm, :metric_average_distance_pts) }
58
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricAverageDistancePts) }
59
+ end
60
+
61
+ context 'metric_count' do
62
+ subject { grid.send(:init_algorithm, :metric_count) }
63
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricCount) }
64
+ end
65
+
66
+ context 'metric_maximum' do
67
+ subject { grid.send(:init_algorithm, :metric_maximum) }
68
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricMaximum) }
69
+ end
70
+
71
+ context 'metric_minimum' do
72
+ subject { grid.send(:init_algorithm, :metric_minimum) }
73
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricMinimum) }
74
+ end
75
+
76
+ context 'metric_range' do
77
+ subject { grid.send(:init_algorithm, :metric_range) }
78
+ it { is_expected.to be_an_instance_of(GDAL::GridAlgorithms::MetricRange) }
79
+ end
80
+
81
+ context 'unknown algorithm' do
82
+ it 'raises a GDAL::UnknownGridAlgorithm' do
83
+ expect { grid.send(:init_algorithm, :metric_pants) }.
84
+ to raise_exception(GDAL::UnknownGridAlgorithm)
85
+ end
86
+ end
87
+ end
5
88
  end
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'gdal/gridder'
3
+
4
+ RSpec.describe GDAL::Gridder do
5
+ let(:source_layer) { instance_double 'OGR::Layer' }
6
+ let(:dest_file_name) { 'blah.docx' }
7
+ let(:gridder_options) { instance_double 'GDAL::GridderOptions' }
8
+
9
+ subject(:gridder) { described_class.new(source_layer, dest_file_name, gridder_options) }
10
+
11
+ describe '#points' do
12
+ let(:clipping_geometry) { instance_double 'OGR::LineString' }
13
+
14
+ before do
15
+ expect(subject).to receive(:ensure_z_values)
16
+ allow(gridder_options).to receive(:input_clipping_geometry).and_return clipping_geometry
17
+ end
18
+
19
+ context 'input_field_name is set' do
20
+ before { allow(gridder_options).to receive(:input_field_name).and_return 'things' }
21
+
22
+ it 'gets points with attributes by the input_field_name' do
23
+ expect(subject).to receive(:points_with_field_attributes).
24
+ with(source_layer, 'things', clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
25
+
26
+ subject.points
27
+ end
28
+
29
+ it 'returns an NArray' do
30
+ allow(subject).to receive(:points_with_field_attributes).
31
+ with(source_layer, 'things', clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
32
+
33
+ expect(subject.points).to eq([[0, 0, 0], [1, 1, 1]])
34
+ end
35
+ end
36
+
37
+ context 'input_field_name is not set' do
38
+ before { allow(gridder_options).to receive(:input_field_name).and_return nil }
39
+
40
+ it 'gets points with attributes without the input_field_name' do
41
+ expect(subject).to receive(:points_no_field_attributes).
42
+ with(source_layer, clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
43
+
44
+ subject.points
45
+ end
46
+
47
+ it 'returns an NArray' do
48
+ allow(subject).to receive(:points_no_field_attributes).
49
+ with(source_layer, clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
50
+
51
+ expect(subject.points).to eq([[0, 0, 0], [1, 1, 1]])
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#ensure_z_values' do
57
+ context 'layer does not have a field by the requested name' do
58
+ before do
59
+ allow(subject).to receive(:layer_missing_specified_field?).and_return true
60
+ allow(gridder_options).to receive(:input_field_name).and_return 'meow'
61
+ end
62
+
63
+ it 'raises an OGR::InvalidFieldName' do
64
+ expect { subject.send(:ensure_z_values) }.to raise_exception OGR::InvalidFieldName
65
+ end
66
+ end
67
+
68
+ context 'no requested field name set and layer has no geometries with Z values' do
69
+ before do
70
+ allow(subject).to receive(:layer_missing_specified_field?).and_return false
71
+ allow(gridder_options).to receive(:input_field_name).and_return nil
72
+ allow(source_layer).to receive(:any_geometries_with_z?).and_return false
73
+ allow(source_layer).to receive(:name).and_return 'meow'
74
+ end
75
+
76
+ it 'raises an GDAL::NoValuesToGrid' do
77
+ expect { subject.send(:ensure_z_values) }.to raise_exception GDAL::NoValuesToGrid
78
+ end
79
+ end
80
+ end
81
+
82
+ describe '#layer_missing_specified_field?' do
83
+ subject { gridder.send(:layer_missing_specified_field?) }
84
+
85
+ context 'input_field_name not set' do
86
+ before { allow(gridder_options).to receive(:input_field_name).and_return nil }
87
+ it { is_expected.to be false }
88
+ end
89
+
90
+ context 'input_field_name set but layer does not contain fields with that name' do
91
+ before do
92
+ allow(gridder_options).to receive(:input_field_name).and_return 'things'
93
+ expect(source_layer).to receive(:find_field_index).with('things').and_return nil
94
+ end
95
+
96
+ it { is_expected.to be true }
97
+ end
98
+ end
99
+ end