[mapserver-users] How to create a chart layer from a php function

Sandra Liliana Moreno s.lilianamoreno at gmail.com
Fri Oct 3 12:43:35 PDT 2008


Hi!!!!

I want to create a chart layer from a PHP function, but in the style
of the class of the layer,
a parameter called "SIZE" in the mapfile, I do not know how to set in
the object styleObj.
Does anyone know how to do this?
	
Thank.

#==========MapFile===========#

LAYER
	NAME "Grafica"
	TYPE CHART
	STATUS DEFAULT
	CONNECTIONTYPE POSTGIS
	CONNECTION "host=127.0.0.1 dbname=xxx user=xxx password=xxx port=5432"
	DATA "the_geom FROM (select a.the_geom AS the_geom, a.dpto, a.gid AS
gid, a.nom_dpto,a.area_km2, b.rio, b.queman from departamento a,
dpto_viv_basura b WHERE a.dpto = b.dpto) AS foo USING UNIQUE gid"
	PROCESSING "CHART_TYPE=pie"
	PROCESSING "CHART_SIZE=30"
	CLASS
		NAME "Rio"
		STYLE
			SIZE [rio]
			COLOR 255 244 237
		END
	END
	CLASS
		NAME "Queman"
		STYLE
			SIZE [queman]
			COLOR 255 217 191
		END
	END
END #LAYER


/////////////////PHP Function///////////////////

function crearLayerGrafica($miMap){
	$layer = ms_newLayerObj($miMap);
	$layer->set( "name", "Grafica");
	$layer->set( "type", MS_LAYER_CHART);
	$layer->set( "status", MS_ON);
	$layer->set("connectiontype", MS_POSTGIS);
	$layer->set("connection", "host=127.0.0.1 dbname=xxx user=xxx
password=xxx port=5432");
	$layer->set("data","the_geom FROM (select a.the_geom AS the_geom,
a.dpto, a.gid AS gid, a.nom_dpto,a.area_km2, b.rio, b.queman from
departamento a, dpto_viv_basura b WHERE a.dpto = b.dpto) AS foo USING
UNIQUE gid");
	$layer->setProcessing("CHART_TYPE=pie");
	$layer->setProcessing("CHART_SIZE=30");
	$clase=ms_newClassObj($layer);
	$clase->set("name","Rio");
	$style=ms_newStyleObj($clase);
	$style->color->setRGB(255,244,237);
	$style->set("size","[rio]");
	$clase=ms_newClassObj($objLayer);
	$clase->set("name","Queman");
	$style=ms_newStyleObj($clase);
	$style->color->setRGB(255,217,191);
	$style->set("size","[queman]");
}



More information about the MapServer-users mailing list