| 1963 | |
| 1964 | |
| 1965 | int msTiledSHPWhichShapes(layerObj *layer, rectObj rect, int isQuery) |
| 1966 | { |
| 1967 | int i, status; |
| 1968 | char *filename, tilename[MS_MAXPATHLEN]; |
| 1969 | char tiFileAbsDir[MS_MAXPATHLEN]; |
| 1970 | |
| 1971 | msTiledSHPLayerInfo *tSHP=NULL; |
| 1972 | |
| 1973 | if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE ) |
| 1974 | return MS_FAILURE; |
| 1975 | |
| 1976 | tSHP = layer->layerinfo; |
| 1977 | if(!tSHP) { |
| 1978 | msSetError(MS_SHPERR, "Tiled shapefile layer has not been opened.", "msTiledSHPWhichShapes()"); |
| 1979 | return(MS_FAILURE); |
| 1980 | } |
| 1981 | |
| 1982 | msShapefileClose(tSHP->shpfile); /* close previously opened files */ |
| 1983 | |
| 1984 | if(tSHP->tilelayerindex != -1) { /* does the tileindex reference another layer */ |
| 1985 | layerObj *tlp; |
| 1986 | shapeObj tshape; |
| 1987 | |
| 1988 | tlp = (GET_LAYER(layer->map, tSHP->tilelayerindex)); |
| 1989 | status= msLayerWhichShapes(tlp, rect, isQuery); |
| 1990 | if(status != MS_SUCCESS) return(status); /* could be MS_DONE or MS_FAILURE */ |
| 1991 | |
| 1992 | msTileIndexAbsoluteDir(tiFileAbsDir, layer); |
| 1993 | |
| 1994 | msInitShape(&tshape); |
| 1995 | while((status = msLayerNextShape(tlp, &tshape)) == MS_SUCCESS) { |
| 1996 | int try_open; |
| 1997 | |
| 1998 | /* TODO: seems stupid to read the tileitem seperately from the shape, need to fix msTiledSHPOpenFile */ |
| 1999 | if(!layer->data) /* assume whole filename is in attribute field */ |
| 2000 | filename = (char *) msDBFReadStringAttribute(tSHP->tileshpfile->hDBF, tshape.index, layer->tileitemindex); |
| 2001 | else { |
| 2002 | snprintf(tilename, sizeof(tilename), "%s/%s", msDBFReadStringAttribute(tSHP->tileshpfile->hDBF, tshape.index, layer->tileitemindex) , layer->data); |
| 2003 | filename = tilename; |
| 2004 | } |
| 2005 | |
| 2006 | if(strlen(filename) == 0) continue; /* check again */ |
| 2007 | |
| 2008 | try_open = msTiledSHPTryOpen(tSHP->shpfile, layer, tiFileAbsDir, filename); |
| 2009 | if( try_open == MS_DONE ) |
| 2010 | continue; |
| 2011 | else if (try_open == MS_FAILURE ) |
| 2012 | return(MS_FAILURE); |
| 2013 | |
| 2014 | status = msShapefileWhichShapes(tSHP->shpfile, rect, layer->debug); |
| 2015 | if(status == MS_DONE) { |
| 2016 | /* Close and continue to next tile */ |
| 2017 | msShapefileClose(tSHP->shpfile); |
| 2018 | continue; |
| 2019 | } |
| 2020 | else if(status != MS_SUCCESS) { |
| 2021 | msShapefileClose(tSHP->shpfile); |
| 2022 | return(MS_FAILURE); |
nothing calls this directly
no test coverage detected