summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js
blob: bac5f9bfeca0b935253a665673a73357ea8e2a13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
 }