diff options
| author | gabrhr <[email protected]> | 2022-06-02 23:10:42 -0500 |
|---|---|---|
| committer | gabrhr <[email protected]> | 2022-06-02 23:10:42 -0500 |
| commit | 1f7786a50303d49f54fa713b540b176131faf971 (patch) | |
| tree | 645190c8edf491ebe54dcf909f16d6982a5ae9ec /front/odiparpack/app/containers/Odipar | |
| parent | 77fb39778fc4ebb3eea9e9801320efe1a4878c9a (diff) | |
| download | DP1_project-1f7786a50303d49f54fa713b540b176131faf971.tar.gz DP1_project-1f7786a50303d49f54fa713b540b176131faf971.tar.bz2 DP1_project-1f7786a50303d49f54fa713b540b176131faf971.zip | |
Add mapa v1
- Mapa con algunos punto
- Zoom al mapa xdddd
- Punto que se mueve
#TODO
- añadir todos los puntos
- Mejorar el path del punto con funcion
- añadir tiempos segun distancia
- estetica al final (camion, colores, etc)
Diffstat (limited to 'front/odiparpack/app/containers/Odipar')
| -rw-r--r-- | front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js | 81 | ||||
| -rw-r--r-- | front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js | 42 |
2 files changed, 123 insertions, 0 deletions
diff --git a/front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js b/front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js new file mode 100644 index 0000000..eff6d5d --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js @@ -0,0 +1,81 @@ +import React, { Component } from "react"; +import { withStyles } from '@material-ui/core/styles'; +import {getX, getY} from './utilCoords' +import { Icon } from "@material-ui/core"; +import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; +import { mapaH, mapaW } from "odi-utils/constants" + +const styles = ({ + root: { + flexGrow: 1, + marginTop: 30, + } + }); + + +class Simulacion7Dias extends Component { + almacenes = [ + { + ubigeo: '150101', + provincia: 'LIMA', + latitud:-12.04591952, + longitud: -77.03049615, + region: 'Costa', + esPrincipal: 1 + },{ + ubigeo: '130101', + provincia: 'TRUJILLO', + latitud: -8.11176389, + longitud: -79.02868652, + region: 'Costa', + esPrincipal: 1 + },{ + ubigeo: '040101', + provincia: 'AREQUIPA', + latitud:-16.39881421, + longitud: -71.537019649, + region: 'Costa', + esPrincipal: 1 + },{ + ubigeo: '050301', + provincia: 'HUANCA SANCOS', + latitud:-13.91988366, + longitud: -74.33388289, + region: 'Costa', + esPrincipal: 0 + } + ] + render() { + return ( + <TransformWrapper + defaultScale={1} + maxScale={1.8} + defaultPositionX={200} + defaultPositionY={100} + > + <TransformComponent> + <div> + <img src={require("../../../../public/images/mapaM.png")}/> + {this.almacenes.map((item,index) => { + console.log(index) + return <div style={{ position: 'absolute', left:`${getX(item.longitud)}px`, top: `${getY(item.latitud)}px`, color:"black"}}> + <Icon style={item.esPrincipal==1? {color:'blue', fontSize:18}:{color:'black', fontSize:15}}>house</Icon> + </div> + })} + </div> + <svg width={mapaW} height={mapaH} style={{position: 'absolute', left: '14px' , top: '34px'}}> + <path fill="none" stroke="red" + d="M 160 437, L 82 283, L 376 600" /> + <circle r="5" fill="red"> + <animateMotion dur="10s" repeatCount={1} + path="M 163 437, L 85 283, L 378 600"/> + </circle> + </svg> + </TransformComponent> + </TransformWrapper> + + ); + } +} + +export default withStyles(styles)(Simulacion7Dias);
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js b/front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js new file mode 100644 index 0000000..bac5f9b --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js @@ -0,0 +1,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 + }
\ No newline at end of file |
