| 1157 | | if( EQUAL(papszFields[nCount-1],"units=Feet") ) |
|---|
| 1158 | | { |
|---|
| 1159 | | oSRS.SetLinearUnits( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) ); |
|---|
| 1160 | | } |
|---|
| 1161 | | else if( EQUAL(papszFields[nCount-1],"units=Seconds") |
|---|
| 1162 | | && oSRS.IsGeographic() ) |
|---|
| 1163 | | { |
|---|
| 1164 | | /* convert geographic coordinate systems in seconds to degrees */ |
|---|
| 1165 | | adfGeoTransform[0] /= 3600.0; |
|---|
| 1166 | | adfGeoTransform[1] /= 3600.0; |
|---|
| 1167 | | adfGeoTransform[2] /= 3600.0; |
|---|
| 1168 | | adfGeoTransform[3] /= 3600.0; |
|---|
| 1169 | | adfGeoTransform[4] /= 3600.0; |
|---|
| 1170 | | adfGeoTransform[5] /= 3600.0; |
|---|
| 1171 | | } |
|---|
| 1172 | | |
|---|
| | 1158 | if( EQUALN( papszFields[nCount-1],"units",5)) |
|---|
| | 1159 | { |
|---|
| | 1160 | /* Handle linear units first. */ |
|---|
| | 1161 | if (EQUAL(papszFields[nCount-1],"units=Feet") ) |
|---|
| | 1162 | oSRS.SetLinearUnitsAndUpdateParameters( SRS_UL_FOOT, atof(SRS_UL_FOOT_CONV) ); |
|---|
| | 1163 | else if (EQUAL(papszFields[nCount-1],"units=Meters") ) |
|---|
| | 1164 | oSRS.SetLinearUnitsAndUpdateParameters( SRS_UL_METER, 1. ); |
|---|
| | 1165 | else if (EQUAL(papszFields[nCount-1],"units=Km") ) |
|---|
| | 1166 | oSRS.SetLinearUnitsAndUpdateParameters( "Kilometer", 1000. ); |
|---|
| | 1167 | else if (EQUAL(papszFields[nCount-1],"units=Yards") ) |
|---|
| | 1168 | oSRS.SetLinearUnitsAndUpdateParameters( "Yard", .9144 ); |
|---|
| | 1169 | else if (EQUAL(papszFields[nCount-1],"units=Miles") ) |
|---|
| | 1170 | oSRS.SetLinearUnitsAndUpdateParameters( "Mile", 1609.344 ); |
|---|
| | 1171 | else if (EQUAL(papszFields[nCount-1],"units=Nautical Miles") ) |
|---|
| | 1172 | oSRS.SetLinearUnitsAndUpdateParameters( SRS_UL_NAUTICAL_MILE, atof(SRS_UL_NAUTICAL_MILE_CONV) ); |
|---|
| | 1173 | |
|---|
| | 1174 | /* Only handle angular units if we know the projection is geographic. */ |
|---|
| | 1175 | if (oSRS.IsGeographic()) |
|---|
| | 1176 | { |
|---|
| | 1177 | if (EQUAL(papszFields[nCount-1],"units=Radians") ) |
|---|
| | 1178 | oSRS.SetAngularUnits( SRS_UA_RADIAN, 1. ); |
|---|
| | 1179 | else |
|---|
| | 1180 | { |
|---|
| | 1181 | /* Degrees, minutes and seconds will all be represented as degrees. */ |
|---|
| | 1182 | oSRS.SetAngularUnits( SRS_UA_DEGREE, atof(SRS_UA_DEGREE_CONV)); |
|---|
| | 1183 | |
|---|
| | 1184 | double conversionFactor = 1.; |
|---|
| | 1185 | if (EQUAL(papszFields[nCount-1],"units=Minutes") ) |
|---|
| | 1186 | conversionFactor = 60.; |
|---|
| | 1187 | else if( EQUAL(papszFields[nCount-1],"units=Seconds") ) |
|---|
| | 1188 | conversionFactor = 3600.; |
|---|
| | 1189 | adfGeoTransform[0] /= conversionFactor; |
|---|
| | 1190 | adfGeoTransform[1] /= conversionFactor; |
|---|
| | 1191 | adfGeoTransform[2] /= conversionFactor; |
|---|
| | 1192 | adfGeoTransform[3] /= conversionFactor; |
|---|
| | 1193 | adfGeoTransform[4] /= conversionFactor; |
|---|
| | 1194 | adfGeoTransform[5] /= conversionFactor; |
|---|
| | 1195 | } |
|---|
| | 1196 | } |
|---|
| | 1197 | } |
|---|
| | 1215 | } |
|---|
| | 1216 | |
|---|
| | 1217 | /************************************************************************/ |
|---|
| | 1218 | /* ProcessRPCinfo() */ |
|---|
| | 1219 | /* */ |
|---|
| | 1220 | /* Extract RPC transformation coefficients if they are present */ |
|---|
| | 1221 | /* and sets into the standard metadata fields for RPC. */ |
|---|
| | 1222 | /************************************************************************/ |
|---|
| | 1223 | |
|---|
| | 1224 | void ENVIDataset::ProcessRPCinfo( const char *pszRPCinfo ) |
|---|
| | 1225 | { |
|---|
| | 1226 | char **papszFields; |
|---|
| | 1227 | char sVal[1280]; |
|---|
| | 1228 | int nCount; |
|---|
| | 1229 | |
|---|
| | 1230 | papszFields = SplitList( pszRPCinfo ); |
|---|
| | 1231 | nCount = CSLCount(papszFields); |
|---|
| | 1232 | |
|---|
| | 1233 | if( nCount < 90 ) |
|---|
| | 1234 | { |
|---|
| | 1235 | CSLDestroy( papszFields ); |
|---|
| | 1236 | return; |
|---|
| | 1237 | } |
|---|
| | 1238 | |
|---|
| | 1239 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[0])); |
|---|
| | 1240 | SetMetadataItem("RPC_LINE_OFF",sVal); |
|---|
| | 1241 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[5])); |
|---|
| | 1242 | SetMetadataItem("RPC_LINE_SCALE",sVal); |
|---|
| | 1243 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[1])); |
|---|
| | 1244 | SetMetadataItem("RPC_SAMP_OFF",sVal); |
|---|
| | 1245 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[6])); |
|---|
| | 1246 | SetMetadataItem("RPC_SAMP_SCALE",sVal); |
|---|
| | 1247 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[2])); |
|---|
| | 1248 | SetMetadataItem("RPC_LAT_OFF",sVal); |
|---|
| | 1249 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[7])); |
|---|
| | 1250 | SetMetadataItem("RPC_LAT_SCALE",sVal); |
|---|
| | 1251 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[3])); |
|---|
| | 1252 | SetMetadataItem("RPC_LONG_OFF",sVal); |
|---|
| | 1253 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[8])); |
|---|
| | 1254 | SetMetadataItem("RPC_LONG_SCALE",sVal); |
|---|
| | 1255 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[4])); |
|---|
| | 1256 | SetMetadataItem("RPC_HEIGHT_OFF",sVal); |
|---|
| | 1257 | snprintf(sVal, sizeof(sVal), "%.16f",atof(papszFields[9])); |
|---|
| | 1258 | SetMetadataItem("RPC_HEIGHT_SCALE",sVal); |
|---|
| | 1259 | |
|---|
| | 1260 | sVal[0] = '\0'; |
|---|
| | 1261 | for(int i = 0; i < 20; i++ ) |
|---|
| | 1262 | snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16f ", |
|---|
| | 1263 | atof(papszFields[10+i])); |
|---|
| | 1264 | SetMetadataItem("RPC_LINE_NUM_COEFF",sVal); |
|---|
| | 1265 | |
|---|
| | 1266 | sVal[0] = '\0'; |
|---|
| | 1267 | for(int i = 0; i < 20; i++ ) |
|---|
| | 1268 | snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16f ", |
|---|
| | 1269 | atof(papszFields[30+i])); |
|---|
| | 1270 | SetMetadataItem("RPC_LINE_DEN_COEFF",sVal); |
|---|
| | 1271 | |
|---|
| | 1272 | sVal[0] = '\0'; |
|---|
| | 1273 | for(int i = 0; i < 20; i++ ) |
|---|
| | 1274 | snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16f ", |
|---|
| | 1275 | atof(papszFields[50+i])); |
|---|
| | 1276 | SetMetadataItem("RPC_SAMP_NUM_COEFF",sVal); |
|---|
| | 1277 | |
|---|
| | 1278 | sVal[0] = '\0'; |
|---|
| | 1279 | for(int i = 0; i < 20; i++ ) |
|---|
| | 1280 | snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16f ", |
|---|
| | 1281 | atof(papszFields[70+i])); |
|---|
| | 1282 | SetMetadataItem("RPC_SAMP_DEN_COEFF",sVal); |
|---|
| | 1283 | |
|---|
| | 1284 | snprintf(sVal, sizeof(sVal), "%.16f", |
|---|
| | 1285 | atof(papszFields[3]) - atof(papszFields[8]) / 2.0 ); |
|---|
| | 1286 | SetMetadataItem("RPC_MIN_LONG",sVal); |
|---|
| | 1287 | |
|---|
| | 1288 | snprintf(sVal, sizeof(sVal), "%.16f", |
|---|
| | 1289 | atof(papszFields[3]) + atof(papszFields[8]) / 2.0 ); |
|---|
| | 1290 | SetMetadataItem("RPC_MAX_LONG",sVal); |
|---|
| | 1291 | |
|---|
| | 1292 | snprintf(sVal, sizeof(sVal), "%.16f", |
|---|
| | 1293 | atof(papszFields[2]) - atof(papszFields[7]) / 2.0 ); |
|---|
| | 1294 | SetMetadataItem("RPC_MIN_LAT",sVal); |
|---|
| | 1295 | |
|---|
| | 1296 | snprintf(sVal, sizeof(sVal), "%.16f", |
|---|
| | 1297 | atof(papszFields[2]) + atof(papszFields[7]) / 2.0 ); |
|---|
| | 1298 | SetMetadataItem("RPC_MAX_LAT",sVal); |
|---|
| | 1299 | |
|---|