Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue with affine transforms #1073

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var maxTransformCacheSize = 10;
/* A RegExp to detect if two transforms only different by the middle axis's
* direction. */
var axisPattern = new RegExp('^(.* |)\\+axis=e(n|s)u(| .*)$');
var affinePattern = new RegExp(/(^|\s)\+(s[1-3][1-3]|[xyz]off)=\S/);

/**
* This purpose of this class is to provide a generic interface for computing
Expand Down Expand Up @@ -101,7 +102,7 @@ var transform = function (options) {
* value is the proj4 string with the affine parameters removed.
*/
function parse_projection(value) {
if (!/(^|\s)\+(s[1-3][1-3]|[xyz]off)=\S/.exec(value)) {
if (!affinePattern.exec(value)) {
return {proj: value};
}
var mat = util.mat4AsArray(),
Expand Down Expand Up @@ -342,7 +343,7 @@ transform.transformCoordinates = function (srcPrj, tgtPrj, coordinates, numberOf
return coordinates;
}

if (Array.isArray(coordinates) && coordinates.length >= 3 && numberOfComponents === 3 && !util.isObject(coordinates[0])) {
if (Array.isArray(coordinates) && coordinates.length >= 3 && numberOfComponents === 3 && !util.isObject(coordinates[0]) && !affinePattern.test(srcPrj) && !affinePattern.test(tgtPrj)) {
return transform.transformCoordinatesFlatArray3(srcPrj, tgtPrj, coordinates);
}
if (Array.isArray(coordinates) && coordinates.length && util.isObject(coordinates[0]) && 'x' in coordinates[0] && 'y' in coordinates[0]) {
Expand Down