]> gitweb.fperrin.net Git - GpsPrune.git/blob - debian/scripts/get-tiles.py
Import Debian packaging from https://salsa.debian.org/debian-gis-team/gpsprune/
[GpsPrune.git] / debian / scripts / get-tiles.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # © 2010, David Paleino <dapal@debian.org>
5 #
6 # This script is released under the GNU General Public License, version 2.
7
8 from urllib2 import urlopen
9 import re
10
11 base = "https://dds.cr.usgs.gov/srtm/version2_1/SRTM3/%s/"
12 regions = ["Eurasia", "North_America", "Australia", "Islands", "South_America", "Africa"]
13
14 for reg in regions:
15     url = base % reg
16     tiles = []
17     for line in urlopen(url).readlines():
18         if line.startswith("<li>"):
19             match = re.match("^<li><.*> ([^>]*)<.*>", line)
20             if match:
21                 tiles.append(match.group(1).replace(".hgt.zip", ""))
22     f = open("tiles%s.txt" % (regions.index(reg)+1), "w")
23     f.write('\n'.join([reg] + tiles))
24     f.close()