MCPcopy Index your code
hub / github.com/MapServer/MapServer / msRASTERLayerGetExtent

Function msRASTERLayerGetExtent

maprasterquery.c:1485–1578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1483/************************************************************************/
1484
1485int 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 }

Callers

nothing calls this directly

Calls 11

msGetLayerIndexFunction · 0.85
msLayerGetExtentFunction · 0.85
msShapefileOpenFunction · 0.85
msBuildPath3Function · 0.85
msBuildPathFunction · 0.85
msShapefileCloseFunction · 0.85
msTryBuildPath3Function · 0.85
msDecryptStringTokensFunction · 0.85
msAcquireLockFunction · 0.85
msFreeFunction · 0.85
msReleaseLockFunction · 0.85

Tested by

no test coverage detected