| | |
| | | |
| | | private boolean copyTif; |
| | | |
| | | private String tifPath; |
| | | |
| | | public String getVer() { |
| | | return ver; |
| | | } |
| | |
| | | public void setCopyTif(boolean copyTif) { |
| | | this.copyTif = copyTif; |
| | | } |
| | | |
| | | public String getTifPath() { |
| | | return tifPath; |
| | | } |
| | | |
| | | public void setTifPath(String tifPath) { |
| | | this.tifPath = tifPath; |
| | | } |
| | | } |
| | |
| | | SemUtils.cityJsonToSem(pointPath, filePatn + "link.sem"); |
| | | return success(filePatn + "link.sem"); |
| | | } |
| | | @ApiOperation(value = "地形转sem") |
| | | @PostMapping(value = "/terrainToSem", produces = "application/json; charset=UTF-8") |
| | | public R<String> terrainToSem(@RequestBody List<GridDto> dtos) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\terrain\\" + times + "\\"; |
| | | File dirFile = new File(path + "appearance"); |
| | | if (!dirFile.exists()) { |
| | | dirFile.mkdirs(); |
| | | } |
| | | double minx=180.0; |
| | | double maxx=0.0; |
| | | double miny=180.0; |
| | | double maxy=0.0; |
| | | for (GridDto dto:dtos |
| | | ) { |
| | | if (dto.getLon()>maxx){ |
| | | maxx=dto.getLon(); |
| | | } |
| | | if (dto.getLon()<minx){ |
| | | minx=dto.getLon(); |
| | | } |
| | | if (dto.getLat()>maxy){ |
| | | maxy=dto.getLat(); |
| | | } |
| | | if (dto.getLat()<miny){ |
| | | miny=dto.getLat(); |
| | | } |
| | | } |
| | | JSONArray min= ProjectionToGeographicUtil.get4548Point(minx,miny); |
| | | JSONArray max=ProjectionToGeographicUtil.get4548Point(maxx,maxy); |
| | | String tifPath=path+"terrain.tif"; |
| | | TiffClipper.cropTiffByLatLon(config.getTifPath(),tifPath,min.getDouble(0),min.getDouble(1),max.getDouble(0),max.getDouble(1)); |
| | | String pngPath = path + "appearance\\terrain.png"; |
| | | TiffToRGBUtil.tifToPng(tifPath, pngPath); |
| | | JSONObject jsonObject = getModule("terrainmodule.json"); |
| | | jsonObject.put("vertices", TiffCoordinateExtractorUtil.getCoordinate(tifPath)); |
| | | FileWriter fileWriter = new FileWriter(path + "terrain.json"); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | String filePatn = inPath + "\\tongzhou\\"; |
| | | File file = new File(filePatn); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | SemUtils.cityJsonToSem(path + "terrain.json", filePatn + "terrain.sem"); |
| | | return success(filePatn + "terrain.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "地形转cityjson") |
| | | @GetMapping(value = "/terrainToCityJson", produces = "application/json; charset=UTF-8") |
| | |
| | | |
| | | public class TiffToRGBUtil { |
| | | public static void main(String[] args) throws Exception{ |
| | | tifToPng("D:\\城市内涝\\sem\\DEM100.tif","D:\\城市内涝\\sem\\DEM100.png"); |
| | | tifToPng("D:\\城市内涝\\sem\\tongzhou_1m_tif\\tongzhou_raster_4548_1m_clip_river_fill.tif","D:\\城市内涝\\sem\\tongzhou_1m_tif\\tongzhou_raster_4548_1m_clip_river_fill.png"); |
| | | } |
| | | public static void tifToPng(String tifPath, String pngPath) throws Exception { |
| | | // 注册所有的 GDAL 驱动 |
| | |
| | | waterPath: depth |
| | | flowPath: velocity |
| | | copyTif: false |
| | | tifPath: D:\城市内涝\sem\tongzhou_1m_tif\tongzhou_raster_4548_1m_clip_river_fill.tif |
| | |
| | | {"type":"CityJSON","version":"1.0","CityObjects":{"UUID_63b11762-6a6a-4d91-b497-6314fee1ce0f":{"type":"+Terrain","geometry":[{"type":"MultiSurface","boundaries":[[[0,1,2,3]]],"texture":{"visual":{"values":[[[0,0,1,2,3]]]}},"lod":0}]}},"appearance":{"textures":[{"type":"PNG","image":"appearances/terrain.png"}],"vertices-texture":[[0.0,0.0],[0.0,1.0],[1.0,1.0],[1.0,0.0]]}} |
| | | {"type":"CityJSON","version":"1.0","CityObjects":{"UUID_63b11762-6a6a-4d91-b497-6314fee1ce0f":{"type":"+Terrain","geometry":[{"type":"MultiSurface","boundaries":[[[0,1,2,3]]],"texture":{"visual":{"values":[[[0,0,1,2,3]]]}},"lod":0}]}},"appearance":{"textures":[{"type":"PNG","image":"appearance/terrain.png"}],"vertices-texture":[[0.0,0.0],[0.0,1.0],[1.0,1.0],[1.0,0.0]]}} |