import { mapaH, mapaW } from "odi-utils/constants" export function transform(lonlat){ const earth_radius_km = 6378.1370 return earth_radius_km*(lonlat)*Math.PI/180 } export function limits(type){ const inferior={lon:-81.324216, lat: -18.345605} const superior={lon:-68.654087, lat:-0.043656} if (type == 'x'){ return [transform(inferior.lon), transform(superior.lon)] } return [transform(inferior.lat),transform(superior.lat)] } //inicio de mapa en x = 13 y = 33 export function getX (lon){ const [infx, supx] = limits('x'); const imgW = mapaW const inicioX= -3 const Fx = Math.abs(infx) - Math.abs(supx) const xPrev = transform(lon) const newX = Math.abs(infx) - Math.abs(xPrev) const x = Math.trunc((Math.abs(newX)*(imgW))/(Fx)) console.log("x: ", x + 0) return x + inicioX; } export function getY (lat){ const [ infy, supy] = limits('y'); const imgH = mapaH const inicioY = -8 const Fy = Math.abs(infy) - Math.abs(supy) const yPrev = transform(lat) const newY = Math.abs(yPrev) - Math.abs(supy) const y = Math.trunc((Math.abs(newY)*(imgH))/(Fy)) console.log("y: ", y +0) return y + inicioY }