| | |
| | | <artifactId>caffeine</artifactId> |
| | | <version>2.9.3</version> |
| | | </dependency> |
| | | <!--hdf5--> |
| | | <dependency> |
| | | <groupId>org.hdfgroup</groupId> |
| | | <artifactId>hdf-java</artifactId> |
| | | <version>2.6.1</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import com.se.simu.domain.vo.R; |
| | | import com.se.simu.helper.ShpHelper; |
| | | import com.se.simu.helper.StringHelper; |
| | | import com.se.simu.service.GedbService; |
| | | import com.se.simu.service.ResultService; |
| | | import com.se.simu.service.SimuService; |
| | | import com.se.simu.service.UwService; |
| | | import com.se.simu.service.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | @Resource |
| | | SimuService simuService; |
| | | |
| | | @Resource |
| | | Hdf5Service hdf5Service; |
| | | |
| | | @Resource |
| | | ResultService resultService; |
| | |
| | | @ApiImplicitParam(name = "time", value = "æ¶é´", dataType = "String", paramType = "query", example = "2024-11-07 09:23:42") |
| | | }) |
| | | @GetMapping("/testResuslt") |
| | | public R<Object> testResuslt(String path,String time) { |
| | | public R<Object> testResuslt(String path, String time) { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(4548); |
| | |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "testH5 *") |
| | | @GetMapping("/testH5") |
| | | public R<Object> testH5() { |
| | | try { |
| | | DataPo data = new DataPo(); |
| | | data.setEpsg(4548); |
| | | data.setInPath("20241010095328"); |
| | | data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); |
| | | |
| | | hdf5Service.test(data); |
| | | |
| | | return success("ok"); |
| | | } catch (Exception ex) { |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private String flowPath; |
| | | |
| | | private String h5Path; |
| | | |
| | | private String inPath; |
| | | |
| | | private String outPath; |
| | | |
| | | private String temp; |
| | |
| | | this.buildingList = new ArrayList<>(); |
| | | } |
| | | |
| | | public ResultDto(String serviceName, String terrainFile, String buildingFile, String waterPath, String flowPath, String outPath, int epsg) { |
| | | public ResultDto(String serviceName, String terrainFile, String buildingFile, String waterPath, String flowPath, String inPath, String outPath, int epsg) { |
| | | this(); |
| | | this.serviceName = serviceName; |
| | | this.terrainFile = terrainFile; |
| | | this.buildingFile = buildingFile; |
| | | this.waterPath = waterPath; |
| | | this.flowPath = flowPath; |
| | | this.inPath = inPath + File.separator + serviceName; |
| | | this.h5Path = this.inPath + File.separator + ".save" + File.separator + serviceName + ".h5"; |
| | | this.outPath = outPath + File.separator + serviceName; |
| | | this.temp = outPath + File.separator + serviceName + File.separator + "temp"; |
| | | this.epsg = epsg; |
| | |
| | | this.flowPath = flowPath; |
| | | } |
| | | |
| | | public String getInPath() { |
| | | return inPath; |
| | | } |
| | | |
| | | public void setInPath(String inPath) { |
| | | this.inPath = inPath; |
| | | } |
| | | |
| | | public String getOutPath() { |
| | | return outPath; |
| | | } |
| | |
| | | public void setSpatialReference(SpatialReference spatialReference) { |
| | | this.spatialReference = spatialReference; |
| | | } |
| | | |
| | | public String getH5Path() { |
| | | return h5Path; |
| | | } |
| | | |
| | | public void setH5Path(String h5Path) { |
| | | this.h5Path = h5Path; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.se.simu.service; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.dto.LayerDto; |
| | | import com.se.simu.domain.dto.ResultDto; |
| | | import com.se.simu.domain.po.DataPo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import ncsa.hdf.hdf5lib.H5; |
| | | import ncsa.hdf.hdf5lib.HDF5Constants; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class Hdf5Service { |
| | | @Resource |
| | | PropertiesConfig config; |
| | | |
| | | public void test(DataPo data) throws Exception { |
| | | String basePath = config.getInPath() + File.separator + data.getInPath() + File.separator; |
| | | ResultDto dto = new ResultDto( |
| | | data.getInPath(), |
| | | basePath + config.getTerrainFile(), |
| | | basePath + config.getBuildingFile(), |
| | | basePath + config.getWaterPath(), |
| | | basePath + config.getFlowPath(), |
| | | config.getInPath(), |
| | | config.getOutPath(), |
| | | data.getEpsg()); |
| | | LayerDto layer = new LayerDto(config.getVer(), data.getEpsg(), config.getSizes()); |
| | | process(dto, layer); |
| | | } |
| | | |
| | | private void process(ResultDto dto, LayerDto layer) throws Exception { |
| | | int fileId = 0; |
| | | int datasetId = 0; |
| | | try { |
| | | if (!FileUtil.exist(dto.getH5Path())) return; |
| | | |
| | | fileId = H5.H5Fopen(dto.getH5Path(), HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT); |
| | | if (fileId == 0) return; |
| | | |
| | | datasetId = H5.H5Dopen(fileId, "data"); |
| | | if (datasetId == 0) return; |
| | | |
| | | // è·åæ°æ®éç维度 |
| | | //long[] dims = H5.H5Dget_dims(datasetId); |
| | | |
| | | // æ ¹æ®æ°æ®éç维度å建ä¸ä¸ªJavaæ°ç»æ¥å卿°æ® |
| | | int[] buffer = new int[1]; |
| | | |
| | | // è¯»åæ°æ®å°Javaæ°ç» |
| | | int herr = H5.H5Dread(datasetId, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT, buffer); |
| | | |
| | | // è¾åºè¯»åå°çæ°æ® |
| | | System.out.println(buffer[0]); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } finally { |
| | | if (datasetId > 0) H5.H5Dclose(datasetId); |
| | | if (fileId > 0) H5.H5Dclose(fileId); |
| | | } |
| | | } |
| | | } |
| | |
| | | basePath + config.getBuildingFile(), |
| | | basePath + config.getWaterPath(), |
| | | basePath + config.getFlowPath(), |
| | | config.getInPath(), |
| | | config.getOutPath(), |
| | | data.getEpsg()); |
| | | LayerDto layer = new LayerDto(config.getVer(), data.getEpsg(), config.getSizes()); |
| | |
| | | #inPath: D:\simu\in |
| | | inPath: D:\simu\uwsolver |
| | | outPath: D:\simu\out |
| | | # |
| | | host: http://106.120.22.26:8024/ |
| | | user: admin |
| | | pwd: admin |