Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jan 27, 2017
1 parent a0022fa commit 6a02717
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 7 additions & 0 deletions tilecloud_chain/format.py
@@ -1,6 +1,13 @@
# -*- coding: utf-8 -*-


def default_int(number_array):
return [
int(n) if n % 1 == 0 else n
for n in number_array
]


def size_format(number):
for unit in ['o', 'Kio', 'Mio', 'Gio', 'Tio']:
if number < 1024.0:
Expand Down
6 changes: 3 additions & 3 deletions tilecloud_chain/generate.py
Expand Up @@ -21,7 +21,7 @@

from tilecloud_chain import TileGeneration, HashDropper, HashLogger, DropEmpty, TilesFileStore, \
add_comon_options, parse_tilecoord, quote, Count
from tilecloud_chain.format import size_format, duration_format
from tilecloud_chain.format import size_format, duration_format, default_int

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -58,8 +58,8 @@ def _gene(self, options, gene, layer, dimensions=None):
if options.get_bbox:
try:
tilecoord = parse_tilecoord(options.get_bbox)
print("Tile bounds: [{:.2f},{:.2f},{:.2f},{:.2f}]".format(
*gene.layer['grid_ref']['obj'].extent(tilecoord)
print("Tile bounds: [{},{},{},{}]".format(
*default_int(gene.layer['grid_ref']['obj'].extent(tilecoord))
))
exit()
except ValueError as e: # pragma: no cover
Expand Down
6 changes: 3 additions & 3 deletions tilecloud_chain/tests/test_generate.py
Expand Up @@ -66,19 +66,19 @@ def test_get_bbox(self, l):
cmd='.build/venv/bin/generate_tiles {} '
'-c tilegeneration/test.yaml --get-bbox 4/4/4 -l point'.format(d),
main_func=generate.main,
expected="""Tile bounds: [425120.00,343600.00,426400.00,344880.00]
expected="""Tile bounds: [425120,343600,426400,344880]
""")
self.assert_cmd_equals(
cmd='.build/venv/bin/generate_tiles {} '
'-c tilegeneration/test.yaml --get-bbox 4/4/4:+1/+1 -l point'.format(d),
main_func=generate.main,
expected="""Tile bounds: [425120.00,343600.00,426400.00,344880.00]
expected="""Tile bounds: [425120,343600,426400,344880]
""")
self.assert_cmd_equals(
cmd='.build/venv/bin/generate_tiles {} '
'-c tilegeneration/test.yaml --get-bbox 4/4/4:+2/+2 -l point'.format(d),
main_func=generate.main,
expected="""Tile bounds: [425120.00,342320.00,427680.00,344880.00]
expected="""Tile bounds: [425120,342320,427680,344880]
""")
l.check()

Expand Down

0 comments on commit 6a02717

Please sign in to comment.