From 1dd5b98266b68ff6f6fe26b845de7e38ef924fff Mon Sep 17 00:00:00 2001 From: songyumeng Date: Thu, 7 May 2020 09:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=E3=80=91=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E8=BD=B4=E6=96=B9=E5=90=91=E6=98=AFne*=E7=9A=84=E6=8A=95?= =?UTF-8?q?=E5=BD=B1=E5=9D=90=E6=A0=87=E8=BD=AC=E6=8D=A2=E5=90=8E=E5=BE=97?= =?UTF-8?q?=E5=88=B0=E7=9A=84=E5=9D=90=E6=A0=87=E6=98=AFy,x=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=20=20review=20by=20xiongjj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mapboxgl/web-map/WebMapViewModel.ts | 7 ++++++- static/libs/json-sql/jsonsql.js | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/mapboxgl/web-map/WebMapViewModel.ts b/src/mapboxgl/web-map/WebMapViewModel.ts index ceccbc50..c2e2733a 100644 --- a/src/mapboxgl/web-map/WebMapViewModel.ts +++ b/src/mapboxgl/web-map/WebMapViewModel.ts @@ -1685,7 +1685,12 @@ export default class WebMapViewModel extends WebMapBase { return point; } // @ts-ignore - return proj4(sourceProjection, 'EPSG:4326', point); + const coor = proj4(sourceProjection, 'EPSG:4326', point); + const proj = proj4.defs(sourceProjection); + if (proj.axis && proj.axis.indexOf('ne') === 0) { + coor.reverse(); + } + return coor; } private _getMapCenter(mapInfo) { diff --git a/static/libs/json-sql/jsonsql.js b/static/libs/json-sql/jsonsql.js index e54888d6..3f739d53 100644 --- a/static/libs/json-sql/jsonsql.js +++ b/static/libs/json-sql/jsonsql.js @@ -63,22 +63,23 @@ window.jsonsql = { // } // } // fix with -- stric mode - if (this.functionreplaceWith(jsonsql_scope[jsonsql_i], jsonsql_o.where)) { + if (this.functionWith(jsonsql_scope[jsonsql_i], jsonsql_o.where)) { jsonsql_result[jsonsql_rc++] = this.returnFields(jsonsql_scope[jsonsql_i], jsonsql_o.fields); } } return jsonsql_result; }, + functionWith(scope, exp) { + if (!scope) return; - functionreplaceWith: function(scope, exp) { - exp = ' ' + exp.trim(); - let quickRegex = /([\s\+\-\*\/%&\|\^!\*~]\s*?)([a-zA-Z_$][a-zA-Z_$0-9]*?)/g; - exp = exp.replace(quickRegex, (a, b, c) => { - return b + 'scope.' + c; - }); - let func = new Function('scope', 'return ' + exp); - return func(scope); + var resetArgs = ''; + for (var key in scope) { + resetArgs = resetArgs + 'var ' + key + ' = _$_$_functionWith["' + key + '"];'; + } + var nf = new Function('_$_$_functionWith', resetArgs + 'return ' + exp); + + return nf(scope); }, returnFields: function(scope, fields) {