PDA

View Full Version : Can't get past "rename" on this file


lancer1991
07-07-2005, 05:25 AM
Okay, I'm not programmer savy, but found this perl file about making a large map from Google's Map site. Seem to be having problems at the "mv" section. I'm tyring to run this on Windows XP and it looks as though "mv" is a "unix" command, so I tried rename, but keep getting a permissions error which I can't figure out how to fix for Windows. CHMOD doesn't work in Windows right? Either way I tried to add that in with no luck. Please help (I tried all that I can with days worth of searching with no luck), see below:

#!/usr/bin/perl

# download a bunch of google map tiles and stitch them together
# Shifty Death Effect Done by Noah Vawter in May, 2005.
# Computing Culture Groop, MIT Media Lab.

# with width 12
$sx = 18172;$sy = 26393; # summerville

$w=2;
$h=2;

open(PEDG,">pedg.html");

print PEDG "<html>\n";

for($yd=0;$yd<$h;$yd++)
{
for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem="tile$x$y.gif";

# do we already have it locally?
$val = open(CHECK,$localnem);
if($val == 0){
# 523 wget "http://mt.google.com/mt?v=w2.4&x=18172&y=26393&zoom=1"
$req="http://mt.google.com/";
$nem="mt?v=w2.4&x=$x&y=$y&zoom=1";
$url = $req . $nem;
print "$url\n";
$cmd1="wget \"$url\" ";
print "$cmd1\n";
system($cmd1);
$cmd2="mv \"$nem\" $localnem";
print "$cmd2\n";
system($cmd2);
}

print PEDG "<img src=$localnem>\n";
}
print PEDG "<p>\n";

}

# concatenate horizontal maps
# convert tile005000.gif -page +129+0 tile006000.gif -page +258+0 tile007000.gif -mosaic o.gif

for($yd=0;$yd<$h;$yd++)
{
$cmd3 = "convert ";

for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem = "tile$x,$y.gif";

$xsh = $xd*128;
$ysh = $yd*128;
$cmd3 .= "$localnem ";
}

$cmd3 .= "+append tmp$yd.gif";
print "$cmd3\n";
system($cmd3);
}

# concatenate horizontal strips
$cmd4 = "convert ";

for($yd=0;$yd<$h;$yd++)
{
$localnem = "tmp$yd.gif";
$cmd4 .= "$localnem ";
}

$cmd4 .= "-append output.gif";
print "$cmd4\n";
system($cmd4);

Kickin
07-08-2005, 03:38 AM
I would think 'rename' would work on a window's box. You should start with changing the shebang line to where ever perl is on your machine.

lancer1991
07-08-2005, 04:08 AM
I don't have problems getting perl to run. It actually goes through the wget, but if I don't put the "die" in it pulls all the files, but they are named "mt@v=w2.4&x=18171&y=26392&zoom=1" as an example and won't rename to the tile$x$y.gif.

Thanks for the response though.

lancer1991
07-08-2005, 04:52 AM
Okay, I figured it out. For some reason It wouldn't take with the () on the rename command. Here's the final output:

#!/perl/bin -w

# download a bunch of google map tiles and stitch them together
# Shifty Death Effect Done by Noah Vawter in May, 2005.
# Computing Culture Groop, MIT Media Lab.

# with width 2
$sx = 18172;$sy = 26393; # summerville

$w=2;
$h=2;

open(PEDG,">pedg.html");

print PEDG "<html>\n";

for($yd=0;$yd<$h;$yd++)
{
for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem="tile$x$y.gif";

# do we already have it locally?
$val = open(CHECK,$localnem);
if($val == 0){
# 523 wget "http://mt.google.com/mt?v=w2.4&x=18172&y=26393&zoom=1"
$req="http://mt.google.com/";
$nem="mt?v=w2.4&x=$x&y=$y&zoom=1";
$url = $req . $nem;
print "$url\n";
$cmd1="wget \"$url\" ";
print "$cmd1\n";
system($cmd1);
$cmd2="rename \"$nem\", $localnem";
print "$cmd2\n";
system($cmd2);
}

print PEDG "<img src=$localnem>\n";
}
print PEDG "<p>\n";

}

# concatenate horizontal maps
# convert tile005000.gif -page +129+0 tile006000.gif -page +258+0

tile007000.gif -mosaic o.gif

for($yd=0;$yd<$h;$yd++)
{
$cmd3 = "convert ";

for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem = "tile$x$y.gif";

$xsh = $xd*128;
$ysh = $yd*128;
$cmd3 .= "$localnem ";
}

$cmd3 .= "+append tmp$yd.gif";
print "$cmd3\n";
system($cmd3);
}

# concatenate horizontal strips
$cmd4 = "convert ";

for($yd=0;$yd<$h;$yd++)
{
$localnem = "tmp$yd.gif";
$cmd4 .= "$localnem ";
}

$cmd4 .= "-append output.gif";
print "$cmd4\n";
system($cmd4);