| | |
| | | package com.se.simu.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.se.simu.config.PropertiesConfig; |
| | |
| | | import com.se.simu.domain.vo.R; |
| | | import com.se.simu.domain.vo.SimuVo; |
| | | import com.se.simu.service.*; |
| | | import com.se.simu.utils.CsvToSQLiteUtils; |
| | | import com.se.simu.utils.ShpToolUtils; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | String floodFile = vo.getFloodFile(); |
| | | log.info("范围文件地址:{}", floodFile); |
| | | try { |
| | | // 判断地址不为空 |
| | | if (StringUtils.isEmpty(floodFile)) { |
| | | return fail("范围文件地址不能为空", false); |
| | | } else { |
| | | // 获取文件的后缀名 |
| | | String fileName = floodFile.substring(floodFile.lastIndexOf(".")); |
| | | // 判断后缀名是否为.shp |
| | | if (!fileName.equalsIgnoreCase(".shp")) { |
| | | return fail("范围文件格式不正确", false); |
| | | } else { |
| | | // 1 读取shp文件,获取范围值 |
| | | JSONObject jsonObject = ShpToolUtils.readShp(floodFile); |
| | | // 2 获取jsonObject中的范围值 |
| | | vo.setMinx(jsonObject.getDouble("minX")); |
| | | vo.setMaxx(jsonObject.getDouble("maxX")); |
| | | vo.setMiny(jsonObject.getDouble("minY")); |
| | | vo.setMaxy(jsonObject.getDouble("maxY")); |
| | | } |
| | | } |
| | | // todo: 解析范围文件 根据不同的的格式文件进行不同的解析,获取需要计算的范围值 |
| | | // 上传格式:.shp/.tiff/.img/.geojson |
| | | // 重新给vo赋值 |
| | | // 1 读取shp文件,获取范围值 |
| | | JSONObject jsonObject = ShpToolUtils.readShp(floodFile); |
| | | // 2 获取jsonObject中的范围值 |
| | | vo.setMinx(jsonObject.getDouble("minX")); |
| | | vo.setMaxx(jsonObject.getDouble("maxX")); |
| | | vo.setMiny(jsonObject.getDouble("minY")); |
| | | vo.setMaxy(jsonObject.getDouble("maxY")); |
| | | } catch (Exception e) { |
| | | log.error("解析范围文件失败"); |
| | | if (null == vo.getMinx() || null == vo.getMiny() || null == vo.getMaxx() || null == vo.getMaxy()) { |
| | |
| | | } |
| | | |
| | | String stationFile = vo.getStationFile(); |
| | | log.info("站点文件shp地址:{}", floodFile); |
| | | |
| | | log.info("站点文件shp地址:{}", stationFile); |
| | | try { |
| | | // 判断地址不为空 |
| | | if (StringUtils.isEmpty(stationFile)) { |
| | | return fail("站点文件shp地址不能为空", false); |
| | | } |
| | | // 1 读取shp文件,获取站点坐标值 |
| | | JSONArray jsonArray = ShpToolUtils.readShpGetLocal(stationFile); |
| | | System.out.println("jsonArray = " + jsonArray); |
| | | } catch (Exception e) { |
| | | log.error("解析站点文件shp失败"); |
| | | } |
| | | |
| | | String stationRainFile = vo.getStationRainFile(); |
| | | log.info("站点雨量CSV文件地址:{}", floodFile); |
| | | // TODO: 2024/12/24 根据这些文件的地址,获取文件内容,创建仿真视图 |
| | | try { |
| | | // 判断地址不为空 |
| | | if (StringUtils.isEmpty(stationRainFile)) { |
| | | return fail("站点雨量CSV文件地址不能为空", false); |
| | | } |
| | | // 创建表名 时间戳 |
| | | String tableName = "station_rain_" + System.currentTimeMillis(); |
| | | // 1 读取CSV 文件 |
| | | CsvToSQLiteUtils.readCsvSaveLocal(stationRainFile, tableName); |
| | | // 获取仿真时间 duration |
| | | |
| | | |
| | | // 获取降雨总量 total |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("解析站点雨量CSV文件失败"); |
| | | } |
| | | // TODO: 2024/12/24 根据这些文件的地址,获取文件内容,创建仿真视图 |
| | | try { |
| | | if (null == vo.getTotal() || vo.getTotal() < 1 || vo.getTotal() > 1000) { |
| | | return fail("降雨量不能为空,且取值在1~1000之间"); |