** Returns extent of spatial coverage for a layer. ** ** If layer->extent is set then this value is used, otherwise the ** driver-specific implementation is called (this can be expensive). ** ** If layer is not already opened then it is opened and closed (so this ** function can be called on both opened or closed layers). ** ** Returns MS_SUCCESS/MS_FAILURE. */
| 279 | ** Returns MS_SUCCESS/MS_FAILURE. |
| 280 | */ |
| 281 | int msLayerGetExtent(layerObj *layer, rectObj *extent) |
| 282 | { |
| 283 | int need_to_close = MS_FALSE, status = MS_SUCCESS; |
| 284 | |
| 285 | if (MS_VALID_EXTENT(layer->extent)) |
| 286 | { |
| 287 | *extent = layer->extent; |
| 288 | return MS_SUCCESS; |
| 289 | } |
| 290 | |
| 291 | if (!msLayerIsOpen(layer)) |
| 292 | { |
| 293 | if (msLayerOpen(layer) != MS_SUCCESS) |
| 294 | return MS_FAILURE; |
| 295 | need_to_close = MS_TRUE; |
| 296 | } |
| 297 | |
| 298 | if ( ! layer->vtable) { |
| 299 | int rv = msInitializeVirtualTable(layer); |
| 300 | if (rv != MS_SUCCESS) { |
| 301 | if (need_to_close) |
| 302 | msLayerClose(layer); |
| 303 | return rv; |
| 304 | } |
| 305 | } |
| 306 | status = layer->vtable->LayerGetExtent(layer, extent); |
| 307 | |
| 308 | if (need_to_close) |
| 309 | msLayerClose(layer); |
| 310 | |
| 311 | return(status); |
| 312 | } |
| 313 | |
| 314 | int msLayerGetItemIndex(layerObj *layer, char *item) |
| 315 | { |
no test coverage detected