Added guard statement for spatial controls (#4124)

This commit is contained in:
Hugh A. Miles II 2017-12-26 12:27:27 -08:00 committed by Maxime Beauchemin
parent 45686a1af6
commit b227612f6e

View File

@ -1848,26 +1848,27 @@ class BaseDeckGLViz(BaseViz):
def get_data(self, df):
fd = self.form_data
spatial = fd.get('spatial')
if spatial.get('type') == 'latlong':
df = df.rename(columns={
spatial.get('lonCol'): 'lon',
spatial.get('latCol'): 'lat'})
elif spatial.get('type') == 'delimited':
cols = ['lon', 'lat']
if spatial.get('reverseCheckbox'):
cols.reverse()
df[cols] = (
df[spatial.get('lonlatCol')]
.str
.split(spatial.get('delimiter'), expand=True)
.astype(np.float64)
)
del df[spatial.get('lonlatCol')]
elif spatial.get('type') == 'geohash':
latlong = df[spatial.get('geohashCol')].map(geohash.decode)
df['lat'] = latlong.apply(lambda x: x[0])
df['lon'] = latlong.apply(lambda x: x[1])
del df['geohash']
if spatial:
if spatial.get('type') == 'latlong':
df = df.rename(columns={
spatial.get('lonCol'): 'lon',
spatial.get('latCol'): 'lat'})
elif spatial.get('type') == 'delimited':
cols = ['lon', 'lat']
if spatial.get('reverseCheckbox'):
cols.reverse()
df[cols] = (
df[spatial.get('lonlatCol')]
.str
.split(spatial.get('delimiter'), expand=True)
.astype(np.float64)
)
del df[spatial.get('lonlatCol')]
elif spatial.get('type') == 'geohash':
latlong = df[spatial.get('geohashCol')].map(geohash.decode)
df['lat'] = latlong.apply(lambda x: x[0])
df['lon'] = latlong.apply(lambda x: x[1])
del df['geohash']
features = []
for d in df.to_dict(orient='records'):