Transform without axis order in proj4
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
addProjection,
|
||||
get,
|
||||
} from '../proj.js';
|
||||
import {assign} from '../obj.js';
|
||||
import {get as getTransform} from './transforms.js';
|
||||
|
||||
/**
|
||||
@@ -46,10 +47,16 @@ export function register(proj4) {
|
||||
const code2 = projCodes[j];
|
||||
const proj2 = get(code2);
|
||||
if (!getTransform(code1, code2)) {
|
||||
if (proj4.defs[code1] === proj4.defs[code2]) {
|
||||
const def1 = proj4.defs(code1);
|
||||
const def2 = proj4.defs(code2);
|
||||
if (def1 === def2) {
|
||||
addEquivalentProjections([proj1, proj2]);
|
||||
} else {
|
||||
const transform = proj4(code1, code2);
|
||||
// Reset axis because OpenLayers always uses x, y axis order
|
||||
const transform = proj4(
|
||||
assign({}, def1, {axis: undefined}),
|
||||
assign({}, def2, {axis: undefined})
|
||||
);
|
||||
addCoordinateTransforms(
|
||||
proj1,
|
||||
proj2,
|
||||
|
||||
@@ -728,6 +728,20 @@ describe('ol.proj', function () {
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
|
||||
it('does not flip axis order', function () {
|
||||
proj4.defs('enu', '+proj=longlat');
|
||||
proj4.defs('neu', '+proj=longlat +axis=neu');
|
||||
register(proj4);
|
||||
|
||||
const got = transform([1, 2], 'neu', 'enu');
|
||||
expect(got).to.eql([1, 2]);
|
||||
|
||||
delete proj4.defs.enu;
|
||||
delete proj4.defs.neu;
|
||||
clearAllProjections();
|
||||
addCommon();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ol.proj.Projection.prototype.getMetersPerUnit()', function () {
|
||||
|
||||
Reference in New Issue
Block a user