林火预测

songhaibo_branch
1 year ago
parent e20022b1b9
commit 683b157a09

@ -1,111 +0,0 @@
<template>
<div class="loginBody">
<div class="loginDiv">
<div class="login-content">
<h1 class="login-title">用户登录</h1>
<el-form :model="loginForm" label-width="100px"
:rules="rules" ref="loginForm">
<el-form-item label="账号" prop="no">
<el-input style="width: 200px" type="text" v-model="loginForm.no"
autocomplete="off" size="small"></el-input>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input style="width: 200px" type="password" v-model="loginForm.password"
show-password autocomplete="off" size="small" @keyup.enter.native="confirm"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="confirm" :disabled="confirm_disabled"> </el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script>
export default {
name: "Login",
data(){
return{
confirm_disabled:false,
loginForm:{
no:'',
password:''
},
rules:{
no: [
{ required: true, message: '请输入账号', trigger: 'blur' }
],
password: [
{ required: true, message: '请输密码', trigger: 'blur' }
],
}
}
},
methods:{
confirm(){
this.confirm_disabled=true;
this.$refs.loginForm.validate((valid) => {
if (valid) { //validtruefalse
// Axios Axios
this.$axios.post(this.$httpUrl+'/user/login',this.loginForm).then(res=>res.data).then(res=>{
console.log(res)
if(res.code==200){
//使 sessionStorage
sessionStorage.setItem("CurUser",JSON.stringify(res.data.user))
console.log(res.data.menu)
this.$store.commit("setMenu",res.data.menu)
//
this.$router.replace('/Index');
}else{
this.confirm_disabled=false;
alert('校验失败,用户名或密码错误!');
return false;
}
});
} else {
this.confirm_disabled=false;
console.log('校验失败');
return false;
}
});
}
}
}
</script>
<style scoped>
.loginBody {
position: absolute;
width: 100%;
height: 100%;
background-color: #B3C0D1;
}
.loginDiv {
position: absolute;
top: 50%;
left: 50%;
margin-top: -200px;
margin-left: -250px;
width: 450px;
height: 330px;
background: #fff;
border-radius: 5%;
}
.login-title {
margin: 20px 0;
text-align: center;
}
.login-content {
width: 400px;
height: 250px;
position: absolute;
top: 25px;
left: 25px;
}
</style>

27518
src/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,46 +0,0 @@
{
"name": "wms-web",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.27.2",
"core-js": "^3.6.5",
"element-ui": "^2.15.9",
"vue": "^2.6.11",
"vue-router": "^3.5.4",
"vuex": "^3.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.15",
"@vue/cli-plugin-eslint": "~4.5.15",
"@vue/cli-service": "~4.5.15",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

@ -0,0 +1,141 @@
#include <math.h>
#include <iostream>
#include "levelToSpeed.h"
using namespace std;
#define M_PI acos(-1)
class ForestFirePrediction {
public:
// 构造函数
ForestFirePrediction(int wind_direction, double wind_level, double slope, double altitude, int cover_type, double fire_size) {
this->wind_direction = wind_direction;
this->wind_level = wind_level;
this->slope = slope;
this->altitude = altitude;
this->cover_type = cover_type;
this->fire_size = fire_size;
}
// 计算受阻距离单位km
double get_distance() {
double rad_slope = slope * M_PI / 180.0; // 将坡度转化为弧度
double distance = sin(rad_slope) * altitude / 1000.0; // 计算受阻距离
return distance;
}
// 预测火灾蔓延范围
void predict_range() {
double impact_factor; // 植被类型影响系数
double correction_coef; // 风速补正系数
double distance; // 受阻距离
double composite_index; // 综合指数
// 根据植被类型获取影响系数
switch (cover_type) {
case 1: // 针叶林
impact_factor = 0.7;
break;
case 2: // 落叶林
impact_factor = 0.5;
break;
case 3: // 灌木林
impact_factor = 0.4;
break;
default:
cout << "植被类型输入错误!" << endl;
return;
}
// 计算风速补正系数
int angle = abs(wind_direction - 180); // 计算风向与火灾扩散方向之间的夹角
if (angle <= 45 || angle >= 315) { // 如果夹角较小,则不需要进行风速补正
correction_coef = 1;
}
else {
correction_coef = 0.65 + 0.35 * cos((angle - 45) * M_PI / 270.0); // 使用公式计算风速补正系数
}
// 计算受阻距离
distance = get_distance();
// 计算综合指数
composite_index = correction_coef * (1 + distance) * impact_factor;
// 计算火灾蔓延半径
double radius = sqrt(fire_size * 1000000 * composite_index) / M_PI;
double range = radius * pow(10, 1.5 * levelToSpeed(wind_level) / 30.0);
// 输出预测结果
cout << "火灾蔓延范围预测结果:" << endl;
cout << "火源最可能在" << radius << "米范围内发生。" << endl;
cout << "在风速为 " << wind_level << "级风的情况下,火源最可能的蔓延范围为 " << range << " 米。" << endl;
}
// 预测火灾蔓延速度
void predict_speed(int level) {
double slope_factor; // 坡度影响因子
double speed_factor; // 风速影响因子
double size_factor; // 火源面积影响因子
// 计算坡度影响因子
if (slope > 0) {
slope_factor = pow(3.33, sqrt(slope));
}
else {
slope_factor = 1;
}
// 计算风速影响因子
double wind_speed = levelToSpeed(wind_level);
speed_factor = 5.15 * pow(wind_speed, 0.39);
// 计算火源面积影响因子
size_factor = pow(fire_size, 0.77);
// 计算火灾蔓延速度
double speed = 0.348 * sqrt(size_factor * slope_factor * speed_factor);
// 输出预测结果
cout << "火灾蔓延速度预测结果:" << endl;
cout << "火灾蔓延速度可能为" << speed << "km/h。" << endl;
}
private:
int wind_direction; // 风向(单位:度)
double wind_level; // 风力等级
double slope; // 坡度(单位:度)
double altitude; // 海拔高度单位m
int cover_type; // 植被类型1针叶林2落叶林3灌木林
double fire_size; // 火源面积(单位:平方米)
};
int main() {
// 读取参数
int wind_direction;
int wind_level;
double slope;
double altitude;
int cover_type;
double fire_size;
cout << "请输入风向0-360度" << endl;
cin >> wind_direction;
cout << "请输入风力等级(级):" << endl;
cin >> wind_level;
cout << "请输入坡度(度):" << endl;
cin >> slope;
cout << "请输入海拔高度m" << endl;
cin >> altitude;
cout << "请输入植被类型1针叶林2落叶林3灌木林" << endl;
cin >> cover_type;
cout << "请输入火源面积m^2" << endl;
cin >> fire_size;
// 预测火灾蔓延范围和速度
ForestFirePrediction ffp(wind_direction, wind_level, slope, altitude, cover_type, fire_size);
ffp.predict_range();
ffp.predict_speed(wind_level);
return 0;
}

@ -0,0 +1,23 @@
#include<iostream>
using namespace std;
double levelToSpeed(int level) {
double speed = 0;
if (level >= 0 && level <= 12) {
static const double table[] = { 0.0, 0.3, 1.6, 3.4, 5.5, 8.0, 10.8, 13.9, 17.2, 20.8, 24.5, 28.5, 32.6 };
speed = table[level];
}
else if (level == 13) {
speed = 35.8;
}
else if (level == 14) {
speed = 41.5;
}
else if (level == 15) {
speed = 48.2;
}
else {
cout << "ÎÞЧµÄ·çÁ¦µÈ¼¶£¡" << endl;
}
return speed;
}
Loading…
Cancel
Save