1
2
3
4
5
6
7
8
9
10
11
12
13
14 import sys
15 import os
16 import time
17 import subprocess
18 import random
19
20
21 def sig(i):
22 if i < 0: return -1
23 elif i > 0: return 1
24 else: return i
25
26
27 if len(sys.argv) < 7:
28 print "You have to specify: slat slon tlat tlon scale tag [--download] [--overwrite] [--writetofile]"
29 sys.exit(0)
30
31
32
33
34
35
36
37
38
39 print sys.argv
40 slat = float(sys.argv[1])
41 slon = float(sys.argv[2])
42 tlat = float(sys.argv[3])
43 tlon = float(sys.argv[4])
44 scale = int(sys.argv[5])
45 tag = sys.argv[6]
46
47 download = False
48 if "--download" in sys.argv[6:]: download = True
49
50 overwrite = False
51 if "--overwrite" in sys.argv[6:]: overwrite = True
52
53 writetofile = False
54 if "--writetofile" in sys.argv[6:]: writetofile = True
55
56
57 scales = (3950, 3950*3, 3950*6, 3950*12, 3950*25, 3950*50, 3950*150, 3950*800, 3950*2000, 3950*7000, 3950*12000)
58
59 if scale not in scales:
60 print "Invalid scale"
61 print "Available scales are: ", scales
62 sys.exit(0)
63
64 alt = scale / scales[0]
65
66
67 if slat > tlat:
68 tmp = tlat
69 tlat = slat
70 slat = tmp
71
72 if slon > tlon:
73 tmp = tlon
74 tlon = slon
75 slon = tmp
76
77
78 k = scale * 0.0000028
79 klat = k * 0.8
80 klon = k * 1.2
81
82
83 mod = 0.000001
84 while (klat%mod)/klat < 0.1 and (klon%mod)/klon < 0.1: mod *= 10
85 mod *= 0.1
86
87 klat -= klat % mod
88 klon -= klon % mod
89
90 slat -= (abs(slat) % klat) * sig(slat)
91 slon -= (abs(slon) % klon) * sig(slon)
92
93
94 lat = slat
95 while lat <= tlat+klat:
96 lon = slon
97 while lon <= tlon+klon:
98 filename = "map_expedia--" \
99 + tag \
100 + "--" \
101 + str(scale) \
102 + "--"
103
104 if lat >= 0: filename += "+%(lat)07.3f" % {"lat":lat}
105 else: filename += "%(lat)08.3f" % {"lat":lat}
106
107 filename += "_"
108 if lon >= 0: filename += "+%(lon)07.3f" % {"lon":lon}
109 else: filename += "%(lon)08.3f" % {"lon":lon}
110
111 filename += ".gif"
112
113 skipped = False
114 if download:
115 if overwrite or not os.path.exists(filename):
116 url = "http://www.expedia.com/pub/agent.dll?qscr=mrdt&ID=3XNsF." \
117 + "&CenP=" + str(lat) + "," + str(lon) \
118 + "&Lang=EUR0809&Alti=" + str(alt) \
119 + "&Size=1280,1024&Offs=0,0"
120
121 subprocess.call(["wget", url, "-O", filename])
122 else:
123 print filename, "already downloaded"
124 skipped = True
125
126 if writetofile:
127 print "Writing to file"
128 f = open(tag + ".txt", "a")
129 f.write(filename + " " + str(lat) + " " + str(lon) + " " + str(scale) + "\n")
130 f.close()
131
132 if download and not skipped:
133 sleep = random.randint(1, 20)
134 while sleep > 0:
135 print sleep
136 time.sleep(1)
137 sleep -= 1
138
139 lon += klon
140 lat += klat
, as shown below in the list of files. Do
link, since this is subject to change and can break easily.