mistercrunch commented on a change in pull request #4134: [Geo] Added DeckGL
Arc Layer
URL:
https://github.com/apache/incubator-superset/pull/4134#discussion_r159558458
##########
File path: superset/viz.py
##########
@@ -1818,6 +1818,58 @@ def get_position(self, d):
d.get('lat'),
]
+ def process_spatial_query_obj(self, spatial_key):
+ fd = self.form_data
+ gb = []
+ spatial = fd.get(spatial_key)
+
+ if spatial is None:
+ raise Exception(_('Bad spatial key'))
+
+ if spatial.get('type') == 'latlong':
+ gb += [spatial.get('lonCol')]
+ gb += [spatial.get('latCol')]
+ elif spatial.get('type') == 'delimited':
+ gb += [spatial.get('lonlatCol')]
+ elif spatial.get('type') == 'geohash':
+ gb += [spatial.get('geohashCol')]
+
+ return gb
+
+ def process_spatial_data_obj(self, df, spatial_key):
+ fd = self.form_data
+ spatial = fd.get(spatial_key)
+ if spatial is None:
+ raise Exception(_('Bad spatial key'))
+
+ 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])
Review comment:
Idea: it may be less complex overall to simply store the lat/long as a tuple
in a single column
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services