| 1483 | /************************************************************************/ |
| 1484 | |
| 1485 | int msRASTERLayerGetExtent(layerObj *layer, rectObj *extent) |
| 1486 | |
| 1487 | { |
| 1488 | #ifndef USE_GDAL |
| 1489 | return MS_FAILURE; |
| 1490 | #else |
| 1491 | char szPath[MS_MAXPATHLEN]; |
| 1492 | mapObj *map = layer->map; |
| 1493 | double adfGeoTransform[6]; |
| 1494 | int nXSize, nYSize; |
| 1495 | GDALDatasetH hDS; |
| 1496 | shapefileObj *tileshpfile; |
| 1497 | int tilelayerindex = -1; |
| 1498 | CPLErr eErr = CE_Failure; |
| 1499 | char *decrypted_path; |
| 1500 | |
| 1501 | if( (!layer->data || strlen(layer->data) == 0) |
| 1502 | && layer->tileindex == NULL) |
| 1503 | { |
| 1504 | /* should we be issuing a specific error about not supporting |
| 1505 | extents for tileindexed raster layers? */ |
| 1506 | return MS_FAILURE; |
| 1507 | } |
| 1508 | |
| 1509 | if( map == NULL ) |
| 1510 | return MS_FAILURE; |
| 1511 | |
| 1512 | /* If the layer use a tileindex, return the extent of the tileindex shapefile/referenced layer */ |
| 1513 | if (layer->tileindex) |
| 1514 | { |
| 1515 | tilelayerindex = msGetLayerIndex(map, layer->tileindex); |
| 1516 | if(tilelayerindex != -1) /* does the tileindex reference another layer */ |
| 1517 | return msLayerGetExtent(GET_LAYER(map, tilelayerindex), extent); |
| 1518 | else |
| 1519 | { |
| 1520 | tileshpfile = (shapefileObj *) malloc(sizeof(shapefileObj)); |
| 1521 | MS_CHECK_ALLOC(tileshpfile, sizeof(shapefileObj), MS_FAILURE); |
| 1522 | |
| 1523 | if(msShapefileOpen(tileshpfile, "rb", msBuildPath3(szPath, map->mappath, map->shapepath, layer->tileindex), MS_TRUE) == -1) |
| 1524 | if(msShapefileOpen(tileshpfile, "rb", msBuildPath(szPath, map->mappath, layer->tileindex), MS_TRUE) == -1) |
| 1525 | return MS_FAILURE; |
| 1526 | |
| 1527 | *extent = tileshpfile->bounds; |
| 1528 | msShapefileClose(tileshpfile); |
| 1529 | free(tileshpfile); |
| 1530 | return MS_SUCCESS; |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | msTryBuildPath3(szPath, map->mappath, map->shapepath, layer->data); |
| 1535 | decrypted_path = msDecryptStringTokens( map, szPath ); |
| 1536 | |
| 1537 | msAcquireLock( TLOCK_GDAL ); |
| 1538 | if( decrypted_path ) |
| 1539 | { |
| 1540 | hDS = GDALOpen(decrypted_path, GA_ReadOnly ); |
| 1541 | msFree( decrypted_path ); |
| 1542 | } |
nothing calls this directly
no test coverage detected