/* eslint-disable no-debugger */ /* eslint-disable prefer-destructuring */ class CoordTrans { constructor(imgBound, geoBound) { this._ix0 = imgBound[0]; this._iy0 = imgBound[1]; this._gx0 = geoBound[0]; this._gy0 = geoBound[3]; this._sx = (imgBound[2] - imgBound[0]) / (geoBound[2] - geoBound[0]); this._sy = (imgBound[1] - imgBound[3]) / (geoBound[3] - geoBound[1]); } geo2imgX(val) { return parseInt(this._ix0 + ((val - this._gx0) * this._sx) + 0.5, 10); } geo2imgY(val) { return parseInt(this._iy0 + ((val - this._gy0) * this._sy) + 0.5, 10); } } export default CoordTrans;