[Mapserver-users] altering $layer->{symbolscale} before draw()
Sean Gillies
sgillies at frii.com
Fri Feb 27 09:23:10 PST 2004
Hi Nikolai,
Do you have an error in your code? I'm going to insert a line into
your code below.
On Feb 27, 2004, at 8:05 AM, Nikolai Vladychevski wrote:
> Hi,
> I have a perl script that uses mapscript to create a map with many
> layers. I want to dynamicaly alter SYMBOLSCALE of the layer depending
> on the scale of the map, because when user zooms too much, the symbol
> is too big. I can not lower SYMBOLSCALE and leave it fixed in mapfile
> becasue when user is browsing at high scales, the symbols is very
> small, almost invisible.
> So I have this code, but it isn't giving expected results, nothing
> happends:
> sub drawLayers {
> my $m=shift; #map
> my $i=shift; #image
> for ($lidx=0;$lidx<$m->{numlayers};$lidx++) {
> $l=$m->getLayer($lidx);
> if ($m->{scale}<32000 && ($l->{name} eq "emplazamientos")) {
> $l->{symbolscale}=320; #<- this doesn't make any difference
Try symbolscale = -1 to turn off scaling when you are zoomed in?
> }
> $l->draw($m,$i);
> }
> here are some lines in mapfile:
> LAYER
> NAME emplazamientos
> DATA emplazamientos.shp
> CLASSITEM 'ID'
> LABELITEM 'ID'
> SYMBOLSCALE 32000
> CLASS
> NAME 'emplazamientosactivos'
> COLOR 0 0 255
> SYMBOL 'emplazamiento'
> SIZE 10
> TEMPLATE "emplazamiento.html"
> END
> .....
> SYMBOL
> NAME "emplazamiento"
> TYPE TRUETYPE
> FONT transmision
> FILLED true
> ANTIALIAS true
> CHARACTER "F"
> END
> .......
> How do I have to change the {symbolscale} variable in order to achieve
> changes in the display, as I do it above, setting it to different
> values doesn't make any difference
> Thanks in advance
> Nikolai
The dynamic scaling in mapserver is a bit limited because what we
*really* need in
many cases is not linear scaling, but *log* scaling of feature line
widths.
If a feature has size0 = 10 at scale0 = 32000 (your case), it would be
nice to
have the feature size scale like
size = size0*log(scale0)/(log(scale)
So that symbol sizes would scale gently. This might not be hard to
implement
at all, requiring only a SYMBOLLOGSCALE property and a bit of new code
in
mapserver.
cheers,
Sean
More information about the MapServer-users
mailing list