Skip to content

Commit

Permalink
tweak cli arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
fitnr committed Dec 1, 2017
1 parent 0117c81 commit bfe4729
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions svgis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ def scale(layer, output, **kwargs):


@main.command()
@click.argument('layer', default=sys.stdin, type=click.Path(exists=True))
@click.argument('layer', type=click.Path(allow_dash=True, exists=True))
@click.option('-j', '--crs', type=str, metavar='KEYWORD', default='file', help=crs_help + ' (default: file)')
@click.option('--latlon', default=False, flag_value=True, help='Print bounds in latitude, longitude order')
def bounds(layer, crs, latlon=False):
'''Return the bounds for a given layer, optionally projected.'''
'''
Return the bounds for a given layer, optionally projected.
Use - for stdin.
'''
meta = meta_complete(layer)

# If crs==file, these will basically be no ops.
Expand Down Expand Up @@ -178,7 +182,7 @@ def draw(layer, output, **kwargs):

# Proj
@main.command()
@click.argument('bounds', nargs=-1, type=float, metavar="minx miny maxx maxy | x y", default=None)
@click.argument('bounds', nargs=-1, type=float, default=None)
@click.option('-m', '--method', default='local', type=click.Choice(('utm', 'local')), help='Defaults to local')
@click.option('-j', '--crs', default=DEFAULT_GEOID, help='Projection of the bounding coordinates')
def project(bounds, method, crs):
Expand All @@ -190,6 +194,10 @@ def project(bounds, method, crs):
if len(bounds) == 2:
bounds = bounds + bounds

if len(bounds) != 4:
click.echo('Either two or four bounds required', err=True)
return

result = fiona.crs.to_string(projection.pick(method, file_crs=crs, bounds=bounds))
click.echo(result.encode('utf-8'))

Expand Down

0 comments on commit bfe4729

Please sign in to comment.