[mapserver-users] Changing the color of a point with Mapscript

Steven Hayes shayes at bigpond.net.au
Mon Apr 1 23:18:43 PST 2002


Hi All,

I use mapscript to dynamically create a point layer with the results of a
query to a MySQL table. Once a hash table is populated from a MySQL query
the following subroutine runs:


################################################################
sub make_unlabled_points {
    my ($layer_name) = @_;

    $layer = $map->getLayerByName($layer_name);

	    my $i = 1; # site counter
	    foreach my $s (@sample_sites) {
	        $point->{x} = $s->{lon};
	        $point->{y} = $s->{lat};
	        $point->draw($map, $layer, $img, undef, undef);
	        $i++;
	    }
}
###############################################################

Given a reference to an existing layer definition in the map file a nice
field of points is rendered.

The following is an example of one of the layers commonly used:

##############################################################
LAYER
	NAME sw_sites_no_lab
	TYPE point
	STATUS DEFAULT
	DATA locations

	CLASS
		SYMBOL 3
		SIZE 3
		NAME "sample sites"
		COLOR 254 0 0
	END
END
##############################################################

The reference to the DATA being in the locations shape file is irrelevant as
the layer definition simply provides symbology. And here is my problem...I
can now do more complex queries of my underlying data and would like to
render points in varying colours reflecting value ranges. How can I do this
with mapscript? The truly dumb and stupid way would be to define various
layers with different symbology but that limits me severely and gives no
real scope for user interaction like refining the colour ramp based on the
range of values in the returned data.

Regards

Steven Hayes




More information about the MapServer-users mailing list