About us | Join us | Hire us | Contact us | Google Group

Changeset 368

Show
Ignore:
Timestamp:
02/23/09 13:44:01 (13 months ago)
Author:
wangchun
Message:

geoutils:

  • propset svn:executable
  • updated googlewms.py for the latest google maps
  • fixed googlewms.py compatiblity for python 2.5
Location:
geoutils
Files:
3 modified

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/python 
     1#!/usr/bin/env python 
    22# -*- coding: utf-8 -*- 
     3 
     4from __future__ import with_statement 
    35 
    46import sys 
     
    1315 
    1416layers = { 
    15     'kh33': {'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'}, 
    2022} 
    2123 
     
    4446            x1, y1 = lon1 / 2.0 / pi + 0.5, log((1.0 + sin(lat1)) / (1.0 - sin(lat1))) / 4.0 / pi + 0.5 
    4547            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), 17) 
     48            z = min(max(int(ceil(log(min(width / ((x2 - x1) * 256), height / ((y2 - y1) * 256)), 2))), 0), 18) 
    4749            iw, ih = int(round(ldexp((x2 - x1) * 256, z))), int(round(ldexp((y2 - y1) * 256, z))) 
    4850            ix_list = range(int(floor((floor(ldexp(x1, z)) - ldexp(x1, z)) / ldexp(x2 - x1, z) * iw)), iw, 256) 
     
    5658                filename = '%02d-%06d-%06d.%s' % (z, 2 ** z - y - 1, x, layers[layer]['type']) 
    5759                try: 
    58                     with file(os.path.join(dirname, filename), 'r') as f: 
     60                    with open(os.path.join(dirname, filename), 'r') as f: 
    5961                        if layers[layer]['type'] == 'png': 
    6062                            gd.image(f, layers[layer]['type']).copyTo(image, (ix, ih - iy - 256)) 
     
    6567                    try: 
    6668                        data = urllib.urlopen(url).read() 
    67                     except Exception as exc: 
     69                    except Exception, exc: 
    6870                        print >> sys.stderr, 'ERROR: %s' % exc 
    6971                        continue 
     
    7476                        else: 
    7577                            image.paste(Image.open(StringIO(data)), (ix, ih - iy - 256)) 
    76                     except Exception as exc: 
     78                    except Exception, exc: 
    7779                        print >> sys.stderr, exc 
    7880                        continue 
     
    8284                        pass 
    8385                    try: 
    84                         with file(os.path.join(dirname, filename), 'w') as f: 
     86                        with open(os.path.join(dirname, filename), 'w') as f: 
    8587                            f.write(data) 
    8688                    except IOError: 
    8789                        pass 
    88         except Exception as exc: 
     90        except Exception, exc: 
    8991            print >> sys.stderr, exc 
    9092            self.send_error(500) 
  • geoutils/plt.pl

    • Property svn:executable set to *