| | |
| | | </profiles> |
| | | |
| | | <build> |
| | | <finalName>simu</finalName> |
| | | <finalName>SimuServer</finalName> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | .description("接口文档") |
| | | .contact(new Contact("WuWeiwei", "http://127.0.0.1:" + serverPort + contextPath + "/doc.html", "252740454@qq.com")) |
| | | .version("1.0.0") |
| | | .title("内涝仿真渲染服务API接口文档") |
| | | .title("内涝仿真服务API接口文档") |
| | | .build(); |
| | | } |
| | | } |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * 内涝控制器 |
| | |
| | | |
| | | private final static int MIN_SIZE = 10; |
| | | |
| | | private final static int MAX_SIZE = 10000000; |
| | | private final static int MAX_SIZE = 80000; |
| | | |
| | | private final static long Y2000 = 949334400000L; |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getTerraMap(serviceName, width, height); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getWaterMap(serviceName, width, height); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return; |
| | | } |
| | | |
| | | // |
| | | String file = waterService.getFlowMap(serviceName, width, height, timestamp); |
| | | writeFile(file, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | WebHelper.writeStr2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); |
| | |
| | | return validate(serviceName, width, height, Y2000, res); |
| | | } |
| | | |
| | | /** |
| | | * 验证 |
| | | */ |
| | | private boolean validate(String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { |
| | | if (StringHelper.isEmpty(serviceName)) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.BAD_REQUEST, "服务名不能为空"); |
| | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 写文件 |
| | | */ |
| | | private boolean writeFile(String path, HttpServletResponse res) throws Exception { |
| | | if (StringHelper.isEmpty(path)) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "生成PNG失败"); |
| | | } |
| | | File file = new File(path); |
| | | if (!file.exists() || file.isDirectory()) { |
| | | return WebHelper.writeJson2Page(res, HttpStatus.INTERNAL_SERVER_ERROR, "PNG文件找不到"); |
| | | } |
| | | |
| | | WebHelper.download(path, file.getName(), res); |
| | | |
| | | return true; |
| | | } |
| | | } |
| | |
| | | |
| | | return layer; |
| | | } |
| | | |
| | | public String getTerraMap(String serviceName, Integer width, Integer height) { |
| | | return "D:/simu/test/geo.png"; |
| | | } |
| | | |
| | | public String getWaterMap(String serviceName, Integer width, Integer height) { |
| | | return null; |
| | | } |
| | | |
| | | public String getFlowMap(String serviceName, Integer width, Integer height, Long timestamp) { |
| | | return null; |
| | | } |
| | | } |