Menu

mapfetch.pl

Maps
2004-06-05
2004-08-22
  • Nobody/Anonymous

    Hello!

    I've been tinkering around with qpeGPS on my 5600 for a few weeks now and I have got to say that it works great! However, I was disappointed in how getmaps (http://z-soft.z-portal.info/getmaps/) does not retrieve maps according to what the qpeGPS people suggested in their documentation: that "If Your maps are overlapping by 240 pixel vertically and 320 pixel horizontally (screen size), You will never see the end of a map, because qpeGPS then will always select the map which fills the screen." While using map set made with getmaps, I widely experienced seeing the edges of the maps and also finding myself in gaps where there were no maps, even though I had a couple of differently scaled map sets.

    So I wrote this script, mapfetch.pl, and so far has been working great for me, and I thought I'd share it with you all. I'm willing to offer any support I can if you: 1. Please read the documentation in the comments and 2. Please send all correspondance either via this thread or to mapfetch@hardcode.cotse.net. Enjoy!

    (I just hope that it pastes in here all right without reformatting too much!)

    #!/usr/bin/perl

    #----------------------------------------------------------------------------
    # Name: mapfetch.pl
    # Version: 0.1
    # Date: 2004/06/04
    # Purpose: Recursively retrieves maps from maptuit.com for any area at any
    #   scale, and ensures that they overlap (for use by qpeGPS, or other GPS
    #   program?)
    # Questions/Comments: mapfetch@hardcode.cotse.net
    # Author: Nick Jensen
    # Copyright (C) 2004  Nick Jensen
    #----------------------------------------------------------------------------
    # Supplementary Documentation:
    #
    #   Description of Arguments:
    #
    #     This should be about 90% familiar to getmaps users.
    #
    #     <map name>        Describes this set of maps
    #     <left>            Left-most center longitude (West)
    #     <right>           Right-most center longitude (East)
    #     <top>             Top-most center latitude (North)
    #     <bottom>          Bottom-most center latitude (South)
    #     <scale>           Desired scale. Scales that I use are:
    #                         Neighborhood=25000-40000
    #                         Area=75000
    #                         Region=500000
    #     [<overlap>]       Amount (in pixels) desired for overlap. Format:
    #                       "<horizontal>x<vertical>". This argument is optional.
    #                       Default="245x325" (Zaurus 5x000 screen size plus 5
    #                       pixels).
    #
    #   How it works:
    #
    #     Assuming that the user enters a good set of arguments, mapfetch.pl
    #     starts off by estimating for the entered scale how much distance
    #     needs to be between each map's center in order to get the desired
    #     overlap. Please understand that this algorithm is extremely
    #     experimental. All I know is that is works decently well for the
    #     scenarios that I'm giving it. Based on those distances, it counts up
    #     the total number of maps it's going to have to fetch to cover the
    #     desired area at that scale. It then proceeds in much the same way as
    #     getmaps did: calling for wget to get the maps and gif2png to convert
    #     them.
    #
    #   Files Produced:
    #
    #     mapfetch.pl produces two types of files:
    #
    #       1. maps.txt - This file is a text file that stores information about
    #                     each map in the format required by qpeGPS. Yes, it
    #                     properly enters the correct pixel sizes: "1036 780".
    #                     Really, the name of this file is dependent on the
    #                     arguments entered, but ends up in this format:
    #                     "<map name>_<scale>_maps.txt".
    #       2. *.png    - These are the individual maps in regular png (Portable
    #                     Network Graphics) format that together form a set of
    #                     maps that cover the desired area. Their filenames are
    #                     also dependent on the arguments but end up in this
    #                     format: "<map name>_<scale>_<index #>_<center
    #                     latitude>_<center longitude>.txt".
    #
    #   Hint for qpeGPS users:
    #
    #     In order for qpeGPS to "know" about the maps you've installed, you
    #     should run this in the qpeGPS maps folder for each set of maps:
    #
    #       cat <map name>_<scale>_maps.txt >>maps.txt
    #
    #   Testing:
    #
    #     So far I've tested this script and have gotten it to work on a Windows
    #     XP box + ActivePerl 5.8 + wget.exe + gif2png.exe, a Debian Sarge
    #     (Testing) GNU/Linux box + Perl 5.8.3 and on my Sharp Zaurus SL-5600
    #     running theKompanyROM + Perl 5.6.1 + qpeGPS 0.9.1. So, I hope it
    #     works on whatever you all are using.
    #
    #     Experimental Algorithm: The algorithm works just fine at "normal"
    #     scales around 25000 - 75000, but I have found that at a scale of
    #     500000 the overlap could be off by one pixel, erring on the side of
    #     caution (one pixel too many). To me, this is acceptable. For others,
    #     maybe not (?), it depends on the application.
    #
    #   Useful Links:
    #
    #   qpeGPS: http://qpegps.sourceforge.net/
    #   Sourceforge Maps Forum: http://sourceforge.net/forum/forum.php?forum_id=206322
    #   getmaps: http://z-soft.z-portal.info/getmaps/
    #   MapQuest (Lat/Lon): http://www.mapquest.com/maps/latlong.adp
    #   ActivePerl: http://activestate.com/Products/Download/Download.plex?id=ActivePerl
    #   wget: http://www.gnu.org/software/wget/wget.html
    #   gif2png: http://www.catb.org/~esr/gif2png/
    #----------------------------------------------------------------------------

    # USAGE SECTION
    my $usage =<<"END-OF-USAGE";
    mapfetch.pl v 0.1 (2004/06/04)

    Usage: mapfetch.pl <map name> <left>
    <right> <top> <bottom> <scale> [<overlap>]
          
         <top> - +-----------------+
                 |                 |
                 |                 |
                 |                 |
                 |                 |
                 |                 |
      <bottom> - +-----------------+
                  \\&nbsp;                \\                <left>            <right>
                     
    Example: mapfetch.pl bw -77.3 -76.3 39.55
      38.625 25000

    For more info, please view source.
    END-OF-USAGE

    # ERROR CHECKING
    if ($#ARGV < 5 || $#ARGV > 6) { die $usage; }

    # GET ARGUMENTS
    my ($name, $left, $right, $top, $bottom, $scale, $overlap) = @ARGV;

    # PROCESS OVERLAP ARG
    my $over_x, $over_y;
    if ($overlap) {
      ($over_x, $over_y) = split(/x/, $overlap);
    } else {
      # DEFAULT OVERLAP FOR ZAURUS 5x00 SCREEN SIZE: 240x320
      ($over_x, $over_y) = (245, 325);
    }

    # MORE ERROR CHECKING
    if ($top <= $bottom) {
      die "<top> latitude must be greater than\n<bottom> latitude.\n";
    }
    if ($right <= $left) {
      die "<right> longitude must be greater than\n<left> latitude.\n";
    }
    unless ($over_x < 518 && $over_x >= 0 && $over_y < 396 && $over_y >= 0) {
      die "Invalid overlap. Valid range: 0x0-517x395.\n\n" .
          "Note: Negative overlaps results in gaps.\n" .
          "Overlaps greater than half of the image\n" .
          "produces too many maps.\n";
    }
    unless ($scale >=2) {
      die "Invalid scale. Valid range: 2 or greater.\n";
    }

    # FIND THE DISTANCES BETWEEN MAP CENTERS ***EXPERIMENTAL***
    my $h_overlap = -(1/240000000) * $over_x + .00000323 + (257/240000000);
    my $h_off = $scale * $h_overlap;
    my $v_overlap = -(5/1600000000) * $over_y + .00000144 + (341/320000000);
    my $v_off = $scale * $v_overlap;

    # CONVERT SCALE TO MAPTUIT SCALE
    $maptuit_scale = sprintf "%.13f", $scale / 2815;

    # COUNT TOTAL NUMBER OF MAPS TO GET
    my ($total, $tot_x, $tot_y) = (0, 0, 0);
    for ($y = $top; $y > $bottom; $y -= $v_off) {
      $tot_y++;
    }
    for ($x = $left; $x < $right; $x += $h_off) {
      $tot_x++;
    }
    $total = $tot_x * $tot_y;
    print "$total total maps to download in a $tot_x x $tot_y grid...\n\n";

    # OPEN THE <MAP NAME>_<SCALE>_MAPS.TXT FILE
    my $mapsdottext = $name . "_" . (sprintf "%.0f", $scale) . "_maps.txt";
    open OUT, ">$mapsdottext" || die "Couldn't open $mapsdottext for writing!\n";

    # GET THE MAPS ALREADY
    my $count = 0;
    for ($y = $top; $y > $bottom; $y -= $v_off) {
      for ($x = $left; $x < $right; $x += $h_off) {
        printf "FETCHING MAP %d OF %d - LATITUDE: %2.6f, LONGITUDE: %2.6f\n\n", ++$count, $total, $y, $x;
        my $format = "%s_%.0f_%05s_%2.6f_%2.6f";
        my $fn = sprintf $format, $name, $scale, $count, $y, $x;
        printf OUT "FRITZ %s.png %.0f 1036 780 %2.6f %2.6f\n", $fn, $scale, $y, $x;
        my $url = "http://www.maptuit.com/htmlclient/map.cgi?";
        $url .= sprintf "%2.6f,%2.6f,1024,768,0,%.13f,1,Unique,0,Maps+m", $x, $y, $maptuit_scale;
        my $wget = "wget -O $fn.gif $url";
        my $gif2png;
        if ($^O eq "MSWin32") {
          # Windows version of gif2png didn't support -O
          $gif2png = "gif2png -d -p $fn";
        } else {
          $gif2png = "gif2png -d -p -O $fn";
        }
        print "EXECUTING: $wget\n";
        system($wget);
        print "EXECUTING: $gif2png\n";
        system($gif2png);
        print "\n\n";
      }
    }

    close OUT || die "Couldn't close $mapsdottext!\n";
    print "mapfetch.pl completed successfully.\n";

    exit 0;

     
    • Nobody/Anonymous

      I realize that the post screwed up the extra spaces I have in the original script. When possible, I'll provide a URL to mapfetch.pl so you can get it without the posting issues.

       
      • Nobody/Anonymous

        thank you!

        the second perl sript work great!

        downloading with the example right now.

        very grateful,
        Ken

         
    • Nobody/Anonymous

      Okay, we'll try this again... with <pre> tags:

      <pre>
      #!/usr/bin/perl

      #----------------------------------------------------------------------------
      # Name: mapfetch.pl
      # Version: 0.1
      # Date: 2004/06/04
      # Purpose: Recursively retrieves maps from maptuit.com for any area at any
      #   scale, and ensures that they overlap (for use by qpeGPS, or other GPS
      #   program?)
      # Questions/Comments: mapfetch@hardcode.cotse.net
      # Author: Nick Jensen
      # Copyright (C) 2004  Nick Jensen
      #----------------------------------------------------------------------------
      # Supplementary Documentation:
      #
      #   Description of Arguments:
      #
      #     This should be about 90% familiar to getmaps users.
      #
      #     <map name>        Describes this set of maps
      #     <left>            Left-most center longitude (West)
      #     <right>           Right-most center longitude (East)
      #     <top>             Top-most center latitude (North)
      #     <bottom>          Bottom-most center latitude (South)
      #     <scale>           Desired scale. Scales that I use are:
      #                         Neighborhood=25000-40000
      #                         Area=75000
      #                         Region=500000
      #     [<overlap>]       Amount (in pixels) desired for overlap. Format:
      #                       "<horizontal>x<vertical>". This argument is optional.
      #                       Default="245x325" (Zaurus 5x000 screen size plus 5
      #                       pixels).
      #
      #   How it works:
      #
      #     Assuming that the user enters a good set of arguments, mapfetch.pl
      #     starts off by estimating for the entered scale how much distance
      #     needs to be between each map's center in order to get the desired
      #     overlap. Please understand that this algorithm is extremely
      #     experimental. All I know is that is works decently well for the
      #     scenarios that I'm giving it. Based on those distances, it counts up
      #     the total number of maps it's going to have to fetch to cover the
      #     desired area at that scale. It then proceeds in much the same way as
      #     getmaps did: calling for wget to get the maps and gif2png to convert
      #     them.
      #
      #   Files Produced:
      #
      #     mapfetch.pl produces two types of files:
      #
      #       1. maps.txt - This file is a text file that stores information about
      #                     each map in the format required by qpeGPS. Yes, it
      #                     properly enters the correct pixel sizes: "1036 780".
      #                     Really, the name of this file is dependent on the
      #                     arguments entered, but ends up in this format:
      #                     "<map name>_<scale>_maps.txt".
      #       2. *.png    - These are the individual maps in regular png (Portable
      #                     Network Graphics) format that together form a set of
      #                     maps that cover the desired area. Their filenames are
      #                     also dependent on the arguments but end up in this
      #                     format: "<map name>_<scale>_<index #>_<center
      #                     latitude>_<center longitude>.txt".
      #
      #   Hint for qpeGPS users:
      #
      #     In order for qpeGPS to "know" about the maps you've installed, you
      #     should run this in the qpeGPS maps folder for each set of maps:
      #
      #       cat <map name>_<scale>_maps.txt >>maps.txt
      #
      #   Testing:
      #
      #     So far I've tested this script and have gotten it to work on a Windows
      #     XP box + ActivePerl 5.8 + wget.exe + gif2png.exe, a Debian Sarge
      #     (Testing) GNU/Linux box + Perl 5.8.3 and on my Sharp Zaurus SL-5600
      #     running theKompanyROM + Perl 5.6.1 + qpeGPS 0.9.1. So, I hope it
      #     works on whatever you all are using.
      #
      #     Experimental Algorithm: The algorithm works just fine at "normal"
      #     scales around 25000 - 75000, but I have found that at a scale of
      #     500000 the overlap could be off by one pixel, erring on the side of
      #     caution (one pixel too many). To me, this is acceptable. For others,
      #     maybe not (?), it depends on the application.
      #
      #   Useful Links:
      #
      #   qpeGPS: http://qpegps.sourceforge.net/
      #   Sourceforge Maps Forum: http://sourceforge.net/forum/forum.php?forum_id=206322
      #   getmaps: http://z-soft.z-portal.info/getmaps/
      #   MapQuest (Lat/Lon): http://www.mapquest.com/maps/latlong.adp
      #   ActivePerl: http://activestate.com/Products/Download/Download.plex?id=ActivePerl
      #   wget: http://www.gnu.org/software/wget/wget.html
      #   gif2png: http://www.catb.org/~esr/gif2png/
      #----------------------------------------------------------------------------

      # USAGE SECTION
      my $usage =<<"END-OF-USAGE";
      mapfetch.pl v 0.1 (2004/06/04)

      Usage: mapfetch.pl <map name> <left>
      <right> <top> <bottom> <scale> [<overlap>]
            
           <top> - +-----------------+
                   |                 |
                   |                 |
                   |                 |
                   |                 |
                   |                 |
        <bottom> - +-----------------+
                    \\&nbsp;                \\                <left>            <right>
                       
      Example: mapfetch.pl bw -77.3 -76.3 39.55
        38.625 25000

      For more info, please view source.
      END-OF-USAGE

      # ERROR CHECKING
      if ($#ARGV < 5 || $#ARGV > 6) { die $usage; }

      # GET ARGUMENTS
      my ($name, $left, $right, $top, $bottom, $scale, $overlap) = @ARGV;

      # PROCESS OVERLAP ARG
      my $over_x, $over_y;
      if ($overlap) {
        ($over_x, $over_y) = split(/x/, $overlap);
      } else {
        # DEFAULT OVERLAP FOR ZAURUS 5x00 SCREEN SIZE: 240x320
        ($over_x, $over_y) = (245, 325);
      }

      # MORE ERROR CHECKING
      if ($top <= $bottom) {
        die "<top> latitude must be greater than\n<bottom> latitude.\n";
      }
      if ($right <= $left) {
        die "<right> longitude must be greater than\n<left> latitude.\n";
      }
      unless ($over_x < 518 && $over_x >= 0 && $over_y < 396 && $over_y >= 0) {
        die "Invalid overlap. Valid range: 0x0-517x395.\n\n" .
            "Note: Negative overlaps results in gaps.\n" .
            "Overlaps greater than half of the image\n" .
            "produces too many maps.\n";
      }
      unless ($scale >=2) {
        die "Invalid scale. Valid range: 2 or greater.\n";
      }

      # FIND THE DISTANCES BETWEEN MAP CENTERS ***EXPERIMENTAL***
      my $h_overlap = -(1/240000000) * $over_x + .00000323 + (257/240000000);
      my $h_off = $scale * $h_overlap;
      my $v_overlap = -(5/1600000000) * $over_y + .00000144 + (341/320000000);
      my $v_off = $scale * $v_overlap;

      # CONVERT SCALE TO MAPTUIT SCALE
      $maptuit_scale = sprintf "%.13f", $scale / 2815;

      # COUNT TOTAL NUMBER OF MAPS TO GET
      my ($total, $tot_x, $tot_y) = (0, 0, 0);
      for ($y = $top; $y > $bottom; $y -= $v_off) {
        $tot_y++;
      }
      for ($x = $left; $x < $right; $x += $h_off) {
        $tot_x++;
      }
      $total = $tot_x * $tot_y;
      print "$total total maps to download in a $tot_x x $tot_y grid...\n\n";

      # OPEN THE <MAP NAME>_<SCALE>_MAPS.TXT FILE
      my $mapsdottext = $name . "_" . (sprintf "%.0f", $scale) . "_maps.txt";
      open OUT, ">$mapsdottext" || die "Couldn't open $mapsdottext for writing!\n";

      # GET THE MAPS ALREADY
      my $count = 0;
      for ($y = $top; $y > $bottom; $y -= $v_off) {
        for ($x = $left; $x < $right; $x += $h_off) {
          printf "FETCHING MAP %d OF %d - LATITUDE: %2.6f, LONGITUDE: %2.6f\n\n", ++$count, $total, $y, $x;
          my $format = "%s_%.0f_%05s_%2.6f_%2.6f";
          my $fn = sprintf $format, $name, $scale, $count, $y, $x;
          printf OUT "FRITZ %s.png %.0f 1036 780 %2.6f %2.6f\n", $fn, $scale, $y, $x;
          my $url = "http://www.maptuit.com/htmlclient/map.cgi?";
          $url .= sprintf "%2.6f,%2.6f,1024,768,0,%.13f,1,Unique,0,Maps+m", $x, $y, $maptuit_scale;
          my $wget = "wget -O $fn.gif $url";
          my $gif2png;
          if ($^O eq "MSWin32") {
            # Windows version of gif2png didn't support -O
            $gif2png = "gif2png -d -p $fn";
          } else {
            $gif2png = "gif2png -d -p -O $fn";
          }
          print "EXECUTING: $wget\n";
          system($wget);
          print "EXECUTING: $gif2png\n";
          system($gif2png);
          print "\n\n";
        }
      }

      close OUT || die "Couldn't close $mapsdottext!\n";
      print "mapfetch.pl completed successfully.\n";

      exit 0;

      </pre>

       
      • Nobody/Anonymous

        <pre> tags don't preserve spaces... here goes with &nbsp;'s...

        #!/usr/bin/perl

        #----------------------------------------------------------------------------
        #&nbsp;Name:&nbsp;mapfetch.pl
        #&nbsp;Version:&nbsp;0.1
        #&nbsp;Date:&nbsp;2004/06/04
        #&nbsp;Purpose:&nbsp;Recursively&nbsp;retrieves&nbsp;maps&nbsp;from&nbsp;maptuit.com&nbsp;for&nbsp;any&nbsp;area&nbsp;at&nbsp;any
        #&nbsp;&nbsp;&nbsp;scale,&nbsp;and&nbsp;ensures&nbsp;that&nbsp;they&nbsp;overlap&nbsp;(for&nbsp;use&nbsp;by&nbsp;qpeGPS,&nbsp;or&nbsp;other&nbsp;GPS
        #&nbsp;&nbsp;&nbsp;program?)
        #&nbsp;Questions/Comments:&nbsp;mapfetch@hardcode.cotse.net
        #&nbsp;Author:&nbsp;Nick&nbsp;Jensen
        #&nbsp;Copyright&nbsp;(C)&nbsp;2004&nbsp;&nbsp;Nick&nbsp;Jensen
        #----------------------------------------------------------------------------
        #&nbsp;Supplementary&nbsp;Documentation:
        #
        #&nbsp;&nbsp;&nbsp;Description&nbsp;of&nbsp;Arguments:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;should&nbsp;be&nbsp;about&nbsp;90%&nbsp;familiar&nbsp;to&nbsp;getmaps&nbsp;users.
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<map&nbsp;name>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Describes&nbsp;this&nbsp;set&nbsp;of&nbsp;maps
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Left-most&nbsp;center&nbsp;longitude&nbsp;(West)
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<right>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Right-most&nbsp;center&nbsp;longitude&nbsp;(East)
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Top-most&nbsp;center&nbsp;latitude&nbsp;(North)
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<bottom>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bottom-most&nbsp;center&nbsp;latitude&nbsp;(South)
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<scale>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Desired&nbsp;scale.&nbsp;Scales&nbsp;that&nbsp;I&nbsp;use&nbsp;are:
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Neighborhood=25000-40000
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Area=75000
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Region=500000
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[<overlap>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount&nbsp;(in&nbsp;pixels)&nbsp;desired&nbsp;for&nbsp;overlap.&nbsp;Format:
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<horizontal>x<vertical>".&nbsp;This&nbsp;argument&nbsp;is&nbsp;optional.
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default="245x325"&nbsp;(Zaurus&nbsp;5x000&nbsp;screen&nbsp;size&nbsp;plus&nbsp;5
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pixels).
        #
        #&nbsp;&nbsp;&nbsp;How&nbsp;it&nbsp;works:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assuming&nbsp;that&nbsp;the&nbsp;user&nbsp;enters&nbsp;a&nbsp;good&nbsp;set&nbsp;of&nbsp;arguments,&nbsp;mapfetch.pl
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;starts&nbsp;off&nbsp;by&nbsp;estimating&nbsp;for&nbsp;the&nbsp;entered&nbsp;scale&nbsp;how&nbsp;much&nbsp;distance
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;needs&nbsp;to&nbsp;be&nbsp;between&nbsp;each&nbsp;map's&nbsp;center&nbsp;in&nbsp;order&nbsp;to&nbsp;get&nbsp;the&nbsp;desired
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;overlap.&nbsp;Please&nbsp;understand&nbsp;that&nbsp;this&nbsp;algorithm&nbsp;is&nbsp;extremely
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;experimental.&nbsp;All&nbsp;I&nbsp;know&nbsp;is&nbsp;that&nbsp;is&nbsp;works&nbsp;decently&nbsp;well&nbsp;for&nbsp;the
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;that&nbsp;I'm&nbsp;giving&nbsp;it.&nbsp;Based&nbsp;on&nbsp;those&nbsp;distances,&nbsp;it&nbsp;counts&nbsp;up
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;total&nbsp;number&nbsp;of&nbsp;maps&nbsp;it's&nbsp;going&nbsp;to&nbsp;have&nbsp;to&nbsp;fetch&nbsp;to&nbsp;cover&nbsp;the
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;desired&nbsp;area&nbsp;at&nbsp;that&nbsp;scale.&nbsp;It&nbsp;then&nbsp;proceeds&nbsp;in&nbsp;much&nbsp;the&nbsp;same&nbsp;way&nbsp;as
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getmaps&nbsp;did:&nbsp;calling&nbsp;for&nbsp;wget&nbsp;to&nbsp;get&nbsp;the&nbsp;maps&nbsp;and&nbsp;gif2png&nbsp;to&nbsp;convert
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;them.
        #
        #&nbsp;&nbsp;&nbsp;Files&nbsp;Produced:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mapfetch.pl&nbsp;produces&nbsp;two&nbsp;types&nbsp;of&nbsp;files:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp;maps.txt&nbsp;-&nbsp;This&nbsp;file&nbsp;is&nbsp;a&nbsp;text&nbsp;file&nbsp;that&nbsp;stores&nbsp;information&nbsp;about
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;each&nbsp;map&nbsp;in&nbsp;the&nbsp;format&nbsp;required&nbsp;by&nbsp;qpeGPS.&nbsp;Yes,&nbsp;it
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;properly&nbsp;enters&nbsp;the&nbsp;correct&nbsp;pixel&nbsp;sizes:&nbsp;"1036&nbsp;780".
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Really,&nbsp;the&nbsp;name&nbsp;of&nbsp;this&nbsp;file&nbsp;is&nbsp;dependent&nbsp;on&nbsp;the
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arguments&nbsp;entered,&nbsp;but&nbsp;ends&nbsp;up&nbsp;in&nbsp;this&nbsp;format:
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"<map&nbsp;name>_<scale>_maps.txt".
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.&nbsp;*.png&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;These&nbsp;are&nbsp;the&nbsp;individual&nbsp;maps&nbsp;in&nbsp;regular&nbsp;png&nbsp;(Portable
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Network&nbsp;Graphics)&nbsp;format&nbsp;that&nbsp;together&nbsp;form&nbsp;a&nbsp;set&nbsp;of
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maps&nbsp;that&nbsp;cover&nbsp;the&nbsp;desired&nbsp;area.&nbsp;Their&nbsp;filenames&nbsp;are
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;also&nbsp;dependent&nbsp;on&nbsp;the&nbsp;arguments&nbsp;but&nbsp;end&nbsp;up&nbsp;in&nbsp;this
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format:&nbsp;"<map&nbsp;name>_<scale>_<index&nbsp;#>_<center
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;latitude>_<center&nbsp;longitude>.txt".
        #
        #&nbsp;&nbsp;&nbsp;Hint&nbsp;for&nbsp;qpeGPS&nbsp;users:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In&nbsp;order&nbsp;for&nbsp;qpeGPS&nbsp;to&nbsp;"know"&nbsp;about&nbsp;the&nbsp;maps&nbsp;you've&nbsp;installed,&nbsp;you
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;should&nbsp;run&nbsp;this&nbsp;in&nbsp;the&nbsp;qpeGPS&nbsp;maps&nbsp;folder&nbsp;for&nbsp;each&nbsp;set&nbsp;of&nbsp;maps:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cat&nbsp;<map&nbsp;name>_<scale>_maps.txt&nbsp;>>maps.txt
        #
        #&nbsp;&nbsp;&nbsp;Testing:
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;So&nbsp;far&nbsp;I've&nbsp;tested&nbsp;this&nbsp;script&nbsp;and&nbsp;have&nbsp;gotten&nbsp;it&nbsp;to&nbsp;work&nbsp;on&nbsp;a&nbsp;Windows
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XP&nbsp;box&nbsp;+&nbsp;ActivePerl&nbsp;5.8&nbsp;+&nbsp;wget.exe&nbsp;+&nbsp;gif2png.exe,&nbsp;a&nbsp;Debian&nbsp;Sarge
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Testing)&nbsp;GNU/Linux&nbsp;box&nbsp;+&nbsp;Perl&nbsp;5.8.3&nbsp;and&nbsp;on&nbsp;my&nbsp;Sharp&nbsp;Zaurus&nbsp;SL-5600
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;running&nbsp;theKompanyROM&nbsp;+&nbsp;Perl&nbsp;5.6.1&nbsp;+&nbsp;qpeGPS&nbsp;0.9.1.&nbsp;So,&nbsp;I&nbsp;hope&nbsp;it
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;works&nbsp;on&nbsp;whatever&nbsp;you&nbsp;all&nbsp;are&nbsp;using.
        #
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Experimental&nbsp;Algorithm:&nbsp;The&nbsp;algorithm&nbsp;works&nbsp;just&nbsp;fine&nbsp;at&nbsp;"normal"
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scales&nbsp;around&nbsp;25000&nbsp;-&nbsp;75000,&nbsp;but&nbsp;I&nbsp;have&nbsp;found&nbsp;that&nbsp;at&nbsp;a&nbsp;scale&nbsp;of
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;500000&nbsp;the&nbsp;overlap&nbsp;could&nbsp;be&nbsp;off&nbsp;by&nbsp;one&nbsp;pixel,&nbsp;erring&nbsp;on&nbsp;the&nbsp;side&nbsp;of
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;caution&nbsp;(one&nbsp;pixel&nbsp;too&nbsp;many).&nbsp;To&nbsp;me,&nbsp;this&nbsp;is&nbsp;acceptable.&nbsp;For&nbsp;others,
        #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maybe&nbsp;not&nbsp;(?),&nbsp;it&nbsp;depends&nbsp;on&nbsp;the&nbsp;application.
        #
        #&nbsp;&nbsp;&nbsp;Useful&nbsp;Links:
        #
        #&nbsp;&nbsp;&nbsp;qpeGPS:&nbsp;http://qpegps.sourceforge.net/
        #&nbsp;&nbsp;&nbsp;Sourceforge&nbsp;Maps&nbsp;Forum:&nbsp;http://sourceforge.net/forum/forum.php?forum_id=206322
        #&nbsp;&nbsp;&nbsp;getmaps:&nbsp;http://z-soft.z-portal.info/getmaps/
        #&nbsp;&nbsp;&nbsp;MapQuest&nbsp;(Lat/Lon):&nbsp;http://www.mapquest.com/maps/latlong.adp
        #&nbsp;&nbsp;&nbsp;ActivePerl:&nbsp;http://activestate.com/Products/Download/Download.plex?id=ActivePerl
        #&nbsp;&nbsp;&nbsp;wget:&nbsp;http://www.gnu.org/software/wget/wget.html
        #&nbsp;&nbsp;&nbsp;gif2png:&nbsp;http://www.catb.org/~esr/gif2png/
        #----------------------------------------------------------------------------

        #&nbsp;USAGE&nbsp;SECTION
        my&nbsp;$usage&nbsp;=<<"END-OF-USAGE";
        mapfetch.pl&nbsp;v&nbsp;0.1&nbsp;(2004/06/04)

        Usage:&nbsp;mapfetch.pl&nbsp;<map&nbsp;name>&nbsp;<left>
        <right>&nbsp;<top>&nbsp;<bottom>&nbsp;<scale>&nbsp;[<overlap>]
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<top>&nbsp;-&nbsp;+-----------------+
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
        &nbsp;&nbsp;<bottom>&nbsp;-&nbsp;+-----------------+
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\\&amp;nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\\ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<right>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Example:&nbsp;mapfetch.pl&nbsp;bw&nbsp;-77.3&nbsp;-76.3&nbsp;39.55
        &nbsp;&nbsp;38.625&nbsp;25000

        For&nbsp;more&nbsp;info,&nbsp;please&nbsp;view&nbsp;source.
        END-OF-USAGE

        #&nbsp;ERROR&nbsp;CHECKING
        if&nbsp;($#ARGV&nbsp;<&nbsp;5&nbsp;||&nbsp;$#ARGV&nbsp;>&nbsp;6)&nbsp;{&nbsp;die&nbsp;$usage;&nbsp;}

        #&nbsp;GET&nbsp;ARGUMENTS
        my&nbsp;($name,&nbsp;$left,&nbsp;$right,&nbsp;$top,&nbsp;$bottom,&nbsp;$scale,&nbsp;$overlap)&nbsp;=&nbsp;@ARGV;

        #&nbsp;PROCESS&nbsp;OVERLAP&nbsp;ARG
        my&nbsp;$over_x,&nbsp;$over_y;
        if&nbsp;($overlap)&nbsp;{
        &nbsp;&nbsp;($over_x,&nbsp;$over_y)&nbsp;=&nbsp;split(/x/,&nbsp;$overlap);
        }&nbsp;else&nbsp;{
        &nbsp;&nbsp;#&nbsp;DEFAULT&nbsp;OVERLAP&nbsp;FOR&nbsp;ZAURUS&nbsp;5x00&nbsp;SCREEN&nbsp;SIZE:&nbsp;240x320
        &nbsp;&nbsp;($over_x,&nbsp;$over_y)&nbsp;=&nbsp;(245,&nbsp;325);
        }

        #&nbsp;MORE&nbsp;ERROR&nbsp;CHECKING
        if&nbsp;($top&nbsp;<=&nbsp;$bottom)&nbsp;{
        &nbsp;&nbsp;die&nbsp;"<top>&nbsp;latitude&nbsp;must&nbsp;be&nbsp;greater&nbsp;than\n<bottom>&nbsp;latitude.\n";
        }
        if&nbsp;($right&nbsp;<=&nbsp;$left)&nbsp;{
        &nbsp;&nbsp;die&nbsp;"<right>&nbsp;longitude&nbsp;must&nbsp;be&nbsp;greater&nbsp;than\n<left>&nbsp;latitude.\n";
        }
        unless&nbsp;($over_x&nbsp;<&nbsp;518&nbsp;&&&nbsp;$over_x&nbsp;>=&nbsp;0&nbsp;&&&nbsp;$over_y&nbsp;<&nbsp;396&nbsp;&&&nbsp;$over_y&nbsp;>=&nbsp;0)&nbsp;{
        &nbsp;&nbsp;die&nbsp;"Invalid&nbsp;overlap.&nbsp;Valid&nbsp;range:&nbsp;0x0-517x395.\n\n"&nbsp;.
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Note:&nbsp;Negative&nbsp;overlaps&nbsp;results&nbsp;in&nbsp;gaps.\n"&nbsp;.
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Overlaps&nbsp;greater&nbsp;than&nbsp;half&nbsp;of&nbsp;the&nbsp;image\n"&nbsp;.
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"produces&nbsp;too&nbsp;many&nbsp;maps.\n";
        }
        unless&nbsp;($scale&nbsp;>=2)&nbsp;{
        &nbsp;&nbsp;die&nbsp;"Invalid&nbsp;scale.&nbsp;Valid&nbsp;range:&nbsp;2&nbsp;or&nbsp;greater.\n";
        }

        #&nbsp;FIND&nbsp;THE&nbsp;DISTANCES&nbsp;BETWEEN&nbsp;MAP&nbsp;CENTERS&nbsp;***EXPERIMENTAL***
        my&nbsp;$h_overlap&nbsp;=&nbsp;-(1/240000000)&nbsp;*&nbsp;$over_x&nbsp;+&nbsp;.00000323&nbsp;+&nbsp;(257/240000000);
        my&nbsp;$h_off&nbsp;=&nbsp;$scale&nbsp;*&nbsp;$h_overlap;
        my&nbsp;$v_overlap&nbsp;=&nbsp;-(5/1600000000)&nbsp;*&nbsp;$over_y&nbsp;+&nbsp;.00000144&nbsp;+&nbsp;(341/320000000);
        my&nbsp;$v_off&nbsp;=&nbsp;$scale&nbsp;*&nbsp;$v_overlap;

        #&nbsp;CONVERT&nbsp;SCALE&nbsp;TO&nbsp;MAPTUIT&nbsp;SCALE
        $maptuit_scale&nbsp;=&nbsp;sprintf&nbsp;"%.13f",&nbsp;$scale&nbsp;/&nbsp;2815;

        #&nbsp;COUNT&nbsp;TOTAL&nbsp;NUMBER&nbsp;OF&nbsp;MAPS&nbsp;TO&nbsp;GET
        my&nbsp;($total,&nbsp;$tot_x,&nbsp;$tot_y)&nbsp;=&nbsp;(0,&nbsp;0,&nbsp;0);
        for&nbsp;($y&nbsp;=&nbsp;$top;&nbsp;$y&nbsp;>&nbsp;$bottom;&nbsp;$y&nbsp;-=&nbsp;$v_off)&nbsp;{
        &nbsp;&nbsp;$tot_y++;
        }
        for&nbsp;($x&nbsp;=&nbsp;$left;&nbsp;$x&nbsp;<&nbsp;$right;&nbsp;$x&nbsp;+=&nbsp;$h_off)&nbsp;{
        &nbsp;&nbsp;$tot_x++;
        }
        $total&nbsp;=&nbsp;$tot_x&nbsp;*&nbsp;$tot_y;
        print&nbsp;"$total&nbsp;total&nbsp;maps&nbsp;to&nbsp;download&nbsp;in&nbsp;a&nbsp;$tot_x&nbsp;x&nbsp;$tot_y&nbsp;grid...\n\n";

        #&nbsp;OPEN&nbsp;THE&nbsp;<MAP&nbsp;NAME>_<SCALE>_MAPS.TXT&nbsp;FILE
        my&nbsp;$mapsdottext&nbsp;=&nbsp;$name&nbsp;.&nbsp;"_"&nbsp;.&nbsp;(sprintf&nbsp;"%.0f",&nbsp;$scale)&nbsp;.&nbsp;"_maps.txt";
        open&nbsp;OUT,&nbsp;">$mapsdottext"&nbsp;||&nbsp;die&nbsp;"Couldn't&nbsp;open&nbsp;$mapsdottext&nbsp;for&nbsp;writing!\n";

        #&nbsp;GET&nbsp;THE&nbsp;MAPS&nbsp;ALREADY
        my&nbsp;$count&nbsp;=&nbsp;0;
        for&nbsp;($y&nbsp;=&nbsp;$top;&nbsp;$y&nbsp;>&nbsp;$bottom;&nbsp;$y&nbsp;-=&nbsp;$v_off)&nbsp;{
        &nbsp;&nbsp;for&nbsp;($x&nbsp;=&nbsp;$left;&nbsp;$x&nbsp;<&nbsp;$right;&nbsp;$x&nbsp;+=&nbsp;$h_off)&nbsp;{
        &nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;"FETCHING&nbsp;MAP&nbsp;%d&nbsp;OF&nbsp;%d&nbsp;-&nbsp;LATITUDE:&nbsp;%2.6f,&nbsp;LONGITUDE:&nbsp;%2.6f\n\n",&nbsp;++$count,&nbsp;$total,&nbsp;$y,&nbsp;$x;
        &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$format&nbsp;=&nbsp;"%s_%.0f_%05s_%2.6f_%2.6f";
        &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$fn&nbsp;=&nbsp;sprintf&nbsp;$format,&nbsp;$name,&nbsp;$scale,&nbsp;$count,&nbsp;$y,&nbsp;$x;
        &nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;OUT&nbsp;"FRITZ&nbsp;%s.png&nbsp;%.0f&nbsp;1036&nbsp;780&nbsp;%2.6f&nbsp;%2.6f\n",&nbsp;$fn,&nbsp;$scale,&nbsp;$y,&nbsp;$x;
        &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$url&nbsp;=&nbsp;"http://www.maptuit.com/htmlclient/map.cgi?";
        &nbsp;&nbsp;&nbsp;&nbsp;$url&nbsp;.=&nbsp;sprintf&nbsp;"%2.6f,%2.6f,1024,768,0,%.13f,1,Unique,0,Maps+m",&nbsp;$x,&nbsp;$y,&nbsp;$maptuit_scale;
        &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$wget&nbsp;=&nbsp;"wget&nbsp;-O&nbsp;$fn.gif&nbsp;$url";
        &nbsp;&nbsp;&nbsp;&nbsp;my&nbsp;$gif2png;
        &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($^O&nbsp;eq&nbsp;"MSWin32")&nbsp;{
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Windows&nbsp;version&nbsp;of&nbsp;gif2png&nbsp;didn't&nbsp;support&nbsp;-O
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$gif2png&nbsp;=&nbsp;"gif2png&nbsp;-d&nbsp;-p&nbsp;$fn";
        &nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$gif2png&nbsp;=&nbsp;"gif2png&nbsp;-d&nbsp;-p&nbsp;-O&nbsp;$fn";
        &nbsp;&nbsp;&nbsp;&nbsp;}
        &nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"EXECUTING:&nbsp;$wget\n";
        &nbsp;&nbsp;&nbsp;&nbsp;system($wget);
        &nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"EXECUTING:&nbsp;$gif2png\n";
        &nbsp;&nbsp;&nbsp;&nbsp;system($gif2png);
        &nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"\n\n";
        &nbsp;&nbsp;}
        }

        close&nbsp;OUT&nbsp;||&nbsp;die&nbsp;"Couldn't&nbsp;close&nbsp;$mapsdottext!\n";
        print&nbsp;"mapfetch.pl&nbsp;completed&nbsp;successfully.\n";

        exit&nbsp;0;

         
    • Nobody/Anonymous

      Very Nice. Could you let us all know what would need to change to run it in 480x640 for the zaurus 6000?

      Thanks

       
      • Martin Henning

        Martin Henning - 2004-07-16

        hiya, are you talking about one of the newer Z's with 2.4.18-rmk7-pxa3-embedix kernel? did you re compile qpegps or does it work and look good without any changes? in any case, please send me some information and/or screenshots of the program running on 640x480... i'd like to put them up on the qpegps.sourceforge.net if you don't mind!

        see ya, martin

         
        • Nobody/Anonymous

          qpeGPS works great, even in 640x480 mode (I.E. the maps look better if you do not run it in 240x320). I was essentially wondering on the perl script, where you have the 240x320 logic for overlapping.
          I.E. over_x and over_y could be differnt in higher res mode, right? WHat else would you need to change?

           
    • Nobody/Anonymous

      qpegps work fine on Zauras SL-C860 with VGA (640x480) screen, so I thing that will work on Z 6000 too.

       
    • Nobody/Anonymous

      FYI, the most up-to-date mapfetch is:

      http://www.hardcodelabs.org/projects/mapfetch.txt

      Also, to answer the question about generating mapsets for the 480x640 zaurii and other pda's...

      Look for these lines in the code:

        # DEFAULT OVERLAP FOR ZAURUS 5x00 SCREEN SIZE: 240x320
        ($over_x, $over_y) = (245, 325);

      If you're using 480x640 (aka portrait-mode), use:
        ($over_x, $over_y) = (485, 645);

      If you're using 640x480 (aka landscape-mode), use:
        ($over_x, $over_y) = (645, 485);

      That should do it! However, please note that I haven't done any testing on this at all... so, if this works for you, doesn't work for you, please post it here.

      - Nick

       
    • Nobody/Anonymous

      Hi,

      Thanks, works a treat on the C860 as well.

      A couple of issues that can be worked round :

      unless ($over_x < 518 && $over_x >= 0 && $over_y < 396 && $over_y >= 0) {

      which need to be upped if you enter bigger overlaps as suggested for hi res units.

      Only other problem is that maps come out with text a little too small to read easily if you are driving at the time.

      Shame there are no parameters for text size anywhere.

      For now, just rescalled them 200% and updated values in maps.txt file.

      Thanks again, excellent script.

      Zuber

       

Log in to post a comment.