ffi-gdal 1.0.0.beta3 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +62 -0
- data/Gemfile +1 -1
- data/History.md +53 -28
- data/README.md +6 -0
- data/Rakefile +23 -1
- data/examples/extract_and_colorize.rb +21 -22
- data/examples/geometries.rb +2 -2
- data/examples/gridding.rb +106 -0
- data/examples/ogr_layer_to_layer.rb +1 -1
- data/examples/points.txt +127 -0
- data/examples/testing_gdal.rb +3 -4
- data/ffi-gdal.gemspec +3 -2
- data/lib/ext/error_symbols.rb +2 -57
- data/lib/ext/ffi_library_function_checks.rb +26 -0
- data/lib/ext/float_ext.rb +2 -2
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +19 -0
- data/lib/ext/to_bool.rb +4 -4
- data/lib/ffi/cpl/conv.rb +132 -0
- data/lib/ffi/cpl/error.rb +67 -0
- data/lib/ffi/cpl/hash_set.rb +39 -0
- data/lib/ffi/cpl/http.rb +25 -0
- data/lib/ffi/cpl/http_result.rb +18 -0
- data/lib/ffi/cpl/list.rb +38 -0
- data/lib/ffi/cpl/mime_part.rb +11 -0
- data/lib/ffi/cpl/minixml.rb +47 -0
- data/lib/ffi/cpl/port.rb +23 -0
- data/lib/ffi/cpl/quad_tree.rb +51 -0
- data/lib/ffi/{ogr/ogr_envelope.rb → cpl/rect_obj.rb} +3 -3
- data/lib/ffi/cpl/string.rb +95 -0
- data/lib/ffi/cpl/vsi.rb +115 -0
- data/lib/ffi/cpl/xml_node.rb +6 -6
- data/lib/ffi/gdal/alg.rb +385 -0
- data/lib/ffi/gdal/{gdal_color_entry.rb → color_entry.rb} +1 -2
- data/lib/ffi/gdal/exceptions.rb +6 -0
- data/lib/ffi/gdal/{gdal_gcp.rb → gcp.rb} +1 -3
- data/lib/ffi/gdal/{gdal_h.rb → gdal.rb} +253 -252
- data/lib/ffi/gdal/grid.rb +58 -0
- data/lib/ffi/gdal/{gdal_grid_data_metrics_options.rb → grid_data_metrics_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_inverse_distance_to_a_power_options.rb → grid_inverse_distance_to_a_power_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_moving_average_options.rb → grid_moving_average_options.rb} +1 -2
- data/lib/ffi/gdal/{gdal_grid_nearest_neighbor_options.rb → grid_nearest_neighbor_options.rb} +1 -2
- data/lib/ffi/gdal/matching.rb +20 -0
- data/lib/ffi/gdal/{gdal_rpc_info.rb → rpc_info.rb} +1 -2
- data/lib/ffi/gdal/{gdal_transformer_info.rb → transformer_info.rb} +1 -2
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +92 -0
- data/lib/ffi/gdal/{gdal_warp_options.rb → warp_options.rb} +8 -4
- data/lib/ffi/gdal/warper.rb +70 -0
- data/lib/ffi/gdal.rb +56 -69
- data/lib/ffi/ogr/api.rb +567 -0
- data/lib/ffi/ogr/{ogr_contour_writer_info.rb → contour_writer_info.rb} +2 -3
- data/lib/ffi/ogr/core.rb +181 -0
- data/lib/ffi/ogr/envelope.rb +12 -0
- data/lib/ffi/ogr/{ogr_envelope_3d.rb → envelope_3d.rb} +2 -2
- data/lib/ffi/ogr/featurestyle.rb +29 -0
- data/lib/ffi/ogr/field.rb +63 -0
- data/lib/ffi/ogr/geocoding.rb +30 -0
- data/lib/ffi/ogr/srs_api.rb +407 -0
- data/lib/ffi/ogr/style_param.rb +13 -0
- data/lib/ffi/ogr/{ogr_style_value.rb → style_value.rb} +4 -3
- data/lib/ffi/ogr.rb +7 -7
- data/lib/ffi-gdal.rb +7 -145
- data/lib/gdal/color_entry.rb +18 -14
- data/lib/gdal/color_entry_mixins/extensions.rb +32 -0
- data/lib/gdal/color_interpretation.rb +2 -2
- data/lib/gdal/color_table.rb +37 -32
- data/lib/gdal/color_table_mixins/extensions.rb +48 -0
- data/lib/gdal/cpl_error_handler.rb +119 -0
- data/lib/gdal/data_type.rb +7 -7
- data/lib/gdal/dataset.rb +131 -238
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +182 -0
- data/lib/gdal/dataset_mixins/extensions.rb +542 -0
- data/lib/gdal/dataset_mixins/matching.rb +26 -0
- data/lib/gdal/driver.rb +68 -92
- data/lib/gdal/driver_mixins/extensions.rb +93 -0
- data/lib/gdal/exceptions.rb +32 -4
- data/lib/gdal/geo_transform.rb +63 -43
- data/lib/gdal/geo_transform_mixins/extensions.rb +57 -0
- data/lib/gdal/grid.rb +144 -0
- data/lib/gdal/grid_types/data_metrics_base.rb +14 -0
- data/lib/gdal/grid_types/inverse_distance_to_a_power.rb +19 -0
- data/lib/gdal/grid_types/metric_average_distance.rb +12 -0
- data/lib/gdal/grid_types/metric_average_distance_pts.rb +12 -0
- data/lib/gdal/grid_types/metric_count.rb +12 -0
- data/lib/gdal/grid_types/metric_maximum.rb +12 -0
- data/lib/gdal/grid_types/metric_minimum.rb +12 -0
- data/lib/gdal/grid_types/metric_range.rb +12 -0
- data/lib/gdal/grid_types/moving_average.rb +19 -0
- data/lib/gdal/grid_types/nearest_neighbor.rb +19 -0
- data/lib/gdal/grid_types.rb +22 -0
- data/lib/gdal/internal_helpers.rb +94 -0
- data/lib/gdal/major_object.rb +4 -7
- data/lib/gdal/options.rb +14 -7
- data/lib/gdal/raster_attribute_table.rb +38 -47
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +41 -0
- data/lib/gdal/raster_band.rb +193 -227
- data/lib/gdal/raster_band_classifier.rb +107 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +292 -0
- data/lib/gdal/raster_band_mixins/extensions.rb +238 -0
- data/lib/gdal/rpc_info.rb +35 -0
- data/lib/gdal/transformer.rb +15 -0
- data/lib/gdal/transformers/approximate_transformer.rb +48 -0
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +45 -0
- data/lib/gdal/transformers/gcp_transformer.rb +55 -0
- data/lib/gdal/transformers/general_image_projection_transformer.rb +31 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +52 -0
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +25 -0
- data/lib/gdal/transformers/geolocation_transformer.rb +42 -0
- data/lib/gdal/transformers/reprojection_transformer.rb +39 -0
- data/lib/gdal/transformers/rpc_transformer.rb +56 -0
- data/lib/gdal/transformers/tps_transformer.rb +40 -0
- data/lib/gdal/virtual_dataset.rb +96 -0
- data/lib/gdal/warp_operation.rb +20 -23
- data/lib/gdal.rb +17 -0
- data/lib/ogr/coordinate_transformation.rb +16 -41
- data/lib/ogr/data_source.rb +103 -58
- data/lib/ogr/data_source_extensions.rb +5 -6
- data/lib/ogr/data_source_mixins/capability_methods.rb +27 -0
- data/lib/ogr/driver.rb +61 -33
- data/lib/ogr/driver_mixins/capability_methods.rb +16 -0
- data/lib/ogr/envelope.rb +29 -18
- data/lib/ogr/envelope_extensions.rb +70 -49
- data/lib/ogr/error_handling.rb +46 -0
- data/lib/ogr/exceptions.rb +58 -12
- data/lib/ogr/feature.rb +334 -86
- data/lib/ogr/feature_definition.rb +94 -51
- data/lib/ogr/feature_definition_extensions.rb +36 -13
- data/lib/ogr/feature_extensions.rb +62 -11
- data/lib/ogr/field.rb +175 -54
- data/lib/ogr/field_definition.rb +110 -0
- data/lib/ogr/{field_extensions.rb → field_definition_extensions.rb} +4 -5
- data/lib/ogr/{geocoding_session.rb → geocoder.rb} +14 -13
- data/lib/ogr/geometries/geometry_collection.rb +13 -0
- data/lib/ogr/geometries/line_string.rb +35 -0
- data/lib/ogr/geometries/linear_ring.rb +11 -0
- data/lib/ogr/geometries/multi_line_string.rb +16 -0
- data/lib/ogr/geometries/multi_point.rb +14 -0
- data/lib/ogr/geometries/multi_polygon.rb +21 -0
- data/lib/ogr/geometries/none_geometry.rb +13 -0
- data/lib/ogr/geometries/point.rb +65 -0
- data/lib/ogr/geometries/point_extensions.rb +32 -0
- data/lib/ogr/geometries/polygon.rb +14 -0
- data/lib/ogr/geometries/unknown_geometry.rb +10 -0
- data/lib/ogr/geometry.rb +270 -242
- data/lib/ogr/geometry_extensions.rb +8 -9
- data/lib/ogr/geometry_field_definition.rb +99 -0
- data/lib/ogr/geometry_field_definition_extensions.rb +19 -0
- data/lib/ogr/geometry_types/container.rb +75 -0
- data/lib/ogr/geometry_types/curve.rb +25 -28
- data/lib/ogr/geometry_types/surface.rb +13 -4
- data/lib/ogr/internal_helpers.rb +57 -0
- data/lib/ogr/layer.rb +60 -181
- data/lib/ogr/layer_mixins/capability_methods.rb +102 -0
- data/lib/ogr/layer_mixins/extensions.rb +59 -0
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +127 -0
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +143 -0
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +163 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +89 -0
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +48 -0
- data/lib/ogr/spatial_reference.rb +108 -589
- data/lib/ogr/spatial_reference_extensions.rb +29 -3
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +494 -0
- data/lib/ogr/spatial_reference_mixins/exporters.rb +134 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +243 -0
- data/lib/ogr/spatial_reference_mixins/morphers.rb +25 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +122 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +62 -0
- data/lib/ogr/style_table.rb +53 -5
- data/lib/ogr/style_table_extensions.rb +21 -5
- data/lib/ogr/style_tool.rb +118 -0
- data/lib/ogr.rb +8 -0
- data/spec/ffi-gdal_spec.rb +1 -2
- data/spec/integration/{color_table_info_spec.rb → gdal/color_table_info_spec.rb} +12 -12
- data/spec/integration/{dataset_info_spec.rb → gdal/dataset_info_spec.rb} +2 -6
- data/spec/integration/{driver_info_spec.rb → gdal/driver_info_spec.rb} +5 -5
- data/spec/integration/{geo_transform_info_spec.rb → gdal/geo_transform_info_spec.rb} +1 -14
- data/spec/integration/{raster_attribute_table_info_spec.rb → gdal/raster_attribute_table_info_spec.rb} +1 -2
- data/spec/integration/{raster_band_info_spec.rb → gdal/raster_band_info_spec.rb} +30 -42
- data/spec/integration/ogr/layer_spec.rb +97 -0
- data/spec/spec_helper.rb +94 -5
- data/spec/support/integration_help.rb +1 -0
- data/spec/support/shared_contexts.rb +26 -0
- data/spec/support/shared_examples/{major_object_examples.rb → gdal/major_object_examples.rb} +5 -5
- data/spec/support/shared_examples/ogr/a_25D_geometry.rb +7 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +47 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +404 -0
- data/spec/support/shared_examples/ogr/a_line_string.rb +16 -0
- data/spec/support/test_style_table.txt +3 -0
- data/spec/unit/ext/error_symbols_spec.rb +41 -53
- data/spec/unit/ext/numeric_as_data_type_spec.rb +113 -0
- data/spec/unit/ffi/gdal_spec.rb +70 -0
- data/spec/unit/gdal/color_entry_spec.rb +5 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +5 -0
- data/spec/unit/gdal/{color_table_extensions_spec.rb → color_table_mixins/extensions_spec.rb} +3 -3
- data/spec/unit/gdal/color_table_spec.rb +14 -16
- data/spec/unit/gdal/data_type_spec.rb +10 -17
- data/spec/unit/gdal/dataset_spec.rb +4 -7
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +22 -0
- data/spec/unit/gdal/driver_spec.rb +49 -0
- data/spec/unit/gdal/environment_methods_spec.rb +6 -0
- data/spec/unit/gdal/geo_transform_spec.rb +276 -0
- data/spec/unit/gdal/grid_spec.rb +5 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +112 -0
- data/spec/unit/gdal/major_object_spec.rb +6 -0
- data/spec/unit/gdal/options_spec.rb +5 -0
- data/spec/unit/gdal/raster_attribute_table_spec.rb +5 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +134 -0
- data/spec/unit/gdal/raster_band_spec.rb +5 -0
- data/spec/unit/gdal/rpc_info_spec.rb +5 -0
- data/spec/unit/gdal/version_info_spec.rb +6 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +32 -0
- data/spec/unit/gdal/warp_operation_spec.rb +5 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +30 -0
- data/spec/unit/ogr/data_source_spec.rb +209 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +18 -0
- data/spec/unit/ogr/driver_spec.rb +150 -0
- data/spec/unit/ogr/envelope_spec.rb +322 -0
- data/spec/unit/ogr/feature_definition_spec.rb +313 -0
- data/spec/unit/ogr/feature_spec.rb +379 -0
- data/spec/unit/ogr/field_definition_spec.rb +135 -0
- data/spec/unit/ogr/field_spec.rb +193 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +186 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +105 -0
- data/spec/unit/ogr/{linear_ring_spec.rb → geometries/linear_ring_spec.rb} +10 -31
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +14 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +41 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +12 -0
- data/spec/unit/ogr/{point_spec.rb → geometries/point_spec.rb} +19 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +17 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +10 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +87 -0
- data/spec/unit/ogr/geometry_spec.rb +542 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +57 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +88 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +145 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +432 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +20 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +42 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +12 -0
- data/spec/unit/ogr/layer_spec.rb +66 -67
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +46 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +139 -0
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +38 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +36 -0
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +102 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +157 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +42 -0
- data/spec/unit/ogr/style_table_spec.rb +132 -0
- data/spec/unit/ogr/style_tool_spec.rb +157 -0
- data/spec/unit/version_info_spec.rb +1 -1
- metadata +285 -75
- data/lib/ffi/cpl/conv_h.rb +0 -143
- data/lib/ffi/cpl/error_h.rb +0 -63
- data/lib/ffi/cpl/minixml_h.rb +0 -14
- data/lib/ffi/cpl/string_h.rb +0 -81
- data/lib/ffi/cpl/vsi_h.rb +0 -112
- data/lib/ffi/gdal/alg_h.rb +0 -127
- data/lib/ffi/gdal/grid_h.rb +0 -51
- data/lib/ffi/gdal/warper_h.rb +0 -48
- data/lib/ffi/ogr/api_h.rb +0 -553
- data/lib/ffi/ogr/core_h.rb +0 -148
- data/lib/ffi/ogr/featurestyle_h.rb +0 -22
- data/lib/ffi/ogr/geocoding_h.rb +0 -21
- data/lib/ffi/ogr/ogr_field.rb +0 -50
- data/lib/ffi/ogr/ogr_style_param.rb +0 -12
- data/lib/ffi/ogr/srs_api_h.rb +0 -325
- data/lib/gdal/color_entry_extensions.rb +0 -30
- data/lib/gdal/color_table_extensions.rb +0 -47
- data/lib/gdal/dataset_extensions.rb +0 -496
- data/lib/gdal/driver_extensions.rb +0 -56
- data/lib/gdal/geo_transform_extensions.rb +0 -90
- data/lib/gdal/raster_attribute_table_extensions.rb +0 -40
- data/lib/gdal/raster_band_extensions.rb +0 -198
- data/lib/ogr/geometry_types/collection.rb +0 -45
- data/lib/ogr/layer_extensions.rb +0 -55
- data/lib/ogr/line_string.rb +0 -7
- data/lib/ogr/linear_ring.rb +0 -6
- data/lib/ogr/multi_line_string.rb +0 -9
- data/lib/ogr/multi_point.rb +0 -7
- data/lib/ogr/multi_polygon.rb +0 -14
- data/lib/ogr/point.rb +0 -89
- data/lib/ogr/polygon.rb +0 -9
@@ -0,0 +1,243 @@
|
|
1
|
+
module OGR
|
2
|
+
module SpatialReferenceMixins
|
3
|
+
module Importers
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
# @param code [Fixnum]
|
10
|
+
# @return [OGR::SpatialReference]
|
11
|
+
def new_from_epsg(code)
|
12
|
+
srs = new
|
13
|
+
srs.import_from_epsg(code)
|
14
|
+
|
15
|
+
srs
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param code [Fixnum]
|
19
|
+
# @return [OGR::SpatialReference]
|
20
|
+
def new_from_epsga(code)
|
21
|
+
srs = new
|
22
|
+
srs.import_from_epsg(code)
|
23
|
+
|
24
|
+
srs
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param projection_name [String] I.e. "NUTM11" or "GEOGRAPHIC".
|
28
|
+
# @param datum_name [String] I.e. "NAD83".
|
29
|
+
# @param linear_unit_name [String] Plural form of linear units, i.e. "FEET".
|
30
|
+
# @return [OGR::SpatialReference]
|
31
|
+
def new_from_erm(projection_name, datum_name, linear_unit_name)
|
32
|
+
srs = new
|
33
|
+
srs.import_from_erm(projection_name, datum_name, linear_unit_name)
|
34
|
+
|
35
|
+
srs
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param prj_text [Array<String>]
|
39
|
+
# @return [OGR::SpatialReference]
|
40
|
+
def new_from_esri(prj_text)
|
41
|
+
srs = new
|
42
|
+
srs.import_from_esri(prj_text)
|
43
|
+
|
44
|
+
srs
|
45
|
+
end
|
46
|
+
|
47
|
+
# @param coord_sys [String] The Mapinfo style CoordSys definition string.
|
48
|
+
# @return [OGR::SpatialReference]
|
49
|
+
def new_from_mapinfo(coord_sys)
|
50
|
+
srs = new
|
51
|
+
srs.import_from_mapinfo(coord_sys)
|
52
|
+
|
53
|
+
srs
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param proj [String]
|
57
|
+
# @param units [String]
|
58
|
+
# @param proj_params [Array<String>]
|
59
|
+
# @return [OGR::SpatialReference]
|
60
|
+
def new_from_pci(proj, units, *proj_params)
|
61
|
+
srs = new
|
62
|
+
srs.import_from_pci(proj, units, *proj_params)
|
63
|
+
|
64
|
+
srs
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param proj4 [String]
|
68
|
+
# @return [OGR::SpatialReference]
|
69
|
+
def new_from_proj4(proj4)
|
70
|
+
srs = new
|
71
|
+
srs.import_from_proj4(proj4)
|
72
|
+
|
73
|
+
srs
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param url [String] URL to fetch the spatial reference from.
|
77
|
+
# @return [OGR::SpatialReference]
|
78
|
+
def new_from_url(url)
|
79
|
+
srs = new
|
80
|
+
srs.import_from_url(url)
|
81
|
+
|
82
|
+
srs
|
83
|
+
end
|
84
|
+
|
85
|
+
# @param projection_system_code
|
86
|
+
# @return [OGR::SpatialReference]
|
87
|
+
def new_from_usgs(projection_system_code, zone, datum, *proj_params)
|
88
|
+
srs = new
|
89
|
+
srs.import_from_usgs(projection_system_code, zone, datum, *proj_params)
|
90
|
+
|
91
|
+
srs
|
92
|
+
end
|
93
|
+
|
94
|
+
# This wipes the existing SRS definition and reassigns it based on the
|
95
|
+
# contents of +wkt+.
|
96
|
+
#
|
97
|
+
# @param wkt [String]
|
98
|
+
# @return [OGR::SpatialReference]
|
99
|
+
def new_from_wkt(wkt)
|
100
|
+
srs = new
|
101
|
+
srs.import_from_wkt(wkt)
|
102
|
+
|
103
|
+
srs
|
104
|
+
end
|
105
|
+
|
106
|
+
# Use for importing a GML coordinate system.
|
107
|
+
#
|
108
|
+
# @param xml [String]
|
109
|
+
# @return [OGR::SpatialReference]
|
110
|
+
def new_from_xml(xml)
|
111
|
+
srs = new
|
112
|
+
srs.import_from_xml(xml)
|
113
|
+
|
114
|
+
srs
|
115
|
+
end
|
116
|
+
|
117
|
+
# @return [OGR::SpatialReference]
|
118
|
+
def build_spatial_ref(spatial_reference_or_wkt = nil)
|
119
|
+
object = new(spatial_reference_or_wkt)
|
120
|
+
ogr_err = yield object.c_pointer
|
121
|
+
ogr_err.handle_result
|
122
|
+
|
123
|
+
object
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# @param code [Fixnum]
|
128
|
+
# @raise [GDAL::UnsupportedOperation] On unknown EPSG code.
|
129
|
+
def import_from_epsg(code)
|
130
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromEPSG(@c_pointer, code)
|
131
|
+
|
132
|
+
ogr_err.handle_result
|
133
|
+
end
|
134
|
+
|
135
|
+
# @param code [Fixnum]
|
136
|
+
def import_from_epsga(code)
|
137
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromEPSGA(@c_pointer, code)
|
138
|
+
|
139
|
+
ogr_err.handle_result
|
140
|
+
end
|
141
|
+
|
142
|
+
# @param wkt [String]
|
143
|
+
def import_from_wkt(wkt)
|
144
|
+
wkt_ptr = FFI::MemoryPointer.from_string(wkt)
|
145
|
+
wkt_ptr_ptr = FFI::MemoryPointer.new(:pointer)
|
146
|
+
wkt_ptr_ptr.write_pointer(wkt_ptr)
|
147
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromWkt(@c_pointer, wkt_ptr_ptr)
|
148
|
+
|
149
|
+
ogr_err.handle_result
|
150
|
+
end
|
151
|
+
|
152
|
+
# @param proj4 [String]
|
153
|
+
def import_from_proj4(proj4)
|
154
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromProj4(@c_pointer, proj4)
|
155
|
+
|
156
|
+
ogr_err.handle_result
|
157
|
+
end
|
158
|
+
|
159
|
+
# @param esri_text [Array<String>]
|
160
|
+
def import_from_esri(esri_text)
|
161
|
+
text_array = esri_text.split("\n")
|
162
|
+
esri_ptr_ptr = GDAL._string_array_to_pointer(text_array)
|
163
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromESRI(@c_pointer, esri_ptr_ptr)
|
164
|
+
|
165
|
+
ogr_err.handle_result
|
166
|
+
end
|
167
|
+
|
168
|
+
# @param proj [String]
|
169
|
+
# @param units [String]
|
170
|
+
# @param proj_params [Array<String>]
|
171
|
+
def import_from_pci(proj, units, *proj_params)
|
172
|
+
if proj_params.empty?
|
173
|
+
proj_ptr = nil
|
174
|
+
else
|
175
|
+
proj_ptr = FFI::MemoryPointer.new(:double, proj_params.size)
|
176
|
+
proj_ptr.write_array_of_double(proj_params)
|
177
|
+
end
|
178
|
+
|
179
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromPCI(@c_pointer, proj, units, proj_ptr)
|
180
|
+
|
181
|
+
ogr_err.handle_result
|
182
|
+
end
|
183
|
+
|
184
|
+
# @param projection_system_code [Fixnum]
|
185
|
+
# @param zone [Fixnum]
|
186
|
+
# @param datum [Fixnum]
|
187
|
+
# @param proj_params [Array<Float>]
|
188
|
+
def import_from_usgs(projection_system_code, zone, datum, *proj_params)
|
189
|
+
if proj_params.empty?
|
190
|
+
proj_ptr = nil
|
191
|
+
else
|
192
|
+
proj_ptr = FFI::MemoryPointer.new(:double, proj_params.size)
|
193
|
+
proj_ptr.write_array_of_double(proj_params)
|
194
|
+
end
|
195
|
+
|
196
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromUSGS(
|
197
|
+
@c_pointer,
|
198
|
+
projection_system_code,
|
199
|
+
zone,
|
200
|
+
proj_ptr,
|
201
|
+
datum)
|
202
|
+
|
203
|
+
ogr_err.handle_result
|
204
|
+
end
|
205
|
+
|
206
|
+
# Use for importing a GML coordinate system.
|
207
|
+
#
|
208
|
+
# @param xml [String]
|
209
|
+
def import_from_xml(xml)
|
210
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromXML(@c_pointer, xml)
|
211
|
+
|
212
|
+
ogr_err.handle_result
|
213
|
+
end
|
214
|
+
|
215
|
+
# @param coord_sys [String] The Mapinfo style CoordSys definition string.
|
216
|
+
def import_from_mapinfo(coord_sys)
|
217
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromMICoordSys(@c_pointer, coord_sys)
|
218
|
+
|
219
|
+
ogr_err.handle_result
|
220
|
+
end
|
221
|
+
|
222
|
+
# @param projection_name [String] I.e. "NUTM11" or "GEOGRAPHIC".
|
223
|
+
# @param datum_name [String] I.e. "NAD83".
|
224
|
+
# @param linear_unit_name [String] Plural form of linear units, i.e. "FEET".
|
225
|
+
def import_from_erm(projection_name, datum_name, linear_unit_name)
|
226
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromERM(
|
227
|
+
@c_pointer,
|
228
|
+
projection_name,
|
229
|
+
datum_name,
|
230
|
+
linear_unit_name)
|
231
|
+
|
232
|
+
ogr_err.handle_result
|
233
|
+
end
|
234
|
+
|
235
|
+
# @param url [String] URL to fetch the spatial reference from.
|
236
|
+
def import_from_url(url)
|
237
|
+
ogr_err = FFI::OGR::SRSAPI.OSRImportFromUrl(@c_pointer, url)
|
238
|
+
|
239
|
+
ogr_err.handle_result
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module OGR
|
2
|
+
module SpatialReferenceMixins
|
3
|
+
module Morphers
|
4
|
+
# Converts, in place, to ESRI WKT format.
|
5
|
+
#
|
6
|
+
# @return [OGR::SpatialReference, false] If successful, returns self.
|
7
|
+
def morph_to_esri!
|
8
|
+
ogr_err = FFI::OGR::SRSAPI.OSRMorphToESRI(@c_pointer)
|
9
|
+
result = ogr_err.handle_result
|
10
|
+
|
11
|
+
result ? self : result
|
12
|
+
end
|
13
|
+
|
14
|
+
# Converts, in place, from ESRI WKT format.
|
15
|
+
#
|
16
|
+
# @return [OGR::SpatialReference, false] If successful, returns self.
|
17
|
+
def morph_from_esri!
|
18
|
+
ogr_err = FFI::OGR::SRSAPI.OSRMorphFromESRI(@c_pointer)
|
19
|
+
result = ogr_err.handle_result
|
20
|
+
|
21
|
+
result ? self : result
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module OGR
|
2
|
+
module SpatialReferenceMixins
|
3
|
+
module ParameterGetterSetters
|
4
|
+
# @param name [String] The case-insensitive tree node to look for.
|
5
|
+
# @param child [Fixnum] The child of the node to fetch.
|
6
|
+
# @return [String, nil]
|
7
|
+
def attribute_value(name, child = 0)
|
8
|
+
FFI::OGR::SRSAPI.OSRGetAttrValue(@c_pointer, name, child)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @param path [String] Path to the node to update/set. If nested, use the
|
12
|
+
# pipe symbol to denote nesting. i.e. 'GEOCCS|UNIT'.
|
13
|
+
# @param value [String] The new value for the node/path. Should be a String,
|
14
|
+
# but if not, will be converted for you.
|
15
|
+
def set_attribute_value(path, value)
|
16
|
+
ogr_err = FFI::OGR::SRSAPI.OSRSetAttrValue(@c_pointer, path, value.to_s)
|
17
|
+
|
18
|
+
ogr_err.handle_result
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Hash{unit_name: String, value: Float}] +unit_name+ is the name
|
22
|
+
# of the unit type ("degree" or "radian"). +value+ is the number to
|
23
|
+
# multiply angular distances to transform them to radians.
|
24
|
+
def angular_units
|
25
|
+
name = FFI::MemoryPointer.new(:string)
|
26
|
+
name_ptr = FFI::MemoryPointer.new(:pointer)
|
27
|
+
name_ptr.write_pointer(name)
|
28
|
+
|
29
|
+
value = FFI::OGR::SRSAPI.OSRGetAngularUnits(@c_pointer, name_ptr)
|
30
|
+
|
31
|
+
{ unit_name: name_ptr.read_pointer.read_string, value: value }
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param unit_label [String]
|
35
|
+
# @param transform_to_radians [Float] The value to multiply an angle to
|
36
|
+
# transform the value to radians.
|
37
|
+
def set_angular_units(unit_label, transform_to_radians)
|
38
|
+
ogr_err = FFI::OGR::SRSAPI.OSRSetAngularUnits(@c_pointer, unit_label, transform_to_radians.to_f)
|
39
|
+
|
40
|
+
ogr_err.handle_result
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Hash{unit_name: String, value: Float}] +unit_name+ is the name
|
44
|
+
# of the unit type (e.g. "Meters"). +value+ is the number to multiply
|
45
|
+
# linear distances to transform them to meters.
|
46
|
+
def linear_units
|
47
|
+
name = FFI::MemoryPointer.new(:string)
|
48
|
+
name_ptr = FFI::MemoryPointer.new(:pointer)
|
49
|
+
name_ptr.write_pointer(name)
|
50
|
+
|
51
|
+
value = FFI::OGR::SRSAPI.OSRGetLinearUnits(@c_pointer, name_ptr)
|
52
|
+
|
53
|
+
{ unit_name: name_ptr.read_pointer.read_string, value: value }
|
54
|
+
end
|
55
|
+
|
56
|
+
# @param unit_label [String]
|
57
|
+
# @param transform_to_meters [Float] The value to multiply a length to
|
58
|
+
# transform the value to meters.
|
59
|
+
def set_linear_units(unit_label, transform_to_meters)
|
60
|
+
ogr_err = FFI::OGR::SRSAPI.OSRSetLinearUnits(@c_pointer, unit_label, transform_to_meters.to_f)
|
61
|
+
|
62
|
+
ogr_err.handle_result
|
63
|
+
end
|
64
|
+
|
65
|
+
# Does the same as #set_linear_units, but also converts parameters to use
|
66
|
+
# the new units.
|
67
|
+
#
|
68
|
+
# @param unit_label [String]
|
69
|
+
# @param transform_to_meters [Float] The value to multiply a length to
|
70
|
+
# transform the value to meters.
|
71
|
+
def set_linear_units_and_update_parameters(unit_label, transform_to_meters)
|
72
|
+
ogr_err = FFI::OGR::SRSAPI.OSRSetLinearUnitsAndUpdateParameters(
|
73
|
+
@c_pointer,
|
74
|
+
unit_label,
|
75
|
+
transform_to_meters.to_f)
|
76
|
+
|
77
|
+
ogr_err.handle_result
|
78
|
+
end
|
79
|
+
|
80
|
+
# The linear units for the projection.
|
81
|
+
#
|
82
|
+
# @param target_key [String] I.e. "PROJCS" or "VERT_CS".
|
83
|
+
# @return [Hash]
|
84
|
+
def target_linear_units(target_key)
|
85
|
+
name = FFI::MemoryPointer.new(:string)
|
86
|
+
name_ptr = FFI::MemoryPointer.new(:pointer)
|
87
|
+
name_ptr.write_pointer(name)
|
88
|
+
|
89
|
+
value = FFI::OGR::SRSAPI.OSRGetTargetLinearUnits(@c_pointer, target_key, name_ptr)
|
90
|
+
|
91
|
+
{ unit_name: name_ptr.read_pointer.read_string, value: value }
|
92
|
+
end
|
93
|
+
|
94
|
+
# @param target_key [String] The keyword to set linear units for ("PROJCS",
|
95
|
+
# "VERT_CS", etc.).
|
96
|
+
# @param unit_label [String] Name of the units to be used.
|
97
|
+
# @param transform_to_meters [Float] The value to multiple a length to
|
98
|
+
# transform the value to meters.
|
99
|
+
def set_target_linear_units(target_key, unit_label, transform_to_meters)
|
100
|
+
ogr_err = FFI::OGR::SRSAPI.OSRSetTargetLinearUnits(
|
101
|
+
@c_pointer,
|
102
|
+
target_key,
|
103
|
+
unit_label,
|
104
|
+
transform_to_meters
|
105
|
+
)
|
106
|
+
|
107
|
+
ogr_err.handle_result
|
108
|
+
end
|
109
|
+
|
110
|
+
# @return [Hash]
|
111
|
+
def prime_meridian
|
112
|
+
pm = FFI::MemoryPointer.new(:string)
|
113
|
+
pm_ptr = FFI::MemoryPointer.new(:pointer)
|
114
|
+
pm_ptr.write_pointer(pm)
|
115
|
+
|
116
|
+
value = FFI::OGR::SRSAPI.OSRGetPrimeMeridian(@c_pointer, pm_ptr)
|
117
|
+
|
118
|
+
{ name: pm_ptr.read_pointer.read_string, value: value }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module OGR
|
2
|
+
module SpatialReferenceMixins
|
3
|
+
module TypeChecks
|
4
|
+
# @return [Boolean] True if the root node is a GEOGCS node.
|
5
|
+
def geographic?
|
6
|
+
FFI::OGR::SRSAPI.OSRIsGeographic(@c_pointer)
|
7
|
+
end
|
8
|
+
|
9
|
+
# @return [Boolean] True if the root node is a LOCAL_CS node.
|
10
|
+
def local?
|
11
|
+
FFI::OGR::SRSAPI.OSRIsLocal(@c_pointer)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Boolean] True if it contains a PROJCS node.
|
15
|
+
def projected?
|
16
|
+
FFI::OGR::SRSAPI.OSRIsProjected(@c_pointer)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Boolean] True if the root node is a COMPD_CS node.
|
20
|
+
def compound?
|
21
|
+
FFI::OGR::SRSAPI.OSRIsCompound(@c_pointer)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Boolean] True if the root node is a GEOCCS node.
|
25
|
+
def geocentric?
|
26
|
+
FFI::OGR::SRSAPI.OSRIsGeocentric(@c_pointer)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Boolean] True if it contains a VERT_CS node.
|
30
|
+
def vertical?
|
31
|
+
FFI::OGR::SRSAPI.OSRIsVertical(@c_pointer)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param other_spatial_ref [OGR::SpatialReference, FFI::Pointer]
|
35
|
+
# @return [Boolean] True if both SpatialReferences describe the same
|
36
|
+
# system.
|
37
|
+
def same?(other_spatial_ref)
|
38
|
+
spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, other_spatial_ref)
|
39
|
+
|
40
|
+
FFI::OGR::SRSAPI.OSRIsSame(@c_pointer, spatial_ref_ptr)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param other_spatial_ref [OGR::SpatialReference, FFI::Pointer]
|
44
|
+
# @return [Boolean] True if the GEOGCS nodes of each SpatialReference
|
45
|
+
# match.
|
46
|
+
def geog_cs_is_same?(other_spatial_ref)
|
47
|
+
spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, other_spatial_ref)
|
48
|
+
|
49
|
+
FFI::OGR::SRSAPI.OSRIsSameGeogCS(@c_pointer, spatial_ref_ptr)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @param other_spatial_ref [OGR::SpatialReference, FFI::Pointer]
|
53
|
+
# @return [Boolean] True if the VERT_CS nodes of each SpatialReference
|
54
|
+
# match.
|
55
|
+
def vert_cs_is_same?(other_spatial_ref)
|
56
|
+
spatial_ref_ptr = GDAL._pointer(OGR::SpatialReference, other_spatial_ref)
|
57
|
+
|
58
|
+
FFI::OGR::SRSAPI.OSRIsSameVertCS(@c_pointer, spatial_ref_ptr)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/ogr/style_table.rb
CHANGED
@@ -5,13 +5,61 @@ module OGR
|
|
5
5
|
class StyleTable
|
6
6
|
include StyleTableExtensions
|
7
7
|
|
8
|
-
# @
|
9
|
-
|
10
|
-
|
8
|
+
# @return [FFI::Pointer] C pointer to the C style table.
|
9
|
+
attr_reader :c_pointer
|
10
|
+
|
11
|
+
# @param [FFI::Pointer] c_pointer
|
12
|
+
def initialize(c_pointer = nil)
|
13
|
+
@c_pointer = c_pointer ? c_pointer : FFI::OGR::API.OGR_STBL_Create
|
14
|
+
|
15
|
+
fail 'Unable to create StyleTable' if @c_pointer.null?
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy!
|
19
|
+
return unless @c_pointer
|
20
|
+
|
21
|
+
FFI::OGR::API.OGR_STBL_Destroy(@c_pointer)
|
22
|
+
@c_pointer = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param name [String] Name of the style.
|
26
|
+
# @param style [String]
|
27
|
+
# @return [Boolean]
|
28
|
+
def add_style(name, style)
|
29
|
+
FFI::OGR::API.OGR_STBL_AddStyle(@c_pointer, name, style)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param style_name [String]
|
33
|
+
# @return [String, nil]
|
34
|
+
def find(style_name)
|
35
|
+
FFI::OGR::API.OGR_STBL_Find(@c_pointer, style_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String, nil] The style name of the last string fetched with #next_style.
|
39
|
+
def last_style_name
|
40
|
+
FFI::OGR::API.OGR_STBL_GetLastStyleName(@c_pointer)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String, nil] The next style string from the table.
|
44
|
+
def next_style
|
45
|
+
FFI::OGR::API.OGR_STBL_GetNextStyle(@c_pointer)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param file_name [String]
|
49
|
+
# @return [Boolean]
|
50
|
+
def load!(file_name)
|
51
|
+
FFI::OGR::API.OGR_STBL_LoadStyleTable(@c_pointer, file_name)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Resets the #next_style to the 0th style.
|
55
|
+
def reset_style_string_reading
|
56
|
+
FFI::OGR::API.OGR_STBL_ResetStyleStringReading(@c_pointer)
|
11
57
|
end
|
12
58
|
|
13
|
-
|
14
|
-
|
59
|
+
# @param file_name [String] Path to the file to save to.
|
60
|
+
# @return [Boolean]
|
61
|
+
def save(file_name)
|
62
|
+
FFI::OGR::API.OGR_STBL_SaveStyleTable(@c_pointer, file_name)
|
15
63
|
end
|
16
64
|
end
|
17
65
|
end
|
@@ -2,15 +2,31 @@ require 'json'
|
|
2
2
|
|
3
3
|
module OGR
|
4
4
|
module StyleTableExtensions
|
5
|
+
# Gets all of the styles as Hash. Note that this calls
|
6
|
+
# #reset_style_string_reading.
|
7
|
+
#
|
8
|
+
# @return [Hash{name => style}]
|
9
|
+
def styles
|
10
|
+
styles = {}
|
11
|
+
reset_style_string_reading
|
5
12
|
|
6
|
-
|
7
|
-
|
8
|
-
|
13
|
+
while style = next_style
|
14
|
+
styles[last_style_name] = style
|
15
|
+
end
|
16
|
+
|
17
|
+
reset_style_string_reading
|
18
|
+
|
19
|
+
styles
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Hash]
|
23
|
+
def as_json(_options = nil)
|
24
|
+
styles
|
9
25
|
end
|
10
26
|
|
11
27
|
# @return [String]
|
12
|
-
def to_json
|
13
|
-
as_json.to_json
|
28
|
+
def to_json(options = nil)
|
29
|
+
as_json(options).to_json
|
14
30
|
end
|
15
31
|
end
|
16
32
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require_relative '../ffi/ogr'
|
2
|
+
|
3
|
+
module OGR
|
4
|
+
class StyleTool
|
5
|
+
# @return [FFI::Pointer] C pointer to the C style tool.
|
6
|
+
attr_reader :c_pointer
|
7
|
+
|
8
|
+
# @param style_tool_class [FFI::OGR::Core::STClassId] Must be one of :OGRSTCPen,
|
9
|
+
# :OGRSTCBrush, :OGRSTCSymbol, :OGRSTCLabel.
|
10
|
+
def initialize(style_tool_class)
|
11
|
+
@c_pointer = FFI::OGR::API.OGR_ST_Create(style_tool_class)
|
12
|
+
return if @c_pointer && !@c_pointer.null?
|
13
|
+
|
14
|
+
fail OGR::CreateFailure, "Unable to create StyleTool using class #{style_tool_class}"
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [String, nil]
|
18
|
+
def style_string
|
19
|
+
FFI::OGR::API.OGR_ST_GetStyleString(@c_pointer)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [FFI::OGR::Core::STClassId]
|
23
|
+
def type
|
24
|
+
FFI::OGR::API.OGR_ST_GetType(@c_pointer)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [FFI::OGR::Core::STUnitId]
|
28
|
+
def unit
|
29
|
+
FFI::OGR::API.OGR_ST_GetUnit(@c_pointer)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param new_unit [FFI::OGR::Core::STUnitId]
|
33
|
+
# @param ground_to_paper_scale [Float]
|
34
|
+
def set_unit(new_unit, ground_to_paper_scale)
|
35
|
+
FFI::OGR::API.OGR_ST_SetUnit(@c_pointer, new_unit, ground_to_paper_scale)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param param_number [Fixnum]
|
39
|
+
# @return [Float, nil]
|
40
|
+
def param_as_double(param_number)
|
41
|
+
value_is_null_ptr = FFI::MemoryPointer.new(:int)
|
42
|
+
value = FFI::OGR::API.OGR_ST_GetParamDbl(@c_pointer, param_number, value_is_null_ptr)
|
43
|
+
|
44
|
+
value_is_null_ptr.read_int.to_bool ? nil : value
|
45
|
+
end
|
46
|
+
alias_method :param_as_float, :param_as_double
|
47
|
+
|
48
|
+
# @param param_number [Fixnum]
|
49
|
+
# @param value [Float]
|
50
|
+
def set_param_as_double(param_number, value)
|
51
|
+
FFI::OGR::API.OGR_ST_SetParamDbl(@c_pointer, param_number, value)
|
52
|
+
end
|
53
|
+
alias_method :set_param_as_float, :set_param_as_double
|
54
|
+
|
55
|
+
# @param param_number [Fixnum]
|
56
|
+
# @return [Fixnum, nil]
|
57
|
+
def param_as_number(param_number)
|
58
|
+
value_is_null_ptr = FFI::MemoryPointer.new(:int)
|
59
|
+
value = FFI::OGR::API.OGR_ST_GetParamNum(@c_pointer, param_number, value_is_null_ptr)
|
60
|
+
|
61
|
+
value_is_null_ptr.read_int.to_bool ? nil : value
|
62
|
+
end
|
63
|
+
alias_method :param_as_integer, :param_as_number
|
64
|
+
|
65
|
+
# @param param_number [Fixnum]
|
66
|
+
# @param value [Fixnum]
|
67
|
+
def set_param_as_number(param_number, value)
|
68
|
+
FFI::OGR::API.OGR_ST_SetParamNum(@c_pointer, param_number, value)
|
69
|
+
end
|
70
|
+
alias_method :set_param_as_integer, :set_param_as_number
|
71
|
+
|
72
|
+
# @param param_number [Fixnum]
|
73
|
+
# @return [String, nil]
|
74
|
+
def param_as_string(param_number)
|
75
|
+
value_is_null_ptr = FFI::MemoryPointer.new(:int)
|
76
|
+
value = FFI::OGR::API.OGR_ST_GetParamStr(@c_pointer, param_number, value_is_null_ptr)
|
77
|
+
|
78
|
+
value_is_null_ptr.read_int.to_bool ? nil : value
|
79
|
+
end
|
80
|
+
|
81
|
+
# @param param_number [Fixnum]
|
82
|
+
# @param value [String]
|
83
|
+
def set_param_as_string(param_number, value)
|
84
|
+
FFI::OGR::API.OGR_ST_SetParamStr(@c_pointer, param_number, value)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns the R, G, B, A components of a #RRGGBB[AA] formatted string.
|
88
|
+
#
|
89
|
+
# @param color_string [String]
|
90
|
+
# @return [Hash{red => Fixnum, green => Fixnum, blue => Fixnum, alpha => Fixnum}]
|
91
|
+
def rgb_from_string(color_string)
|
92
|
+
red_ptr = FFI::MemoryPointer.new(:int)
|
93
|
+
green_ptr = FFI::MemoryPointer.new(:int)
|
94
|
+
blue_ptr = FFI::MemoryPointer.new(:int)
|
95
|
+
alpha_ptr = FFI::MemoryPointer.new(:int)
|
96
|
+
|
97
|
+
boolean_result = FFI::OGR::API.OGR_ST_GetRGBFromString(
|
98
|
+
@c_pointer,
|
99
|
+
color_string,
|
100
|
+
red_ptr,
|
101
|
+
green_ptr,
|
102
|
+
blue_ptr,
|
103
|
+
alpha_ptr
|
104
|
+
)
|
105
|
+
|
106
|
+
if boolean_result
|
107
|
+
{
|
108
|
+
red: red_ptr.read_int,
|
109
|
+
green: green_ptr.read_int,
|
110
|
+
blue: blue_ptr.read_int,
|
111
|
+
alpha: alpha_ptr.read_int
|
112
|
+
}
|
113
|
+
else
|
114
|
+
{ red: nil, green: nil, blue: nil, alpha: nil }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/lib/ogr.rb
ADDED