Class: GDAL::GeoTransform
- Inherits:
-
Object
- Object
- GDAL::GeoTransform
- Includes:
- FFI::GDAL
- Defined in:
- lib/ffi-gdal/geo_transform.rb
Constant Summary
Constants included from FFI::GDAL
FFI::GDAL::ALTER_ALL_FLAG, FFI::GDAL::ALTER_NAME_FLAG, FFI::GDAL::ALTER_TYPE_FLAG, FFI::GDAL::ALTER_WIDTH_PRECISION_FLAG, FFI::GDAL::AppDefined, FFI::GDAL::AssertionFailed, FFI::GDAL::CPLES_BackslashQuotable, FFI::GDAL::CPLES_CSV, FFI::GDAL::CPLES_SQL, FFI::GDAL::CPLES_URL, FFI::GDAL::CPLES_XML, FFI::GDAL::CPLES_XML_BUT_QUOTES, FFI::GDAL::CPLE_WrongFormat, FFI::GDAL::CPLErr, FFI::GDAL::CPLValueType, FFI::GDAL::CPL_ENC_ASCII, FFI::GDAL::CPL_ENC_ISO8859_1, FFI::GDAL::CPL_ENC_LOCALE, FFI::GDAL::CPL_ENC_UCS2, FFI::GDAL::CPL_ENC_UCS4, FFI::GDAL::CPL_ENC_UTF16, FFI::GDAL::CPL_ENC_UTF8, FFI::GDAL::CSLT_ALLOWEMPTYTOKENS, FFI::GDAL::CSLT_HONOURSTRINGS, FFI::GDAL::CSLT_PRESERVEESCAPES, FFI::GDAL::CSLT_PRESERVEQUOTES, FFI::GDAL::CSLT_STRIPENDSPACES, FFI::GDAL::CSLT_STRIPLEADSPACES, FFI::GDAL::FileIO, FFI::GDAL::GDALAccess, FFI::GDAL::GDALAsyncStatusType, FFI::GDAL::GDALColorInterp, FFI::GDAL::GDALDataType, FFI::GDAL::GDALMD_AOP_AREA, FFI::GDAL::GDALMD_AOP_POINT, FFI::GDAL::GDALMD_AREA_OR_POINT, FFI::GDAL::GDALPaletteInterp, FFI::GDAL::GDALRATFieldType, FFI::GDAL::GDALRATFieldUsage, FFI::GDAL::GDALRWFlag, FFI::GDAL::GDALTileOrganization, FFI::GDAL::GDAL_DCAP_CREATE, FFI::GDAL::GDAL_DCAP_CREATECOPY, FFI::GDAL::GDAL_DCAP_OPEN, FFI::GDAL::GDAL_DCAP_RASTER, FFI::GDAL::GDAL_DCAP_VECTOR, FFI::GDAL::GDAL_DCAP_VIRTUALIO, FFI::GDAL::GDAL_DMD_CREATIONDATATYPES, FFI::GDAL::GDAL_DMD_CREATIONOPTIONLIST, FFI::GDAL::GDAL_DMD_EXTENSION, FFI::GDAL::GDAL_DMD_EXTENSIONS, FFI::GDAL::GDAL_DMD_HELPTOPIC, FFI::GDAL::GDAL_DMD_LONGNAME, FFI::GDAL::GDAL_DMD_MIMETYPE, FFI::GDAL::GDAL_DMD_OPTIONLIST, FFI::GDAL::GDAL_DMD_SUBDATASETS, FFI::GDAL::GDAL_DS_LAYER_CREATIONOPTIONLIST, FFI::GDAL::GDAL_OF_ALL, FFI::GDAL::GDAL_OF_RASTER, FFI::GDAL::GDAL_OF_READONLY, FFI::GDAL::GDAL_OF_SHARED, FFI::GDAL::GDAL_OF_UPDATE, FFI::GDAL::GDAL_OF_VECTOR, FFI::GDAL::GDAL_OF_VERBOSE_ERROR, FFI::GDAL::GMF_ALL_VALID, FFI::GDAL::GMF_ALPHA, FFI::GDAL::GMF_NODATA, FFI::GDAL::GMF_PER_DATASET, FFI::GDAL::IllegalArg, FFI::GDAL::NoWriteAccess, FFI::GDAL::None, FFI::GDAL::NotSupported, FFI::GDAL::ODrCCreateDataSource, FFI::GDAL::ODrCDeleteDataSource, FFI::GDAL::ODsCCreateGeomFieldAfterCreateLayer, FFI::GDAL::ODsCCreateLayer, FFI::GDAL::ODsCDeleteLayer, FFI::GDAL::OGRAxisOrientation, FFI::GDAL::OGRDatumType, FFI::GDAL::OGRERR_CORRUPT_DATA, FFI::GDAL::OGRERR_FAILURE, FFI::GDAL::OGRERR_INVALID_HANDLE, FFI::GDAL::OGRERR_NONE, FFI::GDAL::OGRERR_NOT_ENOUGH_DATA, FFI::GDAL::OGRERR_NOT_ENOUGH_MEMORY, FFI::GDAL::OGRERR_UNSUPPORTED_GEOMETRY_TYPE, FFI::GDAL::OGRERR_UNSUPPORTED_OPERATION, FFI::GDAL::OGRERR_UNSUPPORTED_SRS, FFI::GDAL::OGRFieldType, FFI::GDAL::OGRJustification, FFI::GDAL::OGRNullFID, FFI::GDAL::OGRStyleToolClassID, FFI::GDAL::OGRStyleToolParamBrushID, FFI::GDAL::OGRStyleToolParamLabelID, FFI::GDAL::OGRStyleToolParamPenID, FFI::GDAL::OGRStyleToolParamSymbolID, FFI::GDAL::OGRStyleToolUnitsID, FFI::GDAL::OGRUnsetMarker, FFI::GDAL::OGR_Z_MARKER, FFI::GDAL::OGRwkbByteOrder, FFI::GDAL::OGRwkbGeometryType, FFI::GDAL::OGRwkbVariant, FFI::GDAL::OLCAlterFieldDefn, FFI::GDAL::OLCCreateField, FFI::GDAL::OLCCreateGeomField, FFI::GDAL::OLCDeleteFeature, FFI::GDAL::OLCDeleteField, FFI::GDAL::OLCFastFeatureCount, FFI::GDAL::OLCFastGetExtent, FFI::GDAL::OLCFastSetNextByIndex, FFI::GDAL::OLCFastSpatialFilter, FFI::GDAL::OLCIgnoreFields, FFI::GDAL::OLCRandomRead, FFI::GDAL::OLCRandomeWrite, FFI::GDAL::OLCReorderFields, FFI::GDAL::OLCSequentialWrite, FFI::GDAL::OLCStringsAsUTF8, FFI::GDAL::OLCTransactions, FFI::GDAL::ObjectNull, FFI::GDAL::OpenFailed, FFI::GDAL::OutOfMemory, FFI::GDAL::UserInterrupt, FFI::GDAL::VERSION, FFI::GDAL::VSI_STAT_EXISTS_FLAG, FFI::GDAL::VSI_STAT_NATURE_FLAG, FFI::GDAL::VSI_STAT_SIZE_FLAG, FFI::GDAL::WKB_25D_BIT
Instance Attribute Summary collapse
-
#gdal_dataset ⇒ Object
Returns the value of attribute gdal_dataset.
Instance Method Summary collapse
- #c_pointer ⇒ Object
-
#initialize(dataset, geo_transform_pointer: nil) ⇒ GeoTransform
constructor
A new instance of GeoTransform.
- #null? ⇒ Boolean
-
#pixel_height ⇒ Float
AKA Y-pixel size.
-
#pixel_width ⇒ Float
AKA X-pixel size.
-
#to_a ⇒ Array
All attributes as an Array, in the order: * x_origin * pixel_width * x_rotation * y_origin * y_rotation * pixel_height.
-
#x_origin ⇒ Float
X-coordinate of the center of the upper left pixel.
-
#x_projection(x_pixel, y_pixel) ⇒ Float
The calculated UTM easting of the pixel on the map.
-
#x_rotation ⇒ Float
Rotation about the x-axis.
-
#y_origin ⇒ Float
Y-coordinate of the center of the upper left pixel.
-
#y_projection(x_pixel, y_pixel) ⇒ Float
The calculated UTM northing of the pixel on the map.
-
#y_rotation ⇒ Float
Rotation about the y-axis.
Methods included from FFI::GDAL
#CPLFree, #cpla_assert, find_lib, #gdal_check_version, gdal_library_path, search_paths, #srcval, #validate_pointer0, #validate_pointer1, #validate_pointer_err
Constructor Details
#initialize(dataset, geo_transform_pointer: nil) ⇒ GeoTransform
Returns a new instance of GeoTransform.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ffi-gdal/geo_transform.rb', line 11 def initialize(dataset, geo_transform_pointer: nil) @gdal_dataset = if dataset.nil? FFI::MemoryPointer.new(:pointer) elsif dataset.is_a? GDAL::Dataset dataset.c_pointer else dataset end @gdal_geo_transform = if geo_transform_pointer geo_transform_pointer else container_pointer = FFI::MemoryPointer.new(:double, 6) GDALGetGeoTransform(@gdal_dataset, container_pointer).to_ruby container_pointer end to_a end |
Instance Attribute Details
#gdal_dataset ⇒ Object
Returns the value of attribute gdal_dataset.
8 9 10 |
# File 'lib/ffi-gdal/geo_transform.rb', line 8 def gdal_dataset @gdal_dataset end |
Instance Method Details
#c_pointer ⇒ Object
31 32 33 |
# File 'lib/ffi-gdal/geo_transform.rb', line 31 def c_pointer @gdal_geo_transform end |
#null? ⇒ Boolean
35 36 37 |
# File 'lib/ffi-gdal/geo_transform.rb', line 35 def null? @gdal_geo_transform.null? end |
#pixel_height ⇒ Float
AKA Y-pixel size. In wikipedia’s World Map definition, this is “E”.
113 114 115 116 117 |
# File 'lib/ffi-gdal/geo_transform.rb', line 113 def pixel_height return nil if null? @gdal_geo_transform[5].read_double end |
#pixel_width ⇒ Float
AKA X-pixel size. In wikipedia’s World Map definition, this is “A”.
73 74 75 76 77 |
# File 'lib/ffi-gdal/geo_transform.rb', line 73 def pixel_width return nil if null? @gdal_geo_transform[1].read_double end |
#to_a ⇒ Array
All attributes as an Array, in the order:
* x_origin
* pixel_width
* x_rotation
* y_origin
* y_rotation
* pixel_height
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ffi-gdal/geo_transform.rb', line 48 def to_a [ x_origin, pixel_width, x_rotation, y_origin, y_rotation, pixel_height ] end |
#x_origin ⇒ Float
X-coordinate of the center of the upper left pixel. In wikipedia’s World Map definition, this is “C”.
63 64 65 66 67 |
# File 'lib/ffi-gdal/geo_transform.rb', line 63 def x_origin return nil if null? @gdal_geo_transform[0].read_double end |
#x_projection(x_pixel, y_pixel) ⇒ Float
The calculated UTM easting of the pixel on the map.
122 123 124 125 126 |
# File 'lib/ffi-gdal/geo_transform.rb', line 122 def x_projection(x_pixel, y_pixel) return nil if null? (pixel_width * x_pixel) + (x_rotation * y_pixel) + x_origin end |
#x_rotation ⇒ Float
Rotation about the x-axis. In wikipedia’s World Map definition, this is “B”.
83 84 85 86 87 |
# File 'lib/ffi-gdal/geo_transform.rb', line 83 def x_rotation return nil if null? @gdal_geo_transform[2].read_double end |
#y_origin ⇒ Float
Y-coordinate of the center of the upper left pixel. In wikipedia’s World Map definition, this is “F”.
93 94 95 96 97 |
# File 'lib/ffi-gdal/geo_transform.rb', line 93 def y_origin return nil if null? @gdal_geo_transform[3].read_double end |
#y_projection(x_pixel, y_pixel) ⇒ Float
The calculated UTM northing of the pixel on the map.
131 132 133 134 135 |
# File 'lib/ffi-gdal/geo_transform.rb', line 131 def y_projection(x_pixel, y_pixel) return nil if null? (y_rotation * x_pixel) + (pixel_height * y_pixel) + y_origin end |
#y_rotation ⇒ Float
Rotation about the y-axis. In wikipedia’s World Map definition, this is “D”.
103 104 105 106 107 |
# File 'lib/ffi-gdal/geo_transform.rb', line 103 def y_rotation return nil if null? @gdal_geo_transform[4].read_double end |