| 1 | = RFC2: Well Known Binary format for RASTER type = |
| 2 | |
| 3 | '''Author''': Sandro Santilli <strk@keybit.net>[[BR]] |
| 4 | '''Date''': 2009-01-29[[BR]] |
| 5 | '''Status''': Adopted |
| 6 | |
| 7 | Revisions:: |
| 8 | 2011-01-24 by Jorge Arévalo |
| 9 | - Adds isNodataValue bit to band flags |
| 10 | |
| 11 | The WKB format for RASTER is meant for transport. |
| 12 | Takes into account endiannes and avoids any padding. |
| 13 | Still, beside padding and endiannes, it matches the |
| 14 | internal serialized format (see RFC1), for quick |
| 15 | input/output. |
| 16 | |
| 17 | == Basic Type definitions == |
| 18 | |
| 19 | * byte: 1 byte |
| 20 | * uint16: 16 bit unsigned integer (2 bytes) |
| 21 | * uint32: 32 bit unsigned integer (4 bytes) |
| 22 | * float64: double precision floating point number (8 bytes) |
| 23 | |
| 24 | == Header == |
| 25 | |
| 26 | {{{ |
| 27 | +---------------+-------------+------------------------------+ |
| 28 | | - name - | - type - | - meaning - | |
| 29 | +---------------+-------------+------------------------------+ |
| 30 | | endiannes | byte | 1:ndr/little endian | |
| 31 | | | | 0:xdr/big endian | |
| 32 | +---------------+-------------+------------------------------+ |
| 33 | | version | uint16 | format version (0 for this | |
| 34 | | | | structure) | |
| 35 | +---------------+-------------+------------------------------+ |
| 36 | | nBands | uint16 | Number of bands | |
| 37 | +---------------+-------------+------------------------------+ |
| 38 | | scaleX | float64 | pixel width | |
| 39 | | | | in geographical units | |
| 40 | +---------------+-------------+------------------------------+ |
| 41 | | scaleY | float64 | pixel height | |
| 42 | | | | in geographical units | |
| 43 | +---------------+-------------+------------------------------+ |
| 44 | | ipX | float64 | X ordinate of upper-left | |
| 45 | | | | pixel's upper-left corner | |
| 46 | | | | in geographical units | |
| 47 | +---------------+-------------+------------------------------+ |
| 48 | | ipY | float64 | Y ordinate of upper-left | |
| 49 | | | | pixel's upper-left corner | |
| 50 | | | | in geographical units | |
| 51 | +---------------+-------------+------------------------------+ |
| 52 | | skewX | float64 | rotation about Y-axis | |
| 53 | +---------------+-------------+------------------------------+ |
| 54 | | skewY | float64 | rotation about X-axis | |
| 55 | +---------------+-------------+------------------------------+ |
| 56 | | srid | int32 | Spatial reference id | |
| 57 | +---------------+-------------+------------------------------+ |
| 58 | | width | uint16 | number of pixel columns | |
| 59 | +---------------+-------------+------------------------------+ |
| 60 | | height | uint16 | number of pixel rows | |
| 61 | +---------------+-------------+------------------------------+ |
| 62 | | bands[nBands] | RASTERBAND | Bands data | |
| 63 | +---------------+-------------+------------------------------+ |
| 64 | }}} |
| 65 | |
| 66 | == Band == |
| 67 | |
| 68 | {{{ |
| 69 | +---------------+--------------+-----------------------------------+ |
| 70 | | - name - | - type - | - meaning - | |
| 71 | +---------------+--------------+-----------------------------------+ |
| 72 | | isOffline | 1bit | If true, data is to be found | |
| 73 | | | | on the filesystem, trought the | |
| 74 | | | | path specified in RASTERDATA | |
| 75 | +---------------+--------------+-----------------------------------+ |
| 76 | | hasNodataValue| 1bit | If true, stored nodata value is | |
| 77 | | | | a true nodata value. Otherwise | |
| 78 | | | | the value stored as a nodata | |
| 79 | | | | value should be ignored. | |
| 80 | +---------------+--------------+-----------------------------------+ |
| 81 | | isNodataValue | 1bit | If true, all the values of the | |
| 82 | | | | band are expected to be nodata | |
| 83 | | | | values. This is a dirty flag. | |
| 84 | | | | To set the flag to its real value | |
| 85 | | | | the function st_bandisnodata must | |
| 86 | | | | must be called for the band with | |
| 87 | | | | 'TRUE' as last argument. | |
| 88 | +---------------+--------------+-----------------------------------+ |
| 89 | | reserved | 1bit | unused in this version | |
| 90 | +---------------+--------------+-----------------------------------+ |
| 91 | | pixtype | 4bits | 0: 1-bit boolean | |
| 92 | | | | 1: 2-bit unsigned integer | |
| 93 | | | | 2: 4-bit unsigned integer | |
| 94 | | | | 3: 8-bit signed integer | |
| 95 | | | | 4: 8-bit unsigned integer | |
| 96 | | | | 5: 16-bit signed integer | |
| 97 | | | | 6: 16-bit unsigned signed integer | |
| 98 | | | | 7: 32-bit signed integer | |
| 99 | | | | 8: 32-bit unsigned signed integer | |
| 100 | | | | 9: 32-bit float | |
| 101 | | | | 10: 64-bit float | |
| 102 | +---------------+--------------+-----------------------------------+ |
| 103 | | nodata | 1 to 8 bytes | Nodata value | |
| 104 | | | depending on | | |
| 105 | | | pixtype [1] | | |
| 106 | +---------------+--------------+-----------------------------------+ |
| 107 | | data | RASTERDATA | Raster band data (see below) | |
| 108 | +---------------+--------------+-----------------------------------+ |
| 109 | }}} |
| 110 | |
| 111 | === Band data (in-db) === |
| 112 | |
| 113 | {{{ |
| 114 | +---------------+--------------+-----------------------------------+ |
| 115 | | pix[w*h] | 1 to 8 bytes | Pixels values, row after row, | |
| 116 | | | depending on | so pix[0] is upper-left, pix[w-1] | |
| 117 | | | pixtype [1] | is upper-right. | |
| 118 | | | | | |
| 119 | | | | As for endiannes, it is specified | |
| 120 | | | | at the start of WKB, and implicit | |
| 121 | | | | up to 8bits (bit-order is most | |
| 122 | | | | significant first) | |
| 123 | | | | | |
| 124 | +---------------+--------------+-----------------------------------+ |
| 125 | }}} |
| 126 | |
| 127 | [1] 1,2 and 4 bit pixtypes are still encoded as 1-byte per value |
| 128 | |
| 129 | === Band data (out-db) === |
| 130 | |
| 131 | {{{ |
| 132 | +---------------+-------------+-----------------------------------+ |
| 133 | | bandNumber | int8 | 0-based band number to use from | |
| 134 | | | | the set available in the external | |
| 135 | | | | file | |
| 136 | +---------------+-------------+-----------------------------------+ |
| 137 | | path | string | null-terminated path to data file | |
| 138 | +---------------+-------------+-----------------------------------+ |
| 139 | }}} |