@@ -71,51 +71,57 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
71
71
{
72
72
result[ QStringLiteral ( " pxType" ) ] = *reinterpret_cast <const unsigned short int *>( &wkb.constData ()[offset] ) & 0x0F ;
73
73
/*
74
- | 'Bool1' // unsupported
75
- | 'Uint2' // unsupported
76
- | 'Uint4' // unsupported
77
- | 'Int8'
78
- | 'Uint8'
79
- | 'Int16'
80
- | 'Uint16'
81
- | 'Int32'
82
- | 'Uint32'
83
- | 'Float32'
84
- | 'Float64'
74
+ | 0 'Bool1' // unsupported
75
+ | 1 'Uint2' // unsupported
76
+ | 2 'Uint4' // unsupported
77
+ | 3 'Int8'
78
+ | 4 'Uint8'
79
+ | 5 'Int16'
80
+ | 6 'Uint16'
81
+ | 7 'Int32'
82
+ | 8 'Uint32'
83
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!
84
+ | 9 is missing!!!!
85
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!
86
+ | 10 'Float32'
87
+ | 11 'Float64'
85
88
*/
86
89
offset++;
87
90
int pxSize = 0 ; // in bytes
88
91
switch ( result[ QStringLiteral ( " pxType" ) ].toInt () )
89
92
{
90
- case 4 : // int8
93
+ case 3 : // int8
91
94
pxSize = 1 ;
92
95
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const short int *>( &wkb.constData ()[ offset ] );
93
96
break ;
94
- case 5 : // uint8
97
+ case 4 : // uint8
95
98
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const unsigned short int *>( &wkb.constData ()[ offset ] );
96
99
pxSize = 1 ;
97
100
break ;
98
- case 6 : // int16
101
+ case 5 : // int16
99
102
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const int *>( &wkb.constData ()[ offset ] );
100
103
pxSize = 2 ;
101
104
break ;
102
- case 7 : // uint16
105
+ case 6 : // uint16
103
106
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const unsigned int *>( &wkb.constData ()[ offset ] );
104
107
pxSize = 2 ;
105
108
break ;
106
- case 8 : // int32
109
+ case 7 : // int32
107
110
result[ QStringLiteral ( " nodata" ) ] = static_cast <long long >( *reinterpret_cast <const long int *>( &wkb.constData ()[ offset ] ) );
108
111
pxSize = 4 ;
109
112
break ;
110
- case 9 : // uint32
113
+ case 8 : // uint32
111
114
result[ QStringLiteral ( " nodata" ) ] = static_cast <unsigned long long >( *reinterpret_cast <const unsigned long int *>( &wkb.constData ()[ offset ] ) );
112
115
pxSize = 4 ;
113
116
break ;
114
- case 10 : // float
117
+
118
+ // Note: 9 is missing from the specs
119
+
120
+ case 10 : // float 32 bit
115
121
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const float *>( &wkb.constData ()[ offset ] );
116
122
pxSize = 4 ;
117
123
break ;
118
- case 11 : // double
124
+ case 11 : // double 64 bit
119
125
result[ QStringLiteral ( " nodata" ) ] = *reinterpret_cast <const double *>( &wkb.constData ()[ offset ] );
120
126
pxSize = 8 ;
121
127
break ;
@@ -127,7 +133,7 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
127
133
}
128
134
result[ QStringLiteral ( " pxSize" ) ] = pxSize;
129
135
offset += pxSize; // Init of band data
130
- result[ QStringLiteral ( " dataSize" ) ] = static_cast <unsigned int >( pxSize * result[ QStringLiteral ( " width" ) ].toInt () * result[ QStringLiteral ( " height" ) ].toInt () );
136
+ result[ QStringLiteral ( " dataSize" ) ] = static_cast <unsigned int >( pxSize ) * result[ QStringLiteral ( " width" ) ].toUInt () * result[ QStringLiteral ( " height" ) ].toUInt ( );
131
137
};
132
138
133
139
if ( static_cast <unsigned int >( bandNo ) > nBands )
@@ -143,13 +149,13 @@ QVariantMap QgsPostgresRasterUtils::parseWkb( const QByteArray &wkb, int bandNo
143
149
readBandHeader ( );
144
150
if ( bandNo == 0 || static_cast <unsigned int >( bandNo ) == bandCnt )
145
151
{
146
- result[ QStringLiteral ( " band%1" ).arg ( bandCnt )] = wkb.mid ( offset, result[ QStringLiteral ( " dataSize" ) ].toInt () );
152
+ result[ QStringLiteral ( " band%1" ).arg ( bandCnt )] = wkb.mid ( offset, result[ QStringLiteral ( " dataSize" ) ].toUInt () );
147
153
}
148
154
else
149
155
{
150
156
// Skip
151
157
}
152
- offset += result[ QStringLiteral ( " dataSize" ) ].toInt ();
158
+ offset += result[ QStringLiteral ( " dataSize" ) ].toUInt ();
153
159
}
154
160
return result;
155
161
}
0 commit comments