[mapserver-users] Perl or Java - Zoom and Pan
Lowell Filak
lfilak at medinaco.org
Thu Mar 21 06:11:28 PST 2002
It's not elegant but it works.
Lowell F.
package zoom_map;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(zoom_map);
use mapscript;
use CGI qw(:standard *table);
use CGI::Carp qw(fatalsToBrowser set_message);
use main_page;
sub zoom_map {
$|=1;
#
# Declare all variables.
my $ppn = '';
my $mode = 'test';
my $zmdir = 0;
my $zmsize = 5;
my $imgszx = 1;
my $imgszy = 1;
my $minx = 1;
my $miny = 1;
my $maxx = 2;
my $maxy = 2;
my $dx = 1;
my $dy = 1;
my $map = 'mche.map';
my $svquery = 'true';
my $mapext = 'shapes';
my $pickx = 1;
my $picky = 1;
my $imap = '';
my $imapeminx = 0;
my $imapeminy = 0;
my $imapemaxx = 1;
my $imapemaxy = 1;
$imapeminxf = 0;
$imapeminyf = 0;
$imapemaxxf = 1;
$imapemaxyf = 1;
#
# Parse input from calling cgi.
($ppn) = shift;
($mode) = shift;
($zmdir) = shift;
($zmsize) = shift;
($imgszx) = shift;
($imgszy) = shift;
($minx) = shift;
($miny) = shift;
($maxx) = shift;
($maxy) = shift;
($dx) = shift;
($dy) = shift;
($map) = shift;
($svquery) = shift;
($mapext) = shift;
($pickx) = shift;
($picky) = shift;
($imap) = shift;
#
# Check the mapextent.
if (($dx > 100000) & ($zmdir == -1)) {
print "\n<br>Map Extent too Large.";
$zmdir = 0;
return;
}
elsif (($dx < 200) & ($zmdir == 1)) {
$zmdir = 0;
return;
}
if ($zmdir == 0) {
if (($minx < 2083000) | ($miny < 475000) | ($maxx > 2231000) | ($maxy > 595000)) {
print print "\n<br><b>Current Pan Invalid!???";
print "\n<br>Please Press Back and Retry...</b>";
return;
}
}
#
# Is this zoom in, out, or pan.
if ($zmdir == 1) {
my $ndx = ($dx / $zmsize) / 2;
my $ndy = ($dy / $zmsize) / 2;
my $nminx = $pickx - $ndx;
my $nminy = $picky - $ndy;
my $nmaxx = $pickx + $ndx;
my $nmaxy = $picky + $ndy;
&main_page($zmdir,$zmsize,$imgszx,$imgszy,$nminx,$nminy,$nmaxx,$nmaxy,$map,$svquery,$mapext);
}
elsif ($zmdir == -1) {
my $ndx = ($dx * $zmsize) / 2;
my $ndy = ($dy * $zmsize) / 2;
my $nminx = $pickx - $ndx;
my $nminy = $picky - $ndy;
my $nmaxx = $pickx + $ndx;
my $nmaxy = $picky + $ndy;
&main_page($zmdir,$zmsize,$imgszx,$imgszy,$nminx,$nminy,$nmaxx,$nmaxy,$map,$svquery,$mapext);
}
elsif ($zmdir == 0) {
my $ndx = $dx / 2;
my $ndy = $dy / 2;
my $nminx = $pickx - $ndx;
my $nminy = $picky - $ndy;
my $nmaxx = $pickx + $ndx;
my $nmaxy = $picky + $ndy;
&main_page($zmdir,$zmsize,$imgszx,$imgszy,$nminx,$nminy,$nmaxx,$nmaxy,$map,$svquery,$mapext);
}
else {
print "\n<br><b>Current Zoom Mode Unknown!???";
print "\n<br>Please Press Back and Retry...</b>";
}
}
The following message was sent by "Harald Wehr" <hwehr at hs-harz.de> on Thu, 21 Mar 2002 07:18:20 +0100.
> Actually i want to zoom and pan in java. In PHP there is a function
> called "zoompoint" in the mapObj.
>
> As Perl and Java don't have this function it seems to me that i have to
> implement it myself.
>
> Has anyone already done this in perl or java?
>
> Harald
More information about the MapServer-users
mailing list