You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2017/12/26 20:08:36 UTC

[GitHub] hughhhh closed pull request #4123: [Geo] Guard on spatial obj in form_data

hughhhh closed pull request #4123: [Geo] Guard on spatial obj in form_data
URL: https://github.com/apache/incubator-superset/pull/4123
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/viz.py b/superset/viz.py
index bb052d17ab..e649456de1 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1848,26 +1848,27 @@ def query_obj(self):
     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'):


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services