[mapserver-users] Strage behaviour of dynamic classes (color v/s outlinecolor)

Vinko Vrsalovic v at w.cl
Mon Jan 28 23:47:58 PST 2002


Hello again!

	I've been trying to reduce at a minimum the use of the map file
	in order to obtain maximum flexibility (ie, i'd like almost all
	parameters to be configurable trough a web interface).

	My problem is the following:

	I'm creating layers according to some user input, the layers
	are drawn, but the polygon layers take the color parameter
	as the outline color and the color inside the polygons remain
	always the same as the background color of the image.

	Point layers are drawn ok and the trouble i have with line
	layers i guess it's because the symbol set.

	The strange thing about all this is that if i write a map file
	with the same attributes i'm setting dynamically, the polygons
	are filled with the color correctly.

	Here is all the data i think is relevant to the issue
	(is rather (but not too) long, so thanks a lot if you look at 
	it all :-) )

	The version:

	MapScript
	MapScript Version ($Revision: 1.76 $ $Date: 2002/01/20 21:30:01
	$)
	MapServer version 3.5 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
	SUPPORTS=PROJ SUPPORTS=TTF SUPPORTS=WMS_SERVER INPUT=EPPL7
	INPUT=GDAL INPUT=SHAPEFILE
	
	(PHP 4.0.6, Apache 1.3.20)

	The map file:

NAME FIRSTMAP
SIZE 500 500
STATUS ON
SYMBOLSET ../symbols/symbols.sym
EXTENT 173340 6228551 471816 6466951
UNITS METERS
SHAPEPATH "../data"
IMAGECOLOR 150 220 233

WEB
IMAGEPATH "/var/www/html/ms/tmp/"
IMAGEURL "/tmp/"
END

END

	The code:

	$layers is an array that comes with the name of the shapefiles,
	$data is an array with the corresponding attributes to set
	in every layer. I create them and afterwars draw them with
	$layer->draw($img);

	Could the problem be that I 'lose' the classObj's? (or they
	remain attached to the layers even outside the function?)
	I think they remain 'attached' because if i change some
	attributes of the classes it shows on the resulting image.

<?php

dl('php_mapscript.so');

function add_layers($map,$layers,$data) {

	$blanco = $map->addColor(255,255,255);
	$c = $map->addColor(200,100,0);
	$d = $map->addColor(150,200,0);

	for ($i=0;$i<count($layers)-1;$i++) {

		$lay[$layers[$i]] = ms_newLayerObj($map);
	
		$lay[$layers[$i]]->set("name","n".$layers[$i]);
		$lay[$layers[$i]]->set("data",$layers[$i]);
		$lay[$layers[$i]]->set("type","MS_LAYER_".$data["tipo"][$i]);
		$lay[$layers[$i]]->setMetadata("RESULT_FIELDS",'"'.$data["metadata"][$i].'"');
		$lay[$layers[$i]]->set("status",MS_ON);

		$cla[$layers[$i]] = ms_newClassObj($lay[$layers[$i]]);
		switch($data["tipo"][$i]) {

			case "POLYGON":
				$cla[$layers[$i]]->set("color",$blanco);
				break;

			case "LINE":
				$cla[$layers[$i]]->set("color",$c);
				$cla[$layers[$i]]->set("symbol",9);
				$cla[$layers[$i]]->set("size",4);
				break;

			case "POINT":
				$cla[$layers[$i]]->set("color",$d);
				$cla[$layers[$i]]->set("outlinecolor",$blanco);
				$cla[$layers[$i]]->set("symbol",3);
				$cla[$layers[$i]]->set("size",8);
				break;

		}
		
	}

	return $lay;
}

?>


Thanks!,
-- 
V. <v at w.cl>



More information about the MapServer-users mailing list