Skip to content

Commit

Permalink
【fix】兼容轴方向是ne*的投影坐标转换后得到的坐标是y,x的情况 review by xiongjj
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed May 7, 2020
1 parent 8ed2e3f commit 1dd5b98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 10 additions & 9 deletions static/libs/json-sql/jsonsql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1dd5b98

Please sign in to comment.