You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/06/22 01:11:34 UTC

[GitHub] mistercrunch closed pull request #4460: [bugfix] allow reversing geohash, disregard invalid

mistercrunch closed pull request #4460: [bugfix] allow reversing geohash, disregard invalid
URL: https://github.com/apache/incubator-superset/pull/4460
 
 
   

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/assets/javascripts/explore/components/controls/SpatialControl.jsx b/superset/assets/javascripts/explore/components/controls/SpatialControl.jsx
index d9db801c4b..585430f5cd 100644
--- a/superset/assets/javascripts/explore/components/controls/SpatialControl.jsx
+++ b/superset/assets/javascripts/explore/components/controls/SpatialControl.jsx
@@ -75,6 +75,7 @@ export default class SpatialControl extends React.Component {
       }
     } else if (type === spatialTypes.geohash) {
       value.geohashCol = this.state.geohashCol;
+      value.reverseCheckbox = this.state.reverseCheckbox;
       if (!value.geohashCol) {
         errors.push(errMsg);
       }
@@ -169,6 +170,10 @@ export default class SpatialControl extends React.Component {
                 Column
                 {this.renderSelect('geohashCol', spatialTypes.geohash)}
               </Col>
+              <Col md={6}>
+                {t('Reverse lat/long ')}
+                <Checkbox checked={this.state.reverseCheckbox} onChange={this.toggleCheckbox} />
+              </Col>
             </Row>
           </PopoverSection>
           <div className="clearfix">
diff --git a/superset/assets/visualizations/deckgl/layers/common.js b/superset/assets/visualizations/deckgl/layers/common.js
index 7a2cb9785d..3503c98f33 100644
--- a/superset/assets/visualizations/deckgl/layers/common.js
+++ b/superset/assets/visualizations/deckgl/layers/common.js
@@ -4,8 +4,8 @@ import { fitBounds } from 'viewport-mercator-project';
 import sandboxedEval from '../../../javascripts/modules/sandbox';
 
 export function getBounds(points) {
-  const latExt = d3.extent(points, d => d[1]);
-  const lngExt = d3.extent(points, d => d[0]);
+  const latExt = d3.extent(points, d => d[1] ? d[1] : null);
+  const lngExt = d3.extent(points, d => d[0] ? d[0] : null);
   return [
     [lngExt[0], latExt[0]],
     [lngExt[1], latExt[1]],
diff --git a/superset/viz.py b/superset/viz.py
index c1a8d9aa0d..9924c46aaf 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1949,17 +1949,23 @@ def tupleify(s):
 
             df[key] = df[spatial.get('lonlatCol')].apply(tupleify)
 
-            if spatial.get('reverseCheckbox'):
-                df[key] = [
-                    tuple(reversed(o)) if isinstance(o, (list, tuple)) else (0, 0)
-                    for o in df[key]
-                ]
             del df[spatial.get('lonlatCol')]
         elif spatial.get('type') == 'geohash':
-            latlong = df[spatial.get('geohashCol')].map(geohash.decode)
+            def try_geohash(h):
+                try:
+                    latlng = geohash.decode(h)
+                except Exception as e:
+                    latlng = (0, 0)
+                return latlng
+            latlong = df[spatial.get('geohashCol')].map(try_geohash)
             df[key] = list(zip(latlong.apply(lambda x: x[0]),
                                latlong.apply(lambda x: x[1])))
             del df[spatial.get('geohashCol')]
+        if spatial.get('reverseCheckbox'):
+            df[key] = [
+                tuple(reversed(o)) if isinstance(o, (list, tuple)) else (0, 0)
+                for o in df[key]
+            ]
         return df
 
     def query_obj(self):


 

----------------------------------------------------------------
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

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org