Changeset 368
- Timestamp:
- 02/23/09 13:44:01 (19 months ago)
- Location:
- geoutils
- Files:
-
- 3 modified
-
columbus.pl (modified) (1 prop)
-
googlewms.py (modified) (7 diffs, 1 prop)
-
plt.pl (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
geoutils/columbus.pl
- Property svn:executable set to *
-
geoutils/googlewms.py
- Property svn:executable set to *
r365 r368 1 #!/usr/bin/ python1 #!/usr/bin/env python 2 2 # -*- coding: utf-8 -*- 3 4 from __future__ import with_statement 3 5 4 6 import sys … … 13 15 14 16 layers = { 15 'kh 33': {'url': 'http://kh.google.com/kh?v=33', 'type': 'jpg'},16 'w2p.87': {'url': 'http://mt.google.com/mt ?v=w2p.87', 'type': 'jpg'},17 'w2. 86': {'url': 'http://mt.google.com/mt?v=w2.86', 'type': 'png'},18 'w2t. 86': {'url': 'http://mt.google.com/mt?v=w2t.86', 'type': 'png'},19 'cn1. 5': {'url': 'http://mt.google.cn/mt?v=cn1.5', 'type': 'png'},17 'khm36': {'url': 'http://khm.google.com/kh/v=36', 'type': 'jpg'}, 18 'w2p.87': {'url': 'http://mt.google.com/mt/v=w2p.87', 'type': 'jpg'}, 19 'w2.92': {'url': 'http://mt.google.com/mt/v=w2.86', 'type': 'png'}, 20 'w2t.92': {'url': 'http://mt.google.com/mt/v=w2t.86', 'type': 'png'}, 21 'cn1.6': {'url': 'http://mt.google.cn/mt?v=cn1.6', 'type': 'png'}, 20 22 } 21 23 … … 44 46 x1, y1 = lon1 / 2.0 / pi + 0.5, log((1.0 + sin(lat1)) / (1.0 - sin(lat1))) / 4.0 / pi + 0.5 45 47 x2, y2 = lon2 / 2.0 / pi + 0.5, log((1.0 + sin(lat2)) / (1.0 - sin(lat2))) / 4.0 / pi + 0.5 46 z = min(max(int(ceil(log(min(width / ((x2 - x1) * 256), height / ((y2 - y1) * 256)), 2))), 0), 1 7)48 z = min(max(int(ceil(log(min(width / ((x2 - x1) * 256), height / ((y2 - y1) * 256)), 2))), 0), 18) 47 49 iw, ih = int(round(ldexp((x2 - x1) * 256, z))), int(round(ldexp((y2 - y1) * 256, z))) 48 50 ix_list = range(int(floor((floor(ldexp(x1, z)) - ldexp(x1, z)) / ldexp(x2 - x1, z) * iw)), iw, 256) … … 56 58 filename = '%02d-%06d-%06d.%s' % (z, 2 ** z - y - 1, x, layers[layer]['type']) 57 59 try: 58 with file(os.path.join(dirname, filename), 'r') as f:60 with open(os.path.join(dirname, filename), 'r') as f: 59 61 if layers[layer]['type'] == 'png': 60 62 gd.image(f, layers[layer]['type']).copyTo(image, (ix, ih - iy - 256)) … … 65 67 try: 66 68 data = urllib.urlopen(url).read() 67 except Exception asexc:69 except Exception, exc: 68 70 print >> sys.stderr, 'ERROR: %s' % exc 69 71 continue … … 74 76 else: 75 77 image.paste(Image.open(StringIO(data)), (ix, ih - iy - 256)) 76 except Exception asexc:78 except Exception, exc: 77 79 print >> sys.stderr, exc 78 80 continue … … 82 84 pass 83 85 try: 84 with file(os.path.join(dirname, filename), 'w') as f:86 with open(os.path.join(dirname, filename), 'w') as f: 85 87 f.write(data) 86 88 except IOError: 87 89 pass 88 except Exception asexc:90 except Exception, exc: 89 91 print >> sys.stderr, exc 90 92 self.send_error(500) -
geoutils/plt.pl
- Property svn:executable set to *
