ok - got zoom to work - another question

Eric Bridger eric at GOMOOS.ORG
Wed Nov 24 08:50:06 EST 2004


On Tue, 2004-11-23 at 17:15, Joseph Norris wrote:
> Thanks Eric - so as I understand you:
>
> MAP
>   NAME CalMap
>   STATUS ON
>   EXTENT 5890870.385 -192053.200 8943310.847 3226086.749
>   IMAGETYPE GIF
>   SIZE 600 600
>   SHAPEPATH
> "/usr/local/apache/htdocs/mco.communityservers.com/htdocs/maps/teacher/tdata
> "
>   IMAGECOLOR 255 255 255
>   TEMPLATEPATTERN "map"
>
>   SYMBOL
>     NAME 'circle'
>     TYPE ELLIPSE
>     POINTS 1 1 END
>     FILLED TRUE
>   END
>
>
>   LAYER
>     NAME "cal_zp_st"
>     TYPE POLYGON
>     DATA "cal_zp_st"
>     STATUS DEFAULT
>     CLASSITEM "ZCTA"
>
>     CLASS
>         EXPRESSION
> /94087|90408|94107|95118|94530|74580|95404|93711|94904|92030|94121|91042|961
> 01|94523|95548|95658|92057|92503/
>       STYLE
>         SYMBOL 'circle'
>         SIZE 2
>         COLOR 255 102 102
>       END
>
>     END
>
>     CLASS
>       EXPRESSION /./
>       OUTLINECOLOR 204 204 204
>     END
>   END
>   LAYER
>     NAME "poly_minscale"
>     TYPE POLYGON
>     DATA "cal_zp_st"
>     STATUS DEFAULT
>     MINSCALE ????
>     CLASS
>      SYMBOL 'circle'
>       SIZE 2
>       COLOR 255 102 102
>      END
>   END
>      LAYER
>     NAME "poly_maxscale"
>     TYPE POLYGON
>     DATA "cal_zp_st"
>     STATUS DEFAULT
>     MAXSCALE????
>  I don't know what the class would be if any
>   END
>
>
> END # end map from header
>
> How do I determine the minscale and maxscale?
>
> Thanks
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,-1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of Eric Bridger
> Sent: Monday, November 22, 2004 9:53 AM
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] ok - got zoom to work - another question
>
> At 08:39 AM 11/22/2004 -0800, Joseph Norris wrote:
> >Everyone,
> >
> >I have my zoom working but now I would like to tackle something else.  I am
> >putting an ellipse in the zip polygons if there is a 1-more teachers there.
> >For each zip there maybe a max of 10 teachers.  I would like an ellipse or
> >symbol for each one so that when the user zooms into the polygon they can
> >see a symbol for each teacher. Can I do this within the class?  If so how
> or
> >would be the best way to handle this?
>
>
> You can do this in the map file by creating two layers and using MAXSCALE,
> MINSCALE.
> Layer 1 has one ellipse per zip wherever there are 1-10 teachers.
> MINSCALE is set so that it won't appear when you are zoomed in.
> Layer 2 has one ellipse for each teacher and has MAXSCALE set so that it
> turns on when Layer 1 is turned off.
>
> Of course if you are using Perl Mapscript you will need to calculate the
> scale yourself and turn on and off the layers yourself.
> Here's and example:
>
> my $current_scale = calculateScale($map, $imgext[0], $imgext[2]);
> # From mapserver3.6.4: mapscale.c msCalculateScale().  This is not a
> precision thing. We don't worry about
> # msAdjustExtent() since in all our maps, image SIZE has same aspect ratio
> as the map EXTENT.
> # $minx and $maxx are optional in which case the current extent of the map
> is used.
>
> # Be careful about the current map's extent. zoomMap() changes the extents.
>
> sub calculateScale{
>     my ($map, $minx, $maxx) = @_;
>     if(!$minx){
>         $minx = $map->{extent}->{minx};
>         $maxx = $map->{extent}->{maxx};
>     }
>     my @inchesPerUnit = (1, 12, 63360.0, 39.3701, 39370.1, 4374754);
>     my $width = $map->{width};
>     my $units = $map->{units}; # index into unitsPerUnit array
>     my $resolution = $map->{resolution};
>     my $md = $width / ($resolution * $inchesPerUnit[$units]);
>     my $gd = $maxx - $minx;
>     return($gd/$md);
> }

Joseph,
I'm not exactly sure what your data looks like or what you are trying to
achieve. But by using two layers you can control what exactly is
displayed via different CLASS and EXPRESSION's at different scales.

The scale is determined by the current map's extents, (AFTER any zooming
in which you calculated new extents based on the zoom direction.

(Actually this call:
my $current_scale = calculateScale($map, $imgext[0], $imgext[2]);
gets the scale of the map which was just submitted, based on:
  @imgext = split(' ', $q->param('imgext')); where imgext is the extent
just submitted with the form.)

Typically you'd want to call $scale = calculateScale($map) (after your
zoom calculations have changed the map's extents.

What MIXSCALE, MAXSCALE to use in your map file must be determined by
trail and error.

HTH.
Eric



More information about the mapserver-users mailing list