[Mapserver-users] Classes and Layers

Benjamin Wragg bwragg at tpg.com.au
Fri Jan 24 02:05:17 EST 2003


Hi Guys,

I'm trying to add a class to a PostGIS layer that is already defined in
a mapfile. What I'm trying to do is pass the gid of a feature from a
user and create a class only showing the feature selected. The code is
shown below:

	$featureID=X //passed in from user
      $layer=$map->getlayerbyname('testpoints');		
  	
      $class=ms_newClassObj($layer);
	$class->set("name", "Selected Feature");
	$class->setexpression('gid=$featureID');

	$colorId=$map->addColor(255,0,0);
	$class->set("color", $colorId);
	$class->set("size", 10);
	$layer->set("status", MS_ON);
	$image=$map->draw();
      $imageURL$image->saveWebImage(MS_PNG,1,1,0);

The layer in the map file is as follows:

	LAYER
	  CONNECTIONTYPE postgis
	  NAME "testpoints"
	  CONNECTION "user=user password=password dbname=dbname
host=localhost"
	  DATA "the_geom from testpoints"
	  STATUS ON
	  TYPE POINT
	  
	  CLASS
		  NAME "All Features"
		  COLOR 0 0 0
		  SIZE 10
		  SYMBOL 2
	  END	
	END

The map produced is no different. Any ideas?

Thanks,

Benjamin Wragg




More information about the mapserver-users mailing list