[mapserver-users] CGI script - MAP NOT CHANGING SCALE

Marie Flanagan theflan at gofree.indigo.ie
Thu May 23 02:43:57 PDT 2002


Hi Lowell,

I got the problem sorted out.  What I discovered is that if you change the
extent, you must use $map->prepareImage() prior to drawing.  This seems to
set variables like 'scale' based on the extent.

Thanks for your help.

Regards

Marie

----- Original Message -----
From: Lowell Filak <lfilak at medinaco.org>
To: Marie Flanagan <theflan at gofree.indigo.ie>
Sent: Wednesday, May 22, 2002 2:03 PM
Subject: Re: [mapserver-users] CGI script - MAP NOT CHANGING SCALE


> After taking a quick look I'm wondering:
> Is $image_extent[1] your maxy?
> Also isn't the (!CGI::param('imgext')) test ALWAYS false?
> Lowell
>
> The following message was sent by "Marie Flanagan"
<theflan at gofree.indigo.ie> on Mon, 20 May 2002 19:08:13 +0100.
>
> > Hi Lowell,
> >
> > Here's the set_extent routine .... and thanks for having a look.
> >
> > Marie
> >
> > sub set_extent
> > {
> >    my ($zoomdir, $zoomsize, $x, $y, @image_extent) = @_;
> >    my $zoom;
> >    my $map_width = $image_extent[2] - $image_extent[0];
> >    my $map_height = abs($image_extent[1]) - abs($image_extent[3]);
> >    if (!CGI::param('imgext'))
> >    {
> >       if ($map_width > $map_height) { $map_height = $map_width; }
> >       else { $map_width = $map_height; }
> >    }
> >    my $cell_width = $map_width/$map->{width};
> >    my $cell_height = $map_height/$map->{height};
> >    $x = $image_extent[0] + $cell_width*$x;
> >    $y = $image_extent[3] - $cell_height*$y;
> >    print DBG "dir $zoomdir, zoom size $zoomsize, \n";
> >    if ($zoomdir == 0) {$zoom = 1; }
> >    else
> >    {
> >       $zoom = ($zoomdir*$zoomsize);
> >       $zoom = 1.0/abs($zoom) if $zoom < 0;
> >    }
> >    $map->{extent}->{minx} = $x - .5*(($map_width)/$zoom);
> >    $map->{extent}->{miny} = $y - .5*(($map_height)/$zoom);
> >    $map->{extent}->{maxx} = $x + .5*(($map_width)/$zoom);
> >    $map->{extent}->{maxy} = $y + .5*(($map_height)/$zoom);
> >    return;
> > }
> >
> > ----- Original Message -----
> > From: Lowell Filak <lfilak at medinaco.org>
> > To: Marie Flanagan <theflan at gofree.indigo.ie>;
> > <mapserver-users at lists.gis.umn.edu>
> > Sent: Monday, May 20, 2002 2:38 PM
> > Subject: Re: [mapserver-users] CGI script - MAP NOT CHANGING SCALE
> >
> >
> > > Can you forward the set_extent subroutine?
> > > Lowel F.
> > >
> > > The following message was sent by "Marie Flanagan"
> > <theflan at gofree.indigo.ie> on Sat, 18 May 2002 11:02:35 +0100.
> > >
> > > > Hi list,
> > > >
> > > > I have a problem with a CGI script - with zooming in/out.
> > > > My set_extent subroutine seems to work in that the map extent is >
> > changed, but when the map is drawn it presents as a little map in the >
top
> > left hand corner if I am zooming in - it's like the exent is working >
but
> > the scale of the map is not changing.  What am I missing?
> > > >
> > > > 2 of my layers are being created on the fly from a flat file.  One
of >
> > the 'dynamic' layers is a shape and is added as a feature to the layer,
>
> > the other is a set of points and labels.
> > > >
> > > > Help gratetfully received - as I am driven demented with this
problem!
> > > >
> > > > Regards,
> > > >
> > > > Marie
> > > >
> > > >
> > > > Extract from the code:
> > > >
> > > > &set_extent($zoomdir, $zoomsize, $imgx, $imgy, @image_extent);
> > > >
> > > > $shape_layer->addFeature($shape);
> > > > $shape_layer->close();
> > > >
> > > > # Now draw all the map layers.  Point layer with labels will be
drawn >
> > separately after this
> > > > for my $i (0 ..($map->{numlayers}-1))
> > > >
> >
> > > >    my $layer = $map->getLayer($i);
> > > >    $success = $layer->draw($map, $image);
> > > >    print DBG "Drew layer $layer->{name} --------- $i ------
$success\n";
> > >
> > > > }
> > > >
> > > > $num_stops = @stops_list -1;
> > > > for my $i (0 .. $num_stops)
> > > > {
> > > >    $display_count = $i + 1;
> > > >    my ($x, $y, $desc) = split(/\t/, $stops_list[$i]);
> > > >    if ($i==0) { $desc="[ $display_count ] START," . $desc; }
> > > >    if ($i== ($num_stops)) { $desc = "[ $display_count ] FINISH," . >
> > $desc; }
> > > >    if ($i > 0 && $i < ($num_stops)) { $desc =
"[ $display_count ]"; }
> > > >    print DBG "$stops_list[$i] ... $i ... $desc \n";
> > > >    $draw_pt1=new pointObj();
> > > >    $draw_pt1->{x} = $x;
> > > >    $draw_pt1->{y} = $y;
> > > >    $draw_pt1->draw($map, $pt_label, $image, undef, "$desc");
> > > >    $draw_pt2=new pointObj();
> > > >    $draw_pt2->{x} = $x;
> > > >    $draw_pt2->{y} = $y;
> > > >    $draw_pt2->draw($map, $pt_layer, $image, undef, undef);
> > > >    $i++;
> > > > }
> > > >
> > >
> > >
>
>




More information about the MapServer-users mailing list