Make proj4 transforms behave like built-in transforms
This commit is contained in:
+16
-11
@@ -410,17 +410,22 @@ export function toStringXY(coordinate, opt_fractionDigits) {
|
||||
* @return {Coordinate} The coordinate within the real world extent.
|
||||
*/
|
||||
export function wrapX(coordinate, projection) {
|
||||
const projectionExtent = projection.getExtent();
|
||||
if (
|
||||
projection.canWrapX() &&
|
||||
(coordinate[0] < projectionExtent[0] ||
|
||||
coordinate[0] >= projectionExtent[2])
|
||||
) {
|
||||
const worldWidth = getWidth(projectionExtent);
|
||||
const worldsAway = Math.floor(
|
||||
(coordinate[0] - projectionExtent[0]) / worldWidth
|
||||
);
|
||||
coordinate[0] -= worldsAway * worldWidth;
|
||||
const worldsAway = getWorldsAway(coordinate, projection);
|
||||
if (worldsAway) {
|
||||
coordinate[0] -= worldsAway * getWidth(projection.getExtent());
|
||||
}
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
export function getWorldsAway(coordinate, projection) {
|
||||
const projectionExtent = projection.getExtent();
|
||||
let worldsAway = 0;
|
||||
if (
|
||||
projection.canWrapX() &&
|
||||
(coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])
|
||||
) {
|
||||
const worldWidth = getWidth(projectionExtent);
|
||||
worldsAway = Math.floor((coordinate[0] - projectionExtent[0]) / worldWidth);
|
||||
}
|
||||
return worldsAway;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user