Skip to content

Commit

Permalink
Return None if user does not select a projection
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyBYU committed May 2, 2018
1 parent 28d0bb8 commit 4f06fe6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ def getProjection(lat, lon):
lat {number} -- origin latitude
lon {number} -- origin longitude
"""
# Attempt to import AllProjection module
# Attempt to import GeneralProjection module
# Will fail if dependencies not installed
try:
from projection import GeneralProjection
log.info('Returning requested GeneralProjection')

srid = bpy.context.scene.bpyproj.srid
proj_params = bpy.context.scene.bpyproj.proj_params
# srid and proj4 params are blank, return None
if not srid and not proj_params:
log.info('No projection selected by user. Returning None to calling function')
return None
# Ensure that proj params are not set if user selects SRID
if bpy.context.scene.bpyproj.proj_type == 'srid':
proj_params = ''

log.info('Returning requested GeneralProjection')
return GeneralProjection(srid=srid, proj_params=proj_params, lat=lat, lon=lon)
except Exception as e:
log.error(
Expand Down Expand Up @@ -114,7 +119,7 @@ class PyprojProperties(bpy.types.PropertyGroup):
srid = bpy.props.StringProperty(
name="SRID",
description="Spatial Reference System ID (e.g. EPSG:3857)",
default='EPSG:3857'
default=''
)
proj_params = bpy.props.StringProperty(
name="Proj4 Parameters",
Expand Down

0 comments on commit 4f06fe6

Please sign in to comment.