[postgis-users] Postgis, Mapserver and PHP Problem

Tien Nguyen sufibaba at yahoo.com
Tue Nov 26 08:01:44 PST 2002


Hello all,

I sent a previous message but perhaps it was sent as
an attachment and might not show up. I'm resending it,
forgive me if this turns out to be redundant.

My configuration is cygwin Postgres 7.2.3-2, Postgis
0.7.3, Mapserver 3.6.3, IIS, all running on XP.

I've just set all of this up 1 week ago. 

The Situation: I've set up the following files.

---------------------------------------------
Displaymap.php
----------------------------------------------
<?php
		$map_path= "d:/MapServerDemo/itasca/php/";
		$map_filename= "s1ex1test.map";
	
		$map_file= $map_path . $map_filename;
		echo "$map_file";
		
		$map = ms_newMapObj("$map_file");
		echo "$map";
		$image=$map->draw();
		$image_url=$image->saveWebImage(MS_PNG,1,1,0);	
		?>
	
		<HTML>
		<HEAD>
		 	<TITLE>Example 1 Displaying a map</TITLE>
		</HEAD>
		<BODY>
		 	<IMG SRC=<?php echo "$image_url"; ?> >
		</BODY>
		</HTML>

-----------------------------------------------

The map file is:
s1ex1.map

------------------------------------------------
NAME S1EX1
	EXTENT -97.238976 41.619778 -82.122902 49.38562
	SIZE 400 300
	SHAPEPATH "D:/MapServerDemo/itasca/php/data/"		
	WEB
		IMAGEPATH "D:/MapServerDemo/itasca/php/tmp/"
		IMAGEURL "http://localhost/mapserver/php/tmp/"
	END

	LAYER # States
	NAME "states"
	DATA states_ugl
	STATUS DEFAULT
	TYPE POLYGON
	CLASSITEM "STATE"
		CLASS
			NAME "Michigan"
			COLOR 255 255 128
			OUTLINECOLOR 0 0 0
		END # end of class object
	END # end of layer object
END # end of map file

---------------------------------------------------

The above map file uses a shape file and it works
fine.

However the problem is when I changed the datasource
of the map file from above to postgres. I used
shp2pgsql to convert the shape into posgres. 

The error message I got was:

"msPOSTGISLayerOpen(): Query error.
msPOSTGISLayerOpen called but unimplemented!"

---------------------------------------------------

NAME S1EX1
EXTENT -97.238976 41.619778 -82.122902 49.38562
SIZE 400 300

	WEB
		IMAGEPATH "D:/MapServerDemo/itasca/php/tmp/"
		IMAGEURL "http://localhost/mapserver/php/tmp/"
	END
	
LAYER # States
 NAME "states"
  CONNECTIONTYPE postgis
  CONNECTION "user=postgres dbname=myGISdb
host=localhost" 
  #NOTE host=localhost assumes that your MapServer
  #  application is running on the same machine
  #  as your PostgreSQL installation

  DATA "the_geom from states_ugl"
  STATUS DEFAULT
  TYPE POLYGON
  CLASSITEM "STATE"
  CLASS
    NAME "Michigan"
    COLOR 255 255 128
    OUTLINECOLOR 0 0 0
  END # end of class object
END # end of layer object
END # end of map file

----------------------------------------------------

However, the new map file works fine with the
following html file.

Testfile.html
-------------------------------

<html>
<body>

src="http://localhost/Scripts/mapserv.exe?map=E:/terrasipProjects/tutorial35/s1/s1ex1.map&mode=map">
		
</body>
</html>

-----------------------------------------

It seems that Mapserver is able to connect the postgis
datasource without a problem.  However, when I tried
to use PHP mapscript to acess postgis via mapserver
map file, it couldn't see the source.

Since there are so many people on this forum that is
so much more knowledgeable than myself, perhaps
someone might be able to give me a hand with this
problem.

Many thanks in advance !

Cheers. Tien :)



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the postgis-users mailing list