| | |
| | | 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") |