check projection can wrap before getting width

This commit is contained in:
mike-000
2020-07-30 12:24:03 +01:00
committed by GitHub
parent ba41100799
commit 39334fa95d
+2
View File
@@ -410,11 +410,13 @@ export function toStringXY(coordinate, opt_fractionDigits) {
* @return {Coordinate} The coordinate within the real world extent. * @return {Coordinate} The coordinate within the real world extent.
*/ */
export function wrapX(coordinate, projection) { export function wrapX(coordinate, projection) {
if (projection.canWrapX()) {
const worldWidth = getWidth(projection.getExtent()); const worldWidth = getWidth(projection.getExtent());
const worldsAway = getWorldsAway(coordinate, projection, worldWidth); const worldsAway = getWorldsAway(coordinate, projection, worldWidth);
if (worldsAway) { if (worldsAway) {
coordinate[0] -= worldsAway * worldWidth; coordinate[0] -= worldsAway * worldWidth;
} }
}
return coordinate; return coordinate;
} }
/** /**