[mapserver-commits] r7744 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Jun 25 02:57:01 EDT 2008
Author: sdlime
Date: 2008-06-25 02:57:01 -0400 (Wed, 25 Jun 2008)
New Revision: 7744
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapraster.c
trunk/mapserver/mapshape.c
Log:
Updated tileindex processing to fall back on the location of the tileindex if SHAPEPATH is not set. (#2369)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-06-25 06:43:17 UTC (rev 7743)
+++ trunk/mapserver/HISTORY.TXT 2008-06-25 06:57:01 UTC (rev 7744)
@@ -12,6 +12,9 @@
Current Version (SVN trunk):
----------------------------
+- mapshape.c: Applied patch to make the location of tiled data relative to the
+ tileindex directory if SHAPEPATH is not set. (#2369)
+
- maptemplate.c: Fixed issues in RFC 36 implementation that prevented mapscript
mapObj->processQueryTemplate() method from working.
Modified: trunk/mapserver/mapraster.c
===================================================================
--- trunk/mapserver/mapraster.c 2008-06-25 06:43:17 UTC (rev 7743)
+++ trunk/mapserver/mapraster.c 2008-06-25 06:57:01 UTC (rev 7744)
@@ -1205,15 +1205,13 @@
shapeObj tshp;
int force_gdal;
- char szPath[MS_MAXPATHLEN], cwd[MS_MAXPATHLEN];
+ char szPath[MS_MAXPATHLEN];
int final_status = MS_SUCCESS;
rectObj searchrect;
gdImagePtr img;
char *pszTmp = NULL;
- cwd[0] = '\0';
-
if(layer->debug > 0 || map->debug > 1)
msDebug( "msDrawRasterLayerLow(%s): entering.\n", layer->name );
@@ -1411,8 +1409,15 @@
#endif
*/
- msBuildPath3(szPath, map->mappath, map->shapepath, filename);
+ char tiAbsFilePath[MS_MAXPATHLEN];
+ msBuildPath(tiAbsFilePath, map->mappath, layer->tileindex); /* absolute path to tileindex file */
+ char *tiAbsDirPath = msGetPath(tiAbsFilePath); /* tileindex file's directory */
+
+ msBuildPath3(szPath, tiAbsDirPath, map->shapepath, filename);
+
+ free(tiAbsDirPath);
+
/*
** Try to open the file, and read the first 8 bytes as a signature.
** If the open fails for a reason other than "bigness" then we use
@@ -1565,7 +1570,7 @@
** Generate an error.
*/
if( !f ) {
- msSetError(MS_IOERR, "(%s)", "msDrawRaster()", filename);
+ msSetError(MS_IOERR, "%s using full path %s", "msDrawRaster()", filename, szPath);
#ifndef IGNORE_MISSING_DATA
if( layer->debug || map->debug )
Modified: trunk/mapserver/mapshape.c
===================================================================
--- trunk/mapserver/mapshape.c 2008-06-25 06:43:17 UTC (rev 7743)
+++ trunk/mapserver/mapshape.c 2008-06-25 06:57:01 UTC (rev 7744)
@@ -1795,6 +1795,17 @@
return(MS_SUCCESS); /* success */
}
+/* Return the absolute path to the given layer's tileindex file's directory */
+void msTileIndexAbsoluteDir(char *tiFileAbsDir, layerObj *layer)
+{
+ char tiFileAbsPath[MS_MAXPATHLEN];
+
+ msBuildPath(tiFileAbsPath, layer->map->mappath, layer->tileindex); /* absolute path to tileindex file */
+ char *tiFileAbsDirTmp = msGetPath(tiFileAbsPath); /* tileindex file's directory */
+ strncpy(tiFileAbsDir, tiFileAbsDirTmp, MS_MAXPATHLEN);
+ free(tiFileAbsDirTmp);
+}
+
int msTiledSHPOpenFile(layerObj *layer)
{
int i;
@@ -1848,6 +1859,9 @@
if((layer->tileitemindex = msDBFGetItemIndex(tSHP->tileshpfile->hDBF, layer->tileitem)) == -1) return(MS_FAILURE);
+ char tiFileAbsDir[MS_MAXPATHLEN];
+ msTileIndexAbsoluteDir(tiFileAbsDir, layer);
+
/* position the source at the FIRST tile to use as a template, this is so the functions that fill the iteminfo array have something to work from */
for(i=0; i<tSHP->tileshpfile->numshapes; i++) {
@@ -1860,22 +1874,18 @@
if(strlen(filename) == 0) continue; /* check again */
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
/* open the shapefile */
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
#ifndef IGNORE_MISSING_DATA
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... fatal error.\n", filename, layer->name );
- return(MS_FAILURE);
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... fatal error.\n", szPath, layer->name );
+ return(MS_FAILURE);
#else
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... ignoring this missing data.\n", filename, layer->name );
- continue; /* check again */
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... ignoring this missing data.\n", szPath, layer->name );
+ continue; /* check again */
+#endif
}
-#endif
return(MS_SUCCESS); /* found a template, ok to proceed */
}
@@ -1910,6 +1920,9 @@
status= msLayerWhichShapes(tlp, rect);
if(status != MS_SUCCESS) return(status); /* could be MS_DONE or MS_FAILURE */
+ char tiFileAbsDir[MS_MAXPATHLEN];
+ msTileIndexAbsoluteDir(tiFileAbsDir, layer);
+
msInitShape(&tshape);
while((status = msLayerNextShape(tlp, &tshape)) == MS_SUCCESS) {
@@ -1923,22 +1936,18 @@
if(strlen(filename) == 0) continue; /* check again */
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
/* open the shapefile */
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
#ifndef IGNORE_MISSING_DATA
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... fatal error.\n", filename, layer->name );
- return(MS_FAILURE);
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... fatal error.\n", szPath, layer->name );
+ return(MS_FAILURE);
#else
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... ignoring this missing data.\n", filename, layer->name );
- continue; /* check again */
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... ignoring this missing data.\n", szPath, layer->name );
+ continue; /* check again */
+#endif
}
-#endif
status = msShapefileWhichShapes(tSHP->shpfile, rect, layer->debug);
if(status == MS_DONE) {
@@ -1962,6 +1971,9 @@
status = msShapefileWhichShapes(tSHP->tileshpfile, rect, layer->debug);
if(status != MS_SUCCESS) return(status); /* could be MS_DONE or MS_FAILURE */
+ char tiFileAbsDir[MS_MAXPATHLEN];
+ msTileIndexAbsoluteDir(tiFileAbsDir, layer);
+
/* position the source at the FIRST shapefile */
for(i=0; i<tSHP->tileshpfile->numshapes; i++) {
if(msGetBit(tSHP->tileshpfile->status,i)) {
@@ -1974,22 +1986,18 @@
if(strlen(filename) == 0) continue; /* check again */
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
/* open the shapefile */
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
#ifndef IGNORE_MISSING_DATA
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... fatal error.\n", filename, layer->name );
- return(MS_FAILURE);
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... fatal error.\n", szPath, layer->name );
+ return(MS_FAILURE);
#else
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... ignoring this missing data.\n", filename, layer->name );
- continue; /* check again */
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... ignoring this missing data.\n", szPath, layer->name );
+ continue; /* check again */
+#endif
}
-#endif
status = msShapefileWhichShapes(tSHP->shpfile, rect, layer->debug);
if(status == MS_DONE) {
@@ -2034,6 +2042,9 @@
return(MS_FAILURE);
}
+ char tiFileAbsDir[MS_MAXPATHLEN];
+ msTileIndexAbsoluteDir(tiFileAbsDir, layer);
+
do {
i = tSHP->shpfile->lastshape + 1;
while(i<tSHP->shpfile->numshapes && !msGetBit(tSHP->shpfile->status,i)) i++; /* next "in" shape */
@@ -2061,22 +2072,18 @@
if(strlen(filename) == 0) continue; /* check again */
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
/* open the shapefile */
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
#ifndef IGNORE_MISSING_DATA
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... fatal error.\n", filename, layer->name );
- return(MS_FAILURE);
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... fatal error.\n", szPath, layer->name );
+ return(MS_FAILURE);
#else
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... ignoring this missing data.\n", filename, layer->name );
- continue; /* check again */
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... ignoring this missing data.\n", szPath, layer->name );
+ continue; /* check again */
+#endif
}
-#endif
status = msShapefileWhichShapes(tSHP->shpfile, tSHP->tileshpfile->statusbounds, layer->debug);
if(status == MS_DONE) {
@@ -2113,22 +2120,18 @@
if(strlen(filename) == 0) continue; /* check again */
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
/* open the shapefile */
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
#ifndef IGNORE_MISSING_DATA
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... fatal error.\n", filename, layer->name );
- return(MS_FAILURE);
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... fatal error.\n", szPath, layer->name );
+ return(MS_FAILURE);
#else
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1) {
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1) {
- if( layer->debug || layer->map->debug ) msDebug( "Unable to open file %s for layer %s ... ignoring this missing data.\n", filename, layer->name );
- continue; /* check again */
- }
- }
+ if( layer->debug || layer->map->debug ) msDebug( "Unable to open shapefile %s for layer %s ... ignoring this missing data.\n", szPath, layer->name );
+ continue; /* check again */
#endif
+ }
status = msShapefileWhichShapes(tSHP->shpfile, tSHP->tileshpfile->statusbounds, layer->debug);
if(status == MS_DONE) {
@@ -2210,9 +2213,15 @@
/* open the shapefile, since a specific tile was request an error should be generated if that tile does not exist */
if(strlen(filename) == 0) return(MS_FAILURE);
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath3(szPath, layer->map->mappath, layer->map->shapepath, filename)) == -1)
- if(msShapefileOpen(tSHP->shpfile, "rb", msBuildPath(szPath, layer->map->mappath, filename)) == -1)
- return(MS_FAILURE);
+
+ char tiFileAbsDir[MS_MAXPATHLEN];
+ msTileIndexAbsoluteDir(tiFileAbsDir, layer);
+
+ msBuildPath3(szPath, tiFileAbsDir, layer->map->shapepath, filename);
+
+ if(msShapefileOpen(tSHP->shpfile, "rb", szPath) == -1) {
+ return(MS_FAILURE);
+ }
}
if((record < 0) || (record >= tSHP->shpfile->numshapes)) return(MS_FAILURE);
More information about the mapserver-commits
mailing list