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)
# 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;
# 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;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#----------------------------------------------------------------------------
# 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)
# 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;
# 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>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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> - +-----------------+
\\ \\ <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;
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.
thank you!
the second perl sript work great!
downloading with the example right now.
very grateful,
Ken
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> - +-----------------+
\\ \\ <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>
<pre> tags don't preserve spaces... here goes with 's...
#!/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;
Very Nice. Could you let us all know what would need to change to run it in 480x640 for the zaurus 6000?
Thanks
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
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?
qpegps work fine on Zauras SL-C860 with VGA (640x480) screen, so I thing that will work on Z 6000 too.
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
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