[mapserver-users] HELP-Bug or Stupid Error on my part in MAPSERVER C API
Scott Shealy
sshealy at e811.com
Fri Dec 7 11:47:25 PST 2001
Hey guys I have got a problem that I have been trying to figure out for over
3 days now and was wondering if anyone else has any clues.
I am using the following Map File ....
---> begin Map file
NAME test
EXTENT -97.000 25.76 -88.049 31.00
SIZE 800 400
SHAPEPATH "/test_maps/base_cov"
IMAGECOLOR 0 0 204
SYMBOL
NAME "circle"
TYPE ellipse
FILLED true
POINTS 1 1 END
END
LAYER
NAME "query_wells"
DATA "all_wells"
STATUS ON
TYPE POINT
CLASS
EXPRESSION ([api] EQ 42704400350000 OR [api] EQ 17101200790000)
SYMBOL "circle"
COLOR 0 0 0
SIZE 5
END
TOLERANCEUNITS pixels
TOLERANCE 20
END
END
<--- End Map file
I am using the following C program to demonstrate my problem
---> Begin c program
#include <stdlib.h>
#include "../../map.h"
int main(int argc,char *argv[]) {
mapObj *m;
layerObj *l;
int i,j,layernum,return_code,layer_num;
gdImagePtr img;
for(i=0; i<10;i++) {
printf("starting iteration %ld\n",i);
m=msLoadMap("./test.map");
if(m==NULL) {
printf("error loading map on %ld iteration",i);
exit(-1);
}
printf("Number of layers is %ld\n",m->numlayers);
for( j=0;j<m->numlayers;j++) {
printf("%s\n",m->layers[j].name);
}
img = msDrawMap(m);
msSaveImage(img,"/tmp/xxx.png",m->imagetype,m->transparent,
m->interlace,m->imagequality);
msFreeImage(img);
msFreeMap(m);
}
}
<--- End C test program
When I run this program the first iteration of the main loop is ok and the
genrated map image is correct... But the second iteration of the main loop
fails at loading the map. I stuck this thing in the debugger and when I
enter msLoadMap on the second iteration everything is fine. It appears to
successfully open the map and then proceeds to parse the map file. When the
parser goes to get the first token it returns nothing and the msLoadMap
function bails with an an error. That definitely doesn't seem right but I
can't figure out why it is bailing. I can modify my setup two ways to make
this problem go away but neither are acceptable but may provide some clues as
to what is going on.
1) In my map file I can remove the EXPRESSION from the CLASS and everything
runs fine... It goes through each iteration just fine and draws the map.
2)If I move the msLoadmap and msFreeMap() outside the main loop(ie only load
the map once) everything works fine... even with the EXPRESSION Object in the
map file. (But this won't work for me)
If I am using the mapserver C API correctly (thats a big if...please let me
know if I am not) this sort of suggests to me that there might be a bug in
the cleaning up of resources associated with EXPRESSION Objects.
Other pertinant details include (using mapserver nightly build from 2 days
ago(also used one from about a month ago with the same results)).
used this configure command
configure --with-proj --with-gdal
compile my test program with the following script
#!/bin/sh
FLAGS="-DUSE_PROJ -DUSE_PROJ_API_H -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP
-DUSE_GD_FT -DUSE_TIFF -DUSE_JPEG -DUSE_EPPL -DUSE_GDAL -DUSE_WMS
-DIGNORE_MISSING_DATA"
gcc test2.c $FLAGS -g -L/usr/lib -lgd -ljpeg -lfreetype -lpng -lz -ltiff
-L/usr/local/lib -lproj -lgdal.1.1 ../../libmap.a
Any suggestion is greatly appreciated... meanwhile I will keep working on
it...
Thanks,
Scott Shealy
More information about the MapServer-users
mailing list