[mapserver-users] Possible bug with 3.5 code w/ Proj 4

Scott Shealy sshealy at e811.com
Mon Nov 19 11:26:30 PST 2001


Prelims

System: RedHat 7.2
Code base nightly.tar.gz(latest as of today)
Proj 4.4.4

Config

configure --without-ogr --with-proj 

(found Proj installation successfully)

----> Test Map file
NAME unocal
EXTENT -98.0 26.0 -87.0 29.5
SIZE 800 400
SHAPEPATH "/maps/base_cov"
PROJECTION
	"proj=latlong"
END

  
  LAYER
	NAME "coast"
	DATA "coast"
	STATUS ON
	TYPE LINE
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
  END

  LAYER
	NAME "api"
	DATA "api"
	STATUS ON
	TYPE line 
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
  END
  LAYER
	NAME "intl"
	DATA "intl"
	STATUS ON
	TYPE line
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
  END
  LAYER
	NAME "states"
	DATA "states"
	STATUS ON
	TYPE line 
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
  END
  LAYER
	NAME "counties"
	DATA "counties"
	STATUS ON
	TYPE line 
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
END
  LAYER
	NAME "lease"
	DATA "lease"
	STATUS ON
	TYPE line 
	CLASS
		COLOR 128 128 128
	END
	PROJECTION
		"proj=latlong"
	END
  END
END



---->Test code

#include <stdlib.h>
#include "../../map.h" // we are to directories down in mapserver dist

int main(int argc,char *argv[]) {
	mapObj *m;
	int i;
	m=msLoadMap("./1_2.map");
	printf("%ld\n",m->numlayers);
	for( i=0;i<m->numlayers;i++) {
		printf("%s\n",m->layers[i].name);
	}
}

compile command for test code  

gcc test.c -L/usr/lib -lgd -ljpeg -lfreetype -lpng -lz -ltiff  
-L/usr/local/lib  -lproj ../../libmap.a

Everything links fine

When I run it I get the follwoing output

6
coast
(null)
(null)
(null)
(null)
Segmentation Fault

That is obviously not right... So I started playing around with things

I reconfigured with 

configure --without-ogr
did a make clean and then a make again... recompiled my test program.. and 
changed my map file so that it doesn't have any PROJECTION options(BTW if you 
don't do that you an immediate core dump I guess b/c of the lack of 
PROJECTION SUPPORT)

And now I get the expected output.. which is

6
coast
api
intl
states
counties
lease

So then I whipped out DDD and started debugging.... stepped though the code 
and noticed that when I leave msLoadMap function the map is fine... the data 
structures for all six layers looks fine  but the instant I return from 
msLoadMap and I use the mapObj *m in my test.c program and I inspect its 
layers I quickly notice that thing are not right.  m->layers[0] is ok but if 
I look at m->layers[0..5] in the debugger I notice that some of its members 
are pointing to arbitray places and that in second layer the  name now shows 
up in the group and then after the second one nothing seems right in the 
susbsequent layerObj datastructures.  My first hunch what that somehow I had 
different struct defintion of layer obj b/c of some #ifdef statement when I 
compiled my test.c program but after lookin in map.h the only thing I see 
that could do that is #ifndef SWIG and that is definetly defined for either 
compiling the server or my test program. So my next hunch was that (b/c my 
problem goes away when I don't include --with-proj ... is the the proj code 
or mapserv stub for interacting with have some kind of memory leak..  But I 
am not sure about that b/c I can take the mapserv cgi program and place it in 
my cgi-bin of my apache web server and issue the following command

http://localhost/cgi-bin/mapserv?map=/maps/maps/1_2.map&layers=coast+api+lease 

and I get back a great image...and even project the shape files into other 
projection with no problem...

I am stumped... is this a bug?... Am I doing something wrong.? I need the 
projection stuff to work and I need to do it this way b/c I am using the 
mapscript interface in a java project.  But when testing I ran into this 
problem so I pulled the java stuff out of the equation by writing test.c 
above to isolate the problem ... BTW I have got the mapscript interface 
working in java and I am planning to post to the mailing list how I did that 
as soon as the project is complete(deadlines are looming and I am working 65 
hrs a week ... or I would do it now!)

Any help is greatly appreciated...

BTW we have been using mapserver for about 2 weeks and we LOVE IT!!!!

Scott Shealy
E811 Inc. 







More information about the MapServer-users mailing list