mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
Added guard statement for spatial controls (#4124)
This commit is contained in:
parent
45686a1af6
commit
b227612f6e
@ -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'):
|
||||
|
Loading…
Reference in New Issue
Block a user