[Mapserver-users] How does one create .map files?

Merrett, Mike mike.merrett at city.whitehorse.yk.ca
Thu May 27 13:59:49 EDT 2004


here is part of some code I am developing for user selection and then
building of map files:  (not all the code is here - and each database entry
Details column contains a complete Layers section (which I copy/paste into
the DB after verifying it works) then I call the processing script (mostly
gmap75) with the name of the map file.

Hope this helps,
	Mike Merrett

function do_build_map_file() {
	
	// get a random non existing file name for the map file
	do {
		$tmpfname = "tmp/TMPMAP". trim(strval( mt_rand( 1, (2^14) *
mt_rand(1,(2^15)) ))) .".map";
	} while ( ! file_exists( $tmpfname));

	$handle = fopen($tmpfname, "w");
	map_put_headers( $handle );   // put the headers (i.e. everything
above the layers in a normal map file

	//layers are selected -- now build the map file
	$link = dbx_connect (DBX_MYSQL, "localhost", "mysql",
"MapServer_Layers", "MapServer_Layers")
	 			or die ("could not connect");

	foreach( $_POST['layers'] as $a_Layer ) {
		$sql = "select Details"
			."   from MapServer_Layers "
			."   where LayerName = '" . $a_Layer ."'"
			;
		$result = dbx_query($link, $sql, DBX_RESULT_INDEX |
DBX_RESULT_INFO );

		fwrite( $handle, $result->data[0][0]);
		fwrite( $handle, "\n\n");
	}
	fwrite($handle, "\n\nEND");
	fclose($handle);

	return ($tmpfname);
}

-----Original Message-----
From: mapserver-users-admin at lists.gis.umn.edu
[mailto:mapserver-users-admin at lists.gis.umn.edu]On Behalf Of Alejandro
Vartabedian
Sent: May 27, 2004 10:33 AM
To: mapserver-users at lists.gis.umn.edu
Subject: Re: [Mapserver-users] How does one create .map files?


well,
	based on Ed theory, i think some php Smarty templates and
phpmapscript 
can do the job well and easy.
	i'll try this and post some news.

	good luck.

Namnath, Sharyn wrote:
> Thanks to everyone who offered (and is still offering) suggestions.  I
will
> certainly look into all of them.  I know I'm not completely enamored with
> the idea of creating a map file for every map I'm going to need, but if I
> have to then so be it.  I too am interested in your method Ed.  If you
care
> to share, I bet a lot more of us are interested.
> 
> - Sharyn
> 
> 
> -----Original Message-----
> From: Tyler Mitchell [mailto:TMitchell at lignum.com] 
> Sent: Thursday, May 27, 2004 8:03 AM
> To: Ed McNierney
> Cc: mapserver-users at lists.gis.umn.edu
> Subject: RE: [Mapserver-users] How does one create .map files?
> 
> Sounds interesting Ed, I'd love to see an example of your methodology.
> 
> Tyler
> 
> mapserver-users-admin at lists.gis.umn.edu wrote on 05/26/2004 06:57:35 PM:
> 
> 
>>Sharyn -
>>
>>For several years now I've been using the C preprocessor to take
>>"template" MAP files and do #includes, macro expansion, etc.  It's
>>pretty convenient if you need to either generate lots of MAP files or
>>lots of layers in a MAP file.  We've got around 150+ MAP files, around
>>60 or 70 layers, and nearly 350,000 source data files, and it is a good
>>way to keep things organized.
>>
>>   - Ed
>>
>>Ed McNierney
>>President and Chief Mapmaker
>>TopoZone.com
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list