Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Hillup/data/NED100m.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from math import floor, ceil, log
from os import unlink, close, write, makedirs, chmod
from os.path import basename, exists, isdir, join
from httplib import HTTPConnection
from urlparse import urlparse
from StringIO import StringIO
from http.client import HTTPConnection
from urllib.parse import urlparse
from io import StringIO
from gzip import GzipFile
from hashlib import md5

Expand Down Expand Up @@ -68,22 +68,22 @@ def datasource(lat, lon, source_dir):

if not exists(local_dir):
makedirs(local_dir)
chmod(local_dir, 0777)
chmod(local_dir, 0o777)

assert isdir(local_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in DEM.NED100m.datasource().'
print('Retrieving', url, 'in DEM.NED100m.datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status in range(400, 500):
# we're probably outside the coverage area
print >> open(local_none, 'w'), url
print(url, file=open(local_none, 'w'))
return None

assert resp.status == 200, (resp.status, resp.read())
Expand Down
14 changes: 7 additions & 7 deletions Hillup/data/NED10m.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from os import unlink, close, write, makedirs, chmod
from os.path import basename, exists, isdir, join
from tempfile import mkstemp, mkdtemp
from httplib import HTTPConnection
from http.client import HTTPConnection
from shutil import move, rmtree
from urlparse import urlparse
from urllib.parse import urlparse
from zipfile import ZipFile
from fnmatch import fnmatch
from hashlib import md5
Expand Down Expand Up @@ -74,22 +74,22 @@ def datasource(lat, lon, source_dir):

if not exists(local_dir):
makedirs(local_dir)
chmod(local_dir, 0777)
chmod(local_dir, 0o777)

assert isdir(local_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in DEM.NED10m.datasource().'
print('Retrieving', url, 'in DEM.NED10m.datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status == 404:
# we're probably outside the coverage area
print >> open(local_none, 'w'), url
print(url, file=open(local_none, 'w'))
return None

assert resp.status == 200, (resp.status, resp.read())
Expand Down Expand Up @@ -124,8 +124,8 @@ def datasource(lat, lon, source_dir):
if local_file.endswith('.hdr'):
# GDAL needs some extra hints to understand the raw float data
hdr_file = open(local_file, 'a')
print >> hdr_file, 'nbits 32'
print >> hdr_file, 'pixeltype float'
print('nbits 32', file=hdr_file)
print('pixeltype float', file=hdr_file)

#
# The file better exist locally now
Expand Down
12 changes: 6 additions & 6 deletions Hillup/data/NED1km.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from math import floor, ceil, log
from os import unlink, close, write, makedirs, chmod
from os.path import basename, exists, isdir, join
from httplib import HTTPConnection
from urlparse import urlparse
from StringIO import StringIO
from http.client import HTTPConnection
from urllib.parse import urlparse
from io import StringIO
from gzip import GzipFile
from hashlib import md5

Expand Down Expand Up @@ -68,22 +68,22 @@ def datasource(lat, lon, source_dir):

if not exists(local_dir):
makedirs(local_dir)
chmod(local_dir, 0777)
chmod(local_dir, 0o777)

assert isdir(local_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in DEM.NED1km.datasource().'
print('Retrieving', url, 'in DEM.NED1km.datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status in range(400, 500):
# we're probably outside the coverage area
print >> open(local_none, 'w'), url
print(url, file=open(local_none, 'w'))
return None

assert resp.status == 200, (resp.status, resp.read())
Expand Down
12 changes: 6 additions & 6 deletions Hillup/data/SRTM1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from math import floor, log
from os import unlink, close, write, chmod, makedirs
from os.path import basename, exists, isdir, join
from httplib import HTTPConnection
from urlparse import urlparse
from http.client import HTTPConnection
from urllib.parse import urlparse
from tempfile import mkstemp
from zipfile import ZipFile
from hashlib import md5
Expand Down Expand Up @@ -105,22 +105,22 @@ def datasource(lat, lon, source_dir):

if not exists(dem_dir):
makedirs(dem_dir)
chmod(dem_dir, 0777)
chmod(dem_dir, 0o777)

assert isdir(dem_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in DEM.SRTM1.datasource().'
print('Retrieving', url, 'in DEM.SRTM1.datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status == 404:
# we're probably outside the coverage area
print >> open(dem_none, 'w'), url
print(url, file=open(dem_none, 'w'))
return None

assert resp.status == 200, (resp.status, resp.read())
Expand All @@ -142,7 +142,7 @@ def datasource(lat, lon, source_dir):
dem_file.write(zipfile.read(zipfile.namelist()[0]))
dem_file.close()

chmod(dem_path, 0666)
chmod(dem_path, 0o666)

finally:
unlink(zip_path)
Expand Down
12 changes: 6 additions & 6 deletions Hillup/data/SRTM3.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
from math import floor, log
from os import unlink, close, write, chmod, makedirs
from os.path import basename, exists, isdir, join
from httplib import HTTPConnection
from urlparse import urlparse
from http.client import HTTPConnection
from urllib.parse import urlparse
from tempfile import mkstemp
from zipfile import ZipFile
from hashlib import md5
Expand Down Expand Up @@ -199,22 +199,22 @@ def datasource(lat, lon, source_dir):

if not exists(dem_dir):
makedirs(dem_dir)
chmod(dem_dir, 0777)
chmod(dem_dir, 0o777)

assert isdir(dem_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in DEM.SRTM3.datasource().'
print('Retrieving', url, 'in DEM.SRTM3.datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status == 404:
# we're probably outside the coverage area
print >> open(dem_none, 'w'), url
print(url, file=open(dem_none, 'w'))
return None

assert resp.status == 200, (resp.status, resp.read())
Expand All @@ -236,7 +236,7 @@ def datasource(lat, lon, source_dir):
dem_file.write(zipfile.read(zipfile.namelist()[0]))
dem_file.close()

chmod(dem_path, 0666)
chmod(dem_path, 0o666)

finally:
unlink(zip_path)
Expand Down
18 changes: 9 additions & 9 deletions Hillup/data/VFP.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from sys import stderr
from urlparse import urlparse, urljoin
from urllib.parse import urlparse, urljoin
from os import unlink, close, write, chmod, makedirs
from os.path import basename, exists, isdir, join
from httplib import HTTPConnection
from http.client import HTTPConnection
from tempfile import mkstemp
from zipfile import ZipFile
from hashlib import md5
Expand Down Expand Up @@ -39,25 +39,25 @@ def datasource(lat, lon, source_dir):

if not exists(dem_dir):
makedirs(dem_dir)
chmod(dem_dir, 0777)
chmod(dem_dir, 0o777)

assert isdir(dem_dir)

#
# Grab a fresh remote copy
#
print >> stderr, 'Retrieving', url, 'in VFP.vfp_datasource().'
print('Retrieving', url, 'in VFP.vfp_datasource().', file=stderr)

conn = HTTPConnection(host, 80)
conn.request('GET', path)
resp = conn.getresponse()

if resp.status == 404:
# we're probably outside the coverage area, use SRTM3 instead
print >> open(dem_none, 'w'), url
print(url, file=open(dem_none, 'w'))
return None

print >> stderr, 'Found', resp.getheader('location'), 'X-Zip-Path:', resp.getheader('x-zip-path')
print('Found', resp.getheader('location'), 'X-Zip-Path:', resp.getheader('x-zip-path'), file=stderr)

assert resp.status in range(300, 399), (resp.status, resp.read())

Expand All @@ -67,7 +67,7 @@ def datasource(lat, lon, source_dir):
#
# Get the real zip archive
#
print >> stderr, 'Getting', zip_location
print('Getting', zip_location, file=stderr)

s, host, path, p, q, f = urlparse(zip_location)

Expand All @@ -90,13 +90,13 @@ def datasource(lat, lon, source_dir):
#
# Write the actual DEM
#
print >> stderr, 'Extracting', zip_filepath, 'to', dem_path
print('Extracting', zip_filepath, 'to', dem_path, file=stderr)

dem_file = open(dem_path, 'w')
dem_file.write(zipfile.read(zip_filepath))
dem_file.close()

chmod(dem_path, 0666)
chmod(dem_path, 0o666)

finally:
unlink(zip_path)
Expand Down
4 changes: 2 additions & 2 deletions Hillup/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from tempfile import mkstemp
from sys import modules

import NED10m, NED100m, NED1km, SRTM1, SRTM3, VFP, Worldwide
from . import NED10m, NED100m, NED1km, SRTM1, SRTM3, VFP, Worldwide

from ModestMaps.Core import Coordinate
from TileStache.Geography import SphericalMercator
Expand Down Expand Up @@ -299,7 +299,7 @@ def calculate_slope_aspect(elevation, xres, yres, z=1.0):

window = [z * elevation[row:(row + height), col:(col + width)]
for (row, col)
in product(range(3), range(3))]
in product(list(range(3)), list(range(3)))]

x = ((window[0] + window[3] + window[3] + window[6]) \
- (window[2] + window[5] + window[5] + window[8])) \
Expand Down
6 changes: 3 additions & 3 deletions Hillup/tiles.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from math import pi, log
from tempfile import mkstemp
from os import close, write, remove
from urlparse import urljoin, urlparse
from urllib.parse import urljoin, urlparse
from os.path import join, exists
from urllib import urlopen
from urllib.request import urlopen

from TileStache.Geography import SphericalMercator

Expand Down Expand Up @@ -94,7 +94,7 @@ def render_tile(source_dir, coord, min_zoom):
ul = original.zoomTo(coord.zoom).left(coord.column).up(coord.row)
lr = original.down().right().zoomTo(coord.zoom).left(coord.column).up(coord.row)

left, top, right, bottom = map(int, (ul.column * w, ul.row * h, lr.column * w, lr.row * h))
left, top, right, bottom = list(map(int, (ul.column * w, ul.row * h, lr.column * w, lr.row * h)))

shaded = shaded[top:bottom, left:right]

Expand Down
4 changes: 2 additions & 2 deletions hillup-seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def generateCoordinates(ul, lr, zooms, padding):

# read out zooms, columns, rows
zxys = [line.strip().split('/') for line in open(options.tile_list)]
coords = [Coordinate(*map(int, (y, x, z))) for (z, x, y) in zxys]
coords = [Coordinate(*list(map(int, (y, x, z)))) for (z, x, y) in zxys]
tiles = [(i, len(coords), coord) for (i, coord) in enumerate(coords)]

else:
Expand Down Expand Up @@ -117,4 +117,4 @@ def generateCoordinates(ul, lr, zooms, padding):

mimetype, content = getTile(layer, coord, 'TIFF', True)

print coord
print(coord)