Multiple Shape Paths
Larry Zimmerman
laz at gonefishing.sk.ca
Fri Feb 23 00:18:52 PST 2001
Hi,
I have the MapServer running on my UDB (aka Multia) with Debian 2.2
Considering that this is roughly equivalent to a P90, I'm impressed
with response times. I'm also impressed that Mapserver actually runs on
a 64-bit CPU.
I have 2 applications running that share a common base, so I was
thinking it would be nice if SHAPEPATH was able to list alternate
search directories for shape files. The code changes to do this seem
pretty trivial.
Here's the patch to mapshape.c to make it work:
----------------------------
int msOpenSHPFile(shapefileObj *shpfile, char *path, char *tile, char *filename)
{
char *dbfFilename;
char newpath[BUFSIZ], *bp;
char old_path[MS_PATH_LENGTH];
getcwd(old_path, MS_PATH_LENGTH); /* save old working directory */
/* make local copy of path for parsing */
bzero(newpath,BUFSIZ);
if(path) strcpy(newpath,path);
if(tile) strcpy(newpath,tile);
if(newpath[0] == '\0')
return(-1); /* both path names are NULL */
/* break path into alternates */
bp = strtok(newpath,": ;");
while(bp != NULL)
{
chdir(bp);
/* ---- open the shapefile file and get basic info ---- */
if((shpfile->hSHP = SHPOpen(filename, "rb" )) != NULL)
break; /* found it */
chdir(old_path); /* restart at old path */
bp = strtok(NULL,":");
};
if((!shpfile->hSHP) || (bp == NULL)) {
msSetError(MS_IOERR, NULL, "msOpenSHPFile()");
sprintf(ms_error.message, "(%s)", filename);
chdir(old_path);
return(-1);
}
-------------------------------- END OF patch
You can check that this works at:
<http://www.gonefishing.sk.ca/geograph/welcome.html>
The "geograph" data is under this directory,
<http://www.gonefishing.sk.ca/geograph/data/>
but the base is elsewhere.
Larry Z.
More information about the MapServer-users
mailing list