Skip to content

Commit

Permalink
Give better error messages when we need srs_in
Browse files Browse the repository at this point in the history
  • Loading branch information
autra committed Jan 20, 2020
1 parent bf28341 commit f0419e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ ENV/

# Rope project settings
.ropeproject
.pytest
39 changes: 26 additions & 13 deletions py3dtiles/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
total_memory_MB = int(psutil.virtual_memory().total / (1024 * 1024))


class SrsInMissingException(Exception):
pass


def write_tileset(in_folder, out_folder, octree_metadata, offset, scale, projection, rotation_matrix, include_rgb):
# compute tile transform matrix
if rotation_matrix is None:
Expand Down Expand Up @@ -292,19 +296,23 @@ def init_parser(subparser, str2bool):


def main(args):
return convert(args.files,
outfolder=args.out,
overwrite=args.overwrite,
jobs=args.jobs,
cache_size=args.cache_size,
srs_out=args.srs_out,
srs_in=args.srs_in,
fraction=args.fraction,
benchmark=args.benchmark,
rgb=args.rgb,
graph=args.graph,
color_scale=args.color_scale,
verbose=args.verbose)
try:
return convert(args.files,
outfolder=args.out,
overwrite=args.overwrite,
jobs=args.jobs,
cache_size=args.cache_size,
srs_out=args.srs_out,
srs_in=args.srs_in,
fraction=args.fraction,
benchmark=args.benchmark,
rgb=args.rgb,
graph=args.graph,
color_scale=args.color_scale,
verbose=args.verbose)
except SrsInMissingException:
print('No SRS information in input files, you should specify it with --srs_in')
sys.exit(1)


def convert(files,
Expand Down Expand Up @@ -349,6 +357,9 @@ def convert(files,
:param color_scale: Force color scale
:type color_scale: float
:raises SrsInMissingException: if py3dtiles couldn't find srs informations in input files and srs_in is not specified
"""

# allow str directly if only one input
Expand Down Expand Up @@ -383,6 +394,8 @@ def convert(files,
p1 = pyproj.Proj(init='epsg:{}'.format(srs_in))
else:
p1 = infos['srs_in']
if srs_in is None:
raise SrsInMissingException('No SRS informations in the provided files')
projection = [p1, p2]

bl = np.array(list(pyproj.transform(
Expand Down

0 comments on commit f0419e2

Please sign in to comment.