Skip to content

Commit

Permalink
Merge branch 'master' of github.com:interline-io/planetutils
Browse files Browse the repository at this point in the history
  • Loading branch information
drewda committed Dec 7, 2018
2 parents 1d4dc1e + ab7153e commit da21fff
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions planetutils/elevation_tile_download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import, unicode_literals, print_function
import argparse
import sys

Expand All @@ -26,7 +26,7 @@ def main():
elif args.format == 'skadi':
p = ElevationSkadiDownloader(args.outpath)
else:
print "Unknown format: %s"%args.format
print("Unknown format: %s"%args.format)
sys.exit(1)

if args.csv:
Expand Down
2 changes: 1 addition & 1 deletion planetutils/elevation_tile_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_bbox_tiles(self, bbox):
return tiles

def tile_path(self, z, x, y):
return map(str, [z, x, str(y)+'.tif'])
return list(map(str, [z, x, str(y)+'.tif']))

class ElevationSkadiDownloader(ElevationDownloader):
HGT_SIZE = (3601 * 3601 * 2)
Expand Down
14 changes: 7 additions & 7 deletions planetutils/elevation_tile_merge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import, unicode_literals, print_function
import argparse
import sys
import fnmatch
Expand All @@ -20,7 +20,7 @@ def main():
tmppath = args.outpath

if args.scale and len(args.scale.split(',')) != 2:
print "Must provide min, max values"
print("Must provide min, max values")
sys.exit(1)
elif args.scale:
# Output to tmp file
Expand All @@ -32,22 +32,22 @@ def main():
matches.append(os.path.join(root, filename))

if len(matches) == 0:
print "No input files"
print("No input files")
sys.exit(0)

print "Found %s files:"%len(matches)
print("Found %s files:"%len(matches))
for i in matches:
print "\t%s"%(i)
print("\t%s"%(i))

# gdal_merge.py -init 0 -o out.tif
print "Merging... %s"%(tmppath)
print("Merging... %s"%(tmppath))
cmd = ['gdal_merge.py', '-init', '0', '-o', tmppath]
cmd += matches
p = subprocess.check_call(cmd)

# gdal_translate -of GTiff -ot Byte -scale 0 255 0 255 out.tif out8.tif
if args.scale:
print "Scaling: %s -> %s"%(tmppath, outpath)
print("Scaling: %s -> %s"%(tmppath, outpath))
a = args.scale.split(",")
cmd = ['gdal_translate', '-of', 'GTiff', '-ot', 'Byte', '-scale', a[0], a[1], '0', '255', tmppath, outpath]
subprocess.check_call(cmd)
Expand Down
1 change: 0 additions & 1 deletion planetutils/tilepack_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import argparse

from . import log
from . import tilepack
from .bbox import bbox_string, load_bboxes_csv
from .tilepack_downloader import TilepackDownloader

Expand Down
2 changes: 0 additions & 2 deletions planetutils/tilepack_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from urllib.request import urlopen

import os
import urlparse
import subprocess
import json


from . import log
from . import download

Expand Down
21 changes: 21 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import absolute_import, unicode_literals
import tempfile
import types
import os
import unittest

class TestCommandImports(unittest.TestCase):
def test_command_imports(self):
commands = [
'osm_planet_update=planetutils.osm_planet_update:main',
'osm_planet_extract=planetutils.osm_planet_extract:main',
'osm_planet_get_timestamp=planetutils.osm_planet_get_timestamp:main',
'osm_extract_download=planetutils.osm_extract_download:main',
'elevation_tile_download=planetutils.elevation_tile_download:main',
'elevation_tile_merge=planetutils.elevation_tile_merge:main',
'valhalla_tilepack_download=planetutils.tilepack_download:main',
'valhalla_tilepack_list=planetutils.tilepack_list:main'
]
for i in commands:
a, _, b = i.partition('=')[-1].partition(':')
exec('import %s'%(a))

0 comments on commit da21fff

Please sign in to comment.