| | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 内涝服务类 |
| | | * |
| | | * @author WWW |
| | | * @date 2024-07-16 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | |
| | | @Resource |
| | | PropertiesConfig config; |
| | | |
| | | /** |
| | | * 获取元数据信息 |
| | | */ |
| | | public byte[] getson(String serviceName, String json) { |
| | | try { |
| | | String filePath = config.getOutPath() + File.separator + serviceName + File.separator + json; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取地形高度图 |
| | | */ |
| | | public String getTerraMap(String serviceName, Integer width, Integer height) { |
| | | return config.getOutPath() + File.separator + serviceName + File.separator + "terrain" + File.separator + width + "_" + height + ".png"; |
| | | } |
| | | |
| | | /** |
| | | * 获取水面高度图 |
| | | */ |
| | | public String getWaterMap(String serviceName, Integer width, Integer height, Long timestamp) { |
| | | return config.getOutPath() + File.separator + serviceName + File.separator + "waters" + File.separator + timestamp + File.separator + width + "_" + height + ".png"; |
| | | } |
| | | |
| | | /** |
| | | * 获取水流向流速图 |
| | | */ |
| | | public String getFlowMap(String serviceName, Integer width, Integer height, Long timestamp) { |
| | | return config.getOutPath() + File.separator + serviceName + File.separator + "flows" + File.separator + timestamp + File.separator + width + "_" + height + ".png"; |
| | | } |
| | | |
| | | /** |
| | | * 根据坐标查询积水深度:gdalconst.GA_Update |
| | | */ |
| | | public Double getWaterHeight(SimuPo simu, double x, double y, Long timestamp) { |
| | | String filePath = config.getOutPath() + File.separator + simu.getServiceName() + File.separator + "waters" |
| | | + File.separator + timestamp + File.separator + "water.tif"; |
| | |
| | | return data.getSpatialReference(); |
| | | } |
| | | |
| | | /** |
| | | * 将地图坐标转换为栅格像素坐标 |
| | | * |
| | | * @param gt 仿射变换参数 |
| | | * @param x 横坐标 |
| | | * @param y 纵坐标 |
| | | * @return 像素坐标 |
| | | */ |
| | | public int[] coordinates2ColRow(double[] gt, double x, double y) { |
| | | // 向下取整,如果向上取整会导致计算结果偏大,从而在后面读取到邻近像元的数据 |
| | | //Double col = Math.floor(((y - gt[3]) * gt[1] - (x - gt[0]) * gt[4]) / (gt[5] * gt[1] - gt[2] * gt[4])); |
| | | Double col = Math.floor((y * gt[1] - x * gt[4] + gt[0] * gt[4] - gt[3] * gt[1]) / (gt[5] * gt[1] - gt[2] * gt[4])); |
| | | Double row = Math.floor((x - gt[0] - col * gt[2]) / gt[1]); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据seid查询建筑物涉水深度 |
| | | */ |
| | | public List<BuildingDepthVo> getBuildingDepthBySeid(String serviceName, String seid) { |
| | | List<BuildingDepthVo> list = readBuildingJson(serviceName); |
| | | if (CollectionUtils.isEmpty(list)) return null; |