Skip to content

Commit b2266f4

Browse files
[fix]webmap原点对比分辨率对比小数问题
1 parent 7f06572 commit b2266f4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/common/mapping/WebMapV2.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,17 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
705705
}
706706
return this._isSameOrigin(origin) && this._isSameResolutions(resolutions, tileSize);
707707
}
708+
numberEqual(num1, num2, precision = 10E-6) {
709+
return Math.abs(+num1 - +num2) <= precision;
710+
}
708711
_isSameOrigin(origin) {
709712
const extent = this.map.getCRS().getExtent();
710-
return origin[0].toFixed(2) === extent[0].toFixed(2) && origin[1].toFixed(2) === extent[3].toFixed(2);
713+
return this.numberEqual(origin[0], extent[0]) && this.numberEqual(origin[1], extent[3]);
711714
}
712715
_isSameResolutions(resolutions, tileSize, mapTileSize = 512) {
713716
const mapResolutions = this._getMapResolutions();
714717
const conversion = mapTileSize / tileSize;
715-
return resolutions.every((item, i) => (item).toFixed(6) === (conversion * mapResolutions[i]).toFixed(6));
718+
return resolutions.every((item, i) => this.numberEqual(item, conversion * mapResolutions[i]));
716719
}
717720
_getMapResolutions() {
718721
return this._getResolutionsByExtent({extent: this.map.getCRS().getExtent(), tileSize: 512})

0 commit comments

Comments
 (0)