summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/containers/Odipar/Simulacion
diff options
context:
space:
mode:
authorDayana31 <[email protected]>2022-06-03 17:24:38 -0500
committerDayana31 <[email protected]>2022-06-03 17:24:38 -0500
commitf4435233c0aad92f63ee097831565875a6dc903c (patch)
treefb3460742efd381958c1715dd9908597bd7b3e2f /front/odiparpack/app/containers/Odipar/Simulacion
parentc4afbde59b708505803094724632774ffb35ee74 (diff)
parent7494e99f73c3aa28f7caf8b6b0c063a0cb6035cf (diff)
downloadDP1_project-f4435233c0aad92f63ee097831565875a6dc903c.tar.gz
DP1_project-f4435233c0aad92f63ee097831565875a6dc903c.tar.bz2
DP1_project-f4435233c0aad92f63ee097831565875a6dc903c.zip
Merge branch 'gabshr' into dayana
Diffstat (limited to 'front/odiparpack/app/containers/Odipar/Simulacion')
-rw-r--r--front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js85
-rw-r--r--front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js96
-rw-r--r--front/odiparpack/app/containers/Odipar/Simulacion/utilCoords.js42
3 files changed, 223 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..97bcf5b
--- /dev/null
+++ b/front/odiparpack/app/containers/Odipar/Simulacion/Simulacion7Dias.js
@@ -0,0 +1,85 @@
+import React, { Component } from "react";
+import { withStyles } from '@material-ui/core/styles';
+import {getX, getY} from './utilCoords'
+import { Icon, Typography } 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 (
+ <>
+ <Typography variant="h4">
+ {`Resultado de simulación a 7 días`}
+ </Typography>
+ <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/SimulacionMain.js b/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js
new file mode 100644
index 0000000..616fab8
--- /dev/null
+++ b/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js
@@ -0,0 +1,96 @@
+import React, {Component} from "react";
+import { Button, Divider, FormControl, Grid, InputLabel, MenuItem, Paper, Select, Typography } from "@material-ui/core";
+import { withStyles } from '@material-ui/core/styles';
+import { Field, reduxForm } from "redux-form";
+import { SelectRedux } from 'ba-components/Forms/ReduxFormMUI';
+
+const styles = ({
+ root: {
+ flexGrow: 1,
+ marginTop: 30,
+ padding: 20
+ },
+ field: {
+ width: '70%',
+ marginBottom: 20
+ }
+ });
+
+ const initData = {
+ selection: 'option1',
+ };
+
+class SimulacionMain extends Component {
+ state = {
+ tipo:''
+ }
+
+ changeTipo(tipo){
+ this.setState({tipo: tipo})
+ }
+
+ handleChange = event => {
+ this.setState({ [event.target.name]: event.target.value });
+ };
+
+ render() {
+ const trueBool = true;
+ const { classes } = this.props;
+ return (
+ <div>
+ <Typography variant="h4">
+ {`Simulación`}
+ </Typography>
+ <div>
+ <Paper className={classes.root}>
+ <Grid container>
+ <Grid item xs={12} sm={5} >
+ <Typography variant="h6">
+ {`Datos generales`}
+ </Typography>
+ <form>
+ <div>
+ <FormControl className={classes.field}>
+ <InputLabel htmlFor="selection">Tipo de simulación</InputLabel>
+ <Select
+ inputProps={{
+ name: 'tipo',
+ id: 'tipoid',
+ }}
+ value={initData.selection}
+ onChange={this.handleChange}
+ placeholder="Seleccionar"
+ autoWidth={trueBool}
+ >
+ <MenuItem value = "option1" >Simulación a 7 días</MenuItem>
+ <MenuItem value="option2" >Simulación a colapso</MenuItem>
+ </Select>
+ </FormControl>
+ </div>
+
+ <div>
+ <Button variant="contained" color="secondary">
+ Iniciar Simulación
+ </Button>
+ </div>
+ </form>
+ </Grid>
+ <Divider variant="inset" style={{color:'black'}}/>
+ <Grid item xs={12} sm={7}>
+ <Typography variant="h6">
+ {`Pedidos`}
+ </Typography>
+ </Grid>
+ </Grid>
+ </Paper>
+ </div>
+ </div>
+ );
+ }
+}
+
+const SimulacionMainMapped = reduxForm({
+ form: 'immutableExample',
+ })(SimulacionMain);
+
+export default withStyles(styles)(SimulacionMainMapped); \ 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