| 676 | /************************************************************************/ |
| 677 | |
| 678 | int msRasterQueryByRect(mapObj *map, layerObj *layer, rectObj queryRect) |
| 679 | |
| 680 | { |
| 681 | #ifndef USE_GDAL |
| 682 | msSetError( MS_IMGERR, |
| 683 | "Rasters queries only supported with GDAL support enabled.", |
| 684 | "msRasterQueryByRect()" ); |
| 685 | return MS_FAILURE; |
| 686 | #else |
| 687 | int status = MS_SUCCESS; |
| 688 | char *filename=NULL; |
| 689 | |
| 690 | layerObj *tlp=NULL; /* pointer to the tile layer either real or temporary */ |
| 691 | int tileitemindex=-1, tilelayerindex=-1; |
| 692 | shapeObj tshp; |
| 693 | char tilename[MS_PATH_LENGTH]; |
| 694 | int done; |
| 695 | |
| 696 | char szPath[MS_MAXPATHLEN]; |
| 697 | rectObj searchrect; |
| 698 | rasterLayerInfo *rlinfo = NULL; |
| 699 | char tiAbsFilePath[MS_MAXPATHLEN]; |
| 700 | char *tiAbsDirPath = NULL; |
| 701 | |
| 702 | /* -------------------------------------------------------------------- */ |
| 703 | /* Get the layer info. */ |
| 704 | /* -------------------------------------------------------------------- */ |
| 705 | msRasterLayerInfoInitialize( layer ); |
| 706 | rlinfo = (rasterLayerInfo *) layer->layerinfo; |
| 707 | |
| 708 | /* -------------------------------------------------------------------- */ |
| 709 | /* Clear old results cache. */ |
| 710 | /* -------------------------------------------------------------------- */ |
| 711 | if(layer->resultcache) { |
| 712 | if(layer->resultcache->results) free(layer->resultcache->results); |
| 713 | free(layer->resultcache); |
| 714 | layer->resultcache = NULL; |
| 715 | } |
| 716 | |
| 717 | /* -------------------------------------------------------------------- */ |
| 718 | /* Initialize the results cache. */ |
| 719 | /* -------------------------------------------------------------------- */ |
| 720 | layer->resultcache = (resultCacheObj *)msSmallMalloc(sizeof(resultCacheObj)); |
| 721 | layer->resultcache->results = NULL; |
| 722 | layer->resultcache->numresults = layer->resultcache->cachesize = 0; |
| 723 | layer->resultcache->bounds.minx = |
| 724 | layer->resultcache->bounds.miny = |
| 725 | layer->resultcache->bounds.maxx = |
| 726 | layer->resultcache->bounds.maxy = -1; |
| 727 | |
| 728 | /* -------------------------------------------------------------------- */ |
| 729 | /* Check if we should really be acting on this layer and */ |
| 730 | /* provide debug info in various cases. */ |
| 731 | /* -------------------------------------------------------------------- */ |
| 732 | if(layer->debug > 0 || map->debug > 1) |
| 733 | msDebug( "msRasterQueryByRect(%s): entering.\n", layer->name ); |
| 734 | |
| 735 | if(!layer->data && !layer->tileindex) { |
no test coverage detected