[Mapserver-dev] msBuildPath etc...

Steve Lime steve.lime at dnr.state.mn.us
Tue Feb 4 23:46:40 EST 2003


Well, I made the switch tonite. Shapepath is not passed as an argument
to msLayerOpen or msSHPOpenFile. 
msLayerOpen now uses msBuildPath and msBuildPath3 to create a fully
pathed filename to pass to msSHPOpenFile. I'm hoping that the path
building functions equate NULL and "". This change required touching
many files although the vast majority of edits where trivial. I've
tested with the demo and that went fine. Tiled data raster or vector
have not been tested. Nor have I tested the various cases where
shapepath is unset, or when shapepath is set but the file exists
relative to mappath only.

I think this change makes the API make more sense and removes some of
the 3.4isms when shapefiles were king from the code.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> Daniel Morissette <morissette at dmsolutions.ca> 02/03/03 22:40 PM >>>
Steve Lime wrote:
> 
> Hi folks: I'd like to ditch passing shapepath around to msOpenLayer
and
> the shapefile routines. What's the best way to use the various
> msBuildPath functions to do that? For the shapefile (and Xbase
> functions) i'd like to simply pass the final file name. The logic (I
> think) would be:
> 
>   - if DATA or TABLE is full path, then use it
>   - if DATA or TABLE relative, and SHAPEPATH is valid then append it
>   - if SHAPEPATH relative, then append MAPPATH
> 
> If those that wrote those functions would help with their
interpretation
> that would be great.
> 

Hi Steve,

FYI msBuildPath() already contains logic to prevent concatenating two
absolute paths.  There is also a msBuildPath3() function that takes 3
path components and combines them, so I believe you should be able to do
this:

  char path_buffer[MS_MAXPATHLEN];
  msBuildPath3(path_buffer, map_path, shape_path, data_filename);

Unless I'm mistaken, this call should do exactly what you proposed
above, i.e.

 - if data_filename is an absolute path then map_path and shape_path
   are ignored.
 - if data_filename is relative then it is appended to shape_path
 - if shape_path is absolute then map_path is ignored
 - if shape_path is relative then it is appended to map_path.
 - finally, if shape_path is null then it should be automatically 
   ignored and the result will be map_path appended to data_filename.

Oh, and if some error happens then the function returns NULL, otherwise
it will return a reference to path_buffer.

Julien, can you please confirm that this is the expected behavior?

Daniel
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------
_______________________________________________
Mapserver-dev mailing list
Mapserver-dev at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev




More information about the mapserver-dev mailing list