Module: GDAL::Dataset::Accessors
- Included in:
- GDAL::Dataset
- Defined in:
- lib/gdal/dataset/accessors.rb
Instance Method Summary collapse
-
#driver ⇒ GDAL::Driver
The driver to be used for working with this dataset.
-
#gcp_count ⇒ String #returnrn [Integer]
String # @return [Integer].
- #gcp_projection ⇒ String
- #gcps ⇒ FFI::GDAL::GCP
- #geo_transform ⇒ GDAL::GeoTransform
- #geo_transform=(new_transform) ⇒ GDAL::GeoTransform
- #projection ⇒ Object
- #projection=(new_projection) ⇒ Object
-
#spatial_reference ⇒ OGR::SpatialReference
Creates a OGR::SpatialReference object from the dataset’s projection.
Instance Method Details
#driver ⇒ GDAL::Driver
8 9 10 11 12 |
# File 'lib/gdal/dataset/accessors.rb', line 8 def driver driver_ptr = FFI::GDAL::GDAL.GDALGetDatasetDriver(@c_pointer) Driver.new(driver_ptr) end |
#gcp_count ⇒ String #returnrn [Integer]
59 60 61 62 63 |
# File 'lib/gdal/dataset/accessors.rb', line 59 def gcp_count return 0 if null? FFI::GDAL::GDAL.GDALGetGCPCount(@c_pointer) end |
#gcp_projection ⇒ String
66 67 68 69 70 71 72 73 |
# File 'lib/gdal/dataset/accessors.rb', line 66 def gcp_projection return "" if null? proj, ptr = FFI::GDAL::GDAL.GDALGetGCPProjection(@c_pointer) ptr.autorelease = false proj end |
#gcps ⇒ FFI::GDAL::GCP
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/gdal/dataset/accessors.rb', line 76 def gcps return FFI::GDAL::GCP.new if null? gcp_array_pointer = FFI::GDAL::GDAL.GDALGetGCPs(@c_pointer) if gcp_array_pointer.null? FFI::GDAL::GCP.new else FFI::GDAL::GCP.new(gcp_array_pointer) end end |
#geo_transform ⇒ GDAL::GeoTransform
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gdal/dataset/accessors.rb', line 33 def geo_transform return @geo_transform if @geo_transform geo_transform_pointer = GDAL::GeoTransform.new_pointer GDAL::CPLErrorHandler.manually_handle("Unable to get geo_transform") do FFI::GDAL::GDAL.GDALGetGeoTransform(@c_pointer, geo_transform_pointer) end @geo_transform = GeoTransform.new(geo_transform_pointer) end |
#geo_transform=(new_transform) ⇒ GDAL::GeoTransform
48 49 50 51 52 53 54 55 56 |
# File 'lib/gdal/dataset/accessors.rb', line 48 def geo_transform=(new_transform) new_pointer = GDAL._pointer(GDAL::GeoTransform, new_transform) GDAL::CPLErrorHandler.manually_handle("Unable to set geo_transform") do FFI::GDAL::GDAL.GDALSetGeoTransform(@c_pointer, new_pointer) end @geo_transform = new_transform.is_a?(FFI::Pointer) ? GeoTransform.new(new_pointer) : new_transform end |
#projection ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gdal/dataset/accessors.rb', line 14 def projection # Returns a pointer to an internal projection reference string. It should # not be altered, freed or expected to last for long. proj, ptr = FFI::GDAL::GDAL.GDALGetProjectionRef(@c_pointer) ptr.autorelease = false proj || "" end |
#projection=(new_projection) ⇒ Object
25 26 27 28 29 |
# File 'lib/gdal/dataset/accessors.rb', line 25 def projection=(new_projection) GDAL::CPLErrorHandler.manually_handle("Unable to set projection") do FFI::GDAL::GDAL.GDALSetProjection(@c_pointer, new_projection.to_s) end end |
#spatial_reference ⇒ OGR::SpatialReference
Creates a OGR::SpatialReference object from the dataset’s projection.
91 92 93 94 95 96 97 98 |
# File 'lib/gdal/dataset/accessors.rb', line 91 def spatial_reference return @spatial_reference if @spatial_reference proj = projection return nil if proj.empty? @spatial_reference = OGR::SpatialReference.new(proj) end |