| | |
| | | package com.se.simu.service; |
| | | |
| | | import com.se.simu.domain.LayerVo; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.vo.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class WaterService { |
| | | @Value("${sys.ver}") |
| | | String ver; |
| | | @Resource |
| | | PropertiesConfig config; |
| | | |
| | | @Value("${sys.path.gdal}") |
| | | String gdalPath; |
| | | /** |
| | | * 获取元数据信息 |
| | | */ |
| | | public byte[] getLayerJson(String serviceName) { |
| | | try { |
| | | String filePath = config.getOutPath() + File.separator + serviceName + File.separator + "layer.json"; |
| | | |
| | | @Value("${sys.path.data}") |
| | | String dataPath; |
| | | File dat = new File(filePath); |
| | | if (!dat.exists()) { |
| | | return null; |
| | | } |
| | | |
| | | public LayerVo getLayer(String serviceName) { |
| | | LayerVo layer = new LayerVo(); |
| | | layer.setVer(ver); |
| | | layer.setDuration(new LayerVo.Duration(1719812810225L, 1719812810225L)); |
| | | layer.setExtension(new LayerVo.Extension(2.11062743358, 0.53812160220, 2.11070827834, 0.53819799453, 1.151, 38.83)); |
| | | layer.setTerrain(new LayerVo.Terrain(10000, 10000)); |
| | | byte[] bytes = new byte[(int) dat.length()]; |
| | | |
| | | FileInputStream fs = new FileInputStream(filePath); |
| | | fs.read(bytes); |
| | | fs.close(); |
| | | |
| | | return bytes; |
| | | } catch (Exception ex) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取地形高度图 |
| | | */ |
| | | 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"; |
| | | } |
| | | |
| | | /** |
| | | * 获取图层 * |
| | | */ |
| | | public Layer getLayer(String serviceName) { |
| | | Layer layer = new Layer(); |
| | | layer.setVersion(config.getVer()); |
| | | layer.setDuration(new Duration(1719812810225L, 1719812810225L)); |
| | | layer.setExtension(new Extension(2.11062743358, 0.53812160220, 2.11070827834, 0.53819799453, 1.151, 38.83)); |
| | | |
| | | List<Integer[]> sizes = new ArrayList<>(); |
| | | sizes.add(new Integer[]{64, 64}); |
| | | sizes.add(new Integer[]{128, 128}); |
| | | sizes.add(new Integer[]{256, 256}); |
| | | sizes.add(new Integer[]{512, 512}); |
| | | sizes.add(new Integer[]{1024, 1024}); |
| | | sizes.add(new Integer[]{2048, 2048}); |
| | | layer.setTerrain(new Terrain(sizes)); |
| | | |
| | | List<Long> data = new ArrayList<>(Arrays.asList(1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L, 1719812812225L)); |
| | | layer.setWater(new LayerVo.Water(10000, 10000, data)); |
| | | layer.setWaters(new Water(data)); |
| | | |
| | | 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; |
| | | } |
| | | } |