$OpenBSD: patch-gpsmap_cc,v 1.2 2006/11/01 21:13:19 kili Exp $ # New mapsource, from upstream SVN. # Use our ftp(1) instead of wget. --- gpsmap.cc.orig Wed Nov 2 22:16:07 2005 +++ gpsmap.cc Sat Oct 21 12:42:56 2006 @@ -79,7 +79,8 @@ const char *config_base = "kismet.conf"; #define MAPSOURCE_TIGER 3 #define MAPSOURCE_EARTHAMAPS 4 #define MAPSOURCE_TERRATOPO 5 -#define MAPSOURCE_MAX 5 +#define MAPSOURCE_EUEX 6 +#define MAPSOURCE_MAX 6 // Broken map sources... Damn vendors changing. // Mappoint @@ -96,9 +97,11 @@ const char url_template_ti[] = "http://t // Earthamaps need a perl helper script to get data because of cookies const char url_template_em[] = "gpsmap-helper-earthamaps %s %f %f %d %d %ld"; -// Download template for sources that we fetch using wget -const char download_template[] = "wget \"%s\" -O %s"; +const char url_template_euex[] = "http://www.expedia.de/pub/agent.dll?qscr=mrdt&ID=3XNsF.&CenP=%f,%f&Lang=%s&Alti=%ld&Size=%d,%d&Offs=0.000000,0.000000&BCheck=1"; +// Download template for sources that we fetch using ftp +const char download_template[] = "/usr/bin/ftp -o %s \"%s\""; + // Image scales we try to autofetch long int scales[] = { 1000, 2000, 5000, 10000, 20000, 30000, 50000, 60000, 70000, 75000, 80000, 85000, 90000, 95000, 100000, 125000, 150000, 200000, @@ -115,6 +118,12 @@ long int earthamapscales[] = { 0, 0, 32393191, 16196595, 8098298, 4319092, 2159546, 1079773, 539887, 215955, 107977, 53989, 26994, 14315, 7158, 3579, -1 }; +// Scales for Expedia +long int euexscales[] = { 3950, 7900, 11850, 15800, 19750, 23700, 27650, + 31600, 35550, 39500, 79000, 118500, 197500, 237000, 276500, 316000, + 355500, 395000, 790000, 1580000, 237000, 3160000, 3950000, 19750000, + 39500000, 47400000}; + // Decay from absolute blue for multiple tracks const uint8_t track_decay = 0x1F; // distance (in feet) before we throttle a network and discard it @@ -1494,6 +1503,29 @@ int BestMapScale(long int *in_mapscale, return -1; } + if (mapsource == MAPSOURCE_EUEX) { + for (int x = 0; euexscales[x] != -1; x++) { + calcxy(&mapx, &mapy, tlat, tlon, + (double) euexscales[x]/PIXELFACT, + map_avg_lat, map_avg_lon); + calcxy(&map2x, &map2y, blat, blon, + (double) euexscales[x]/PIXELFACT, + map_avg_lat, map_avg_lon); + + if ((mapx < 0 || mapx > map_width || mapy < 0 || + mapy > map_height) || + (map2x < 0 || map2x > map_width || + map2y < 0 || map2y > map_height)) { + continue; + } else { + (*in_mapscale) = euexscales[x]; + (*in_fetchscale) = x; + return 1; + } + } + return -1; + } + if (mapsource == MAPSOURCE_EARTHAMAPS) { // Find how many scales we have int nscales; @@ -3348,6 +3380,7 @@ int Usage(char* argv, int ec = 1) { " 3 Tiger US Census (vector)\n" " 4 EarthaMaps (vector, UNAVAILABLE)\n" " 5 TerraServer (topo)\n" + " 6 Expedia EU (vector)\n" " -D, --keep-gif Keep the downloaded map\n" " -V, --version GPSMap version\n" "\nImage options\n" @@ -4163,6 +4196,13 @@ int main(int argc, char *argv[]) { } else if (mapsource == MAPSOURCE_EARTHAMAPS) { snprintf(url, 1024, url_template_em, mapname, map_avg_lat, map_avg_lon, map_width, map_height, fetch_scale); + } else if (mapsource == MAPSOURCE_EUEX) { + fetch_scale = (long) (map_scale / 3950); + char loc[8] = "USA0409"; + if (map_avg_lat > (-30.0)) + strcpy(loc,"EUR0809"); + snprintf(url, 1024, url_template_euex, map_avg_lat, map_avg_lon, + loc, fetch_scale, map_width, map_height); } printf("Map url: %s\n", url); @@ -4177,8 +4217,11 @@ int main(int argc, char *argv[]) { } } else { char geturl[1024]; - snprintf(geturl, 1024, download_template, url, mapname); - system(geturl); + snprintf(geturl, 1024, download_template, mapname, url); + if (system(geturl)!=0) { + fprintf(stderr, "WARNING: failed to execute '%s'\n", geturl); + exit(1); + } } printf("Loading map into Imagemagick structures.\n");