| | |
| | | import java.net.URL; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | return fail("鲿±èå´ä¸è½ä¸ºç©º", false); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(vo.getSemUrl())){ |
| | | if (StringUtils.isEmpty(vo.getSemUrl())) { |
| | | return fail("semæä»¶çæè·¯å¾ä¸è½ä¸ºç©ºï¼", false); |
| | | } |
| | | List<GridDto> dtos = new ArrayList<>(); |
| | |
| | | dtos.add(new GridDto(vo.getMaxy(), vo.getMinx())); |
| | | dtos.add(new GridDto(vo.getMaxy(), vo.getMaxx())); |
| | | dtos.add(new GridDto(vo.getMiny(), vo.getMaxx())); |
| | | createSem(tableName, dtos, vo.getSemUrl()); |
| | | createSem(tableName, dtos, vo); |
| | | // å¼å§æ¨¡æè®¡ç® |
| | | boolean flag = simuFilesService.createByfiles(vo); |
| | | return success(flag, flag ? "æå" : "失败"); |
| | |
| | | } |
| | | } |
| | | |
| | | public R<Boolean> createSem(String tableName, List<GridDto> dtos, String semUrl) throws Exception { |
| | | boolean ends = semUrl.endsWith("\\"); |
| | | if (!ends) { |
| | | semUrl = semUrl + "\\"; |
| | | @ApiOperation(value = "è·åç¹è·¯å¾") |
| | | @GetMapping("/getPointUrl") |
| | | public R<String> getPointUrl(@RequestParam("id") Integer id) throws Exception{ |
| | | SimuPo po = simuService.getSimuById(id); |
| | | String token = EntityLibraryUtils.login(); |
| | | if (po != null) { |
| | | return success(po.getPointUrl().replace("{token}",token)); |
| | | } |
| | | File file = new File(semUrl); |
| | | return success(null); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·å线路å¾") |
| | | @GetMapping("/getLineUrl") |
| | | public R<String> getLineUrl(@RequestParam("id") Integer id) throws Exception{ |
| | | SimuPo po = simuService.getSimuById(id); |
| | | String token = EntityLibraryUtils.login(); |
| | | if (po != null) { |
| | | return success(po.getLinkUrl().replace("{token}",token)); |
| | | } |
| | | return success(null); |
| | | } |
| | | |
| | | public R<Boolean> createSem(String tableName, List<GridDto> dtos, CreateFilesSimuVo vo) throws Exception { |
| | | String name = vo.getSemUrl(); |
| | | vo.setSemUrl(inPath + "\\" + vo.getSemUrl()); |
| | | boolean ends = vo.getSemUrl().endsWith("\\"); |
| | | if (!ends) { |
| | | vo.setSemUrl(vo.getSemUrl() + "\\"); |
| | | } |
| | | File file = new File(vo.getSemUrl()); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | //éé¨æä»¶çæ |
| | | saveZarr(tableName,semUrl); |
| | | String token = EntityLibraryUtils.login(); |
| | | //éé¨æä»¶çæ |
| | | saveZarr(tableName, vo.getSemUrl()); |
| | | //管ç¹çæ |
| | | pointTosem(dtos, token,semUrl); |
| | | pointTosem(dtos, token, vo.getSemUrl()); |
| | | //ç®¡çº¿çæ |
| | | lineToSem(dtos, token,semUrl); |
| | | //å°å½¢çæ |
| | | terrainToSem(dtos,semUrl); |
| | | lineToSem(dtos, token, vo.getSemUrl()); |
| | | //èå´çæ |
| | | gridToCityJson(dtos,semUrl); |
| | | gridToCityJson(dtos, vo.getSemUrl()); |
| | | //æ²³æµçæ |
| | | riverToSem(semUrl); |
| | | riverToSem(vo.getSemUrl()); |
| | | //åå°å©ç¨çæ |
| | | landuseToSem(semUrl); |
| | | landuseToSem(vo.getSemUrl()); |
| | | //å°å½¢çæ |
| | | terrainToSem(dtos, vo.getSemUrl()); |
| | | String bbox = ""; |
| | | //çæç¹å线çå®ä½åºæ¨¡åå¹¶ä¿åè·¯å¾ |
| | | vo.setPointName(name + "-point"); |
| | | vo.setLinkName(name + "-line"); |
| | | JSONArray min = ProjectionToGeographicUtil.get4548Point(dtos.get(0).getLon(), dtos.get(0).getLat()); |
| | | JSONArray max = ProjectionToGeographicUtil.get4548Point(dtos.get(2).getLon(), dtos.get(2).getLat()); |
| | | bbox = bbox + min.getDouble(0) + "," + min.getDouble(1) + "," + max.getDouble(0) + "," + max.getDouble(1); |
| | | JSONObject point = getModule("layerQueryPointParams.json"); |
| | | String pointUrl = assemble(vo.getPointName(), point.getString("layerid"), bbox, token); |
| | | vo.setPointName(pointUrl); |
| | | JSONObject link = getModule("layerQueryParams.json"); |
| | | String linkUrl = assemble(vo.getLinkName(), link.getString("layerid"), bbox, token); |
| | | vo.setLinkName(linkUrl); |
| | | return success(true); |
| | | } |
| | | |
| | | @ApiOperation(value = "tarræä»¶ç»è£
") |
| | | @GetMapping(value = "/saveZarr", produces = "application/json; charset=UTF-8") |
| | | public R<String> saveZarr(@RequestParam("name") String tableName,String semUrl) throws Exception { |
| | | |
| | | public String assemble(String name, String layerid, String bbox, String token) throws Exception { |
| | | JSONObject jsonObject = EntityLibraryUtils.createAssemble(name, token); |
| | | String packageid = jsonObject.getString("packageid"); |
| | | EntityLibraryUtils.addAssemble(layerid, token, packageid, bbox); |
| | | JSONObject result = EntityLibraryUtils.submitAssemble(token, packageid); |
| | | Random random = new Random(); |
| | | int randomNumber = random.nextInt(90000) + 10000; |
| | | String url = "http://106.120.22.26:8024/geo-service/package/3d/normal/85257774fdb64e5f99f6778696cad02a/" + packageid + "/" + layerid + "//l0/tileset.json?r=" + randomNumber + "&token={token}"; |
| | | return url; |
| | | } |
| | | |
| | | public R<String> saveZarr(String tableName, String semUrl) throws Exception { |
| | | List<String> list = CsvToSQLiteUtils.getNameList(tableName); |
| | | String path = outPath + "\\"; |
| | | String rainfall = "rainfall\\"; |
| | | String basePath = path + tableName + "\\" + rainfall; |
| | | JSONObject jsonObject = getModule("rainfallmodule.json"); |
| | | String startTime = null; |
| | | String endTime = null; |
| | | for (String src : list |
| | | ) { |
| | | File directories = new File(basePath); |
| | |
| | | System.out.println("Directories already exist."); |
| | | } |
| | | List<StationRainVo> stationRainVos = CsvToSQLiteUtils.getList(tableName, src); |
| | | if (startTime == null) { |
| | | startTime = stationRainVos.get(0).getDatetime(); |
| | | } |
| | | if (endTime == null) { |
| | | endTime = stationRainVos.get(stationRainVos.size() - 1).getDatetime(); |
| | | } |
| | | ZarrUtils.saveZarrRainfall(basePath + src, stationRainVos); |
| | | ZarrUtils.saveZarrTime(basePath + src, stationRainVos); |
| | | ZipUtils.toZarr(basePath + src, basePath + src + ".zip"); |
| | |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | SemUtils.cityJsonToSem(path + tableName + "\\éé¨é.json", semUrl + "raingage.sem"); |
| | | getConfigJson(startTime, endTime, semUrl); |
| | | return success(semUrl + "raingage.sem"); |
| | | } |
| | | |
| | | public R<String> pointTosem(List<GridDto> dtos, String token,String semUrl) throws Exception { |
| | | public void getConfigJson(String startTime, String endTime, String semUrl) throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm"); |
| | | Date start = sdf.parse(startTime); |
| | | Date end = sdf.parse(endTime); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); |
| | | JSONObject jsonObject = getModule("config.json"); |
| | | jsonObject.put("start_datetime", simpleDateFormat.format(start)); |
| | | jsonObject.put("end_datetime", simpleDateFormat.format(end)); |
| | | FileWriter fileWriter = new FileWriter(semUrl + "\\config.json"); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | } |
| | | |
| | | public R<String> pointTosem(List<GridDto> dtos, String token, String semUrl) throws Exception { |
| | | String path = outPath + "\\point\\"; |
| | | String publicKey = EntityLibraryUtils.getPublicKey(); |
| | | JSONArray jsonArrayList = EntityLibraryUtils.getPointInfo(dtos, token); |
| | |
| | | return success(semUrl + "node.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "管ç¹è½¬cityjson") |
| | | @GetMapping(value = "/pointToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> pointToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { |
| | | |
| | | public R<String> pointToCityJson(String shpPath) throws Exception { |
| | | String path = outPath + "\\point\\"; |
| | | List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); |
| | | JSONObject jsonObject = getModule("pointmodule.json"); |
| | |
| | | return success(filePatn + "node.sem"); |
| | | } |
| | | |
| | | public R<String> lineToSem(List<GridDto> dtos, String token,String semUrl) throws Exception { |
| | | public R<String> lineToSem(List<GridDto> dtos, String token, String semUrl) throws Exception { |
| | | String path = outPath + "\\line\\"; |
| | | String publicKey = EntityLibraryUtils.getPublicKey(); |
| | | JSONArray jsonArrayList = EntityLibraryUtils.getLineInfo(dtos, token); |
| | |
| | | return success(semUrl + "link.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "管线转cityjson") |
| | | @GetMapping(value = "/lineToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> lineToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { |
| | | public R<String> lineToCityJson(String shpPath) throws Exception { |
| | | String path = outPath + "\\line\\"; |
| | | List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); |
| | | JSONObject jsonObject = getModule("linemodule.json"); |
| | |
| | | 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,String semUrl) throws Exception { |
| | | public R<String> terrainToSem(List<GridDto> dtos, String semUrl) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\terrain\\" + times + "\\"; |
| | | File dirFile = new File(path + "appearance"); |
| | |
| | | return success(semUrl + "terrain.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "å°å½¢è½¬cityjson") |
| | | @GetMapping(value = "/terrainToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> terrainToCityJson(@RequestParam("tifPath") String tifPath) throws Exception { |
| | | public R<String> terrainToCityJson(String tifPath) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\terrain\\" + times + "\\"; |
| | | File dirFile = new File(path + "appearance"); |
| | |
| | | return success(filePatn + "terrain.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "grid转cityjson") |
| | | @PostMapping(value = "/gridToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> gridToCityJson(@RequestBody List<GridDto> dtos,String semUrl) throws Exception { |
| | | public R<String> gridToCityJson(List<GridDto> dtos, String semUrl) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\grid\\" + times + "\\"; |
| | | File dirFile = new File(path); |
| | |
| | | return success(semUrl + "grid.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "river转sem") |
| | | @GetMapping(value = "/riverToSem", produces = "application/json; charset=UTF-8") |
| | | public R<String> riverToSem(String semUrl) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\river\\" + times + "\\"; |
| | |
| | | return success(semUrl + "river.sem"); |
| | | } |
| | | |
| | | @ApiOperation(value = "landuse转sem") |
| | | @GetMapping(value = "/landuseToSem", produces = "application/json; charset=UTF-8") |
| | | public R<String> landuseToSem(String semUrl) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\landuse\\" + times + "\\"; |