| | |
| | | |
| | | @ApiOperation(value = "tarr文件组装") |
| | | @GetMapping(value = "/saveZarr", produces = "application/json; charset=UTF-8") |
| | | public R<Boolean> saveZarr(@RequestParam("name") String tableName) throws IOException { |
| | | public R<Boolean> saveZarr(@RequestParam("name") String tableName) throws Exception { |
| | | List<String> list = CsvToSQLiteUtils.getNameList(tableName); |
| | | String path = outPath + "\\"; |
| | | String rainfall = "rainfall\\"; |
| | |
| | | metry.put("type", "MultiPoint"); |
| | | metry.put("lod", 0); |
| | | JSONArray boundarie = new JSONArray(); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()-1); |
| | | metry.put("boundaries", boundarie); |
| | | geometry.add(metry); |
| | | cityObject.put("geometry", geometry); |
| | |
| | | FileWriter fileWriter = new FileWriter(path + tableName + "\\降雨量.json"); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | SemUtils.cityJsonToSem(path + tableName + "\\降雨量.json",path + tableName + "\\降雨量.sem"); |
| | | return success(true); |
| | | } |
| | | |
| | | @ApiOperation(value = "管点转cityjson") |
| | | @GetMapping(value = "/pointToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> pointToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { |
| | | String path = outPath + "\\"; |
| | | String path = outPath + "\\point\\"; |
| | | List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); |
| | | JSONObject jsonObject = getModule("pointmodule.json"); |
| | | for (Map<String, Object> map : list |
| | |
| | | metry.put("type", "MultiPoint"); |
| | | metry.put("lod", 0); |
| | | JSONArray boundarie = new JSONArray(); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()-1); |
| | | metry.put("boundaries", boundarie); |
| | | geometry.add(metry); |
| | | cityObject.put("geometry", geometry); |
| | | jsonObject.getJSONObject("CityObjects").put("UUID_"+UUID.randomUUID().toString(), cityObject); |
| | | jsonObject.getJSONObject("CityObjects").put("UUID_" + UUID.randomUUID().toString(), cityObject); |
| | | } |
| | | long times=System.currentTimeMillis(); |
| | | String pointPath=path + times + "\\管点.json"; |
| | | File dirFile=new File(path + times); |
| | | if (!dirFile.exists()){ |
| | | long times = System.currentTimeMillis(); |
| | | String pointPath = path + times + "\\管点.json"; |
| | | File dirFile = new File(path + times); |
| | | if (!dirFile.exists()) { |
| | | dirFile.mkdirs(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(pointPath); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | SemUtils.cityJsonToSem(pointPath,path + times + "\\管点.sem"); |
| | | return success(pointPath); |
| | | } |
| | | |
| | | @ApiOperation(value = "管线转cityjson") |
| | | @GetMapping(value = "/lineToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> lineToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { |
| | | String path = outPath + "\\line\\"; |
| | | List<Map<String, Object>> list = ShpReadUtils.readPointShp(shpPath); |
| | | JSONObject jsonObject = getModule("linemodule.json"); |
| | | for (Map<String, Object> map : list |
| | | ) { |
| | | //拼装基础信息 |
| | | JSONObject cityObject = new JSONObject(); |
| | | cityObject.put("type", "+PipeLine"); |
| | | JSONObject attribute = new JSONObject(); |
| | | attribute.put("name", map.get("msfs")); |
| | | JSONArray geometry = new JSONArray(); |
| | | JSONObject metry = new JSONObject(); |
| | | metry.put("type", "MultiLineString"); |
| | | metry.put("lod", 0); |
| | | JSONArray boundarie = new JSONArray(); |
| | | JSONArray array = JSONObject.parseObject(map.get("the_geom").toString()).getJSONArray("coordinates"); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | JSONObject object = JSONObject.parseObject(array.get(i).toString()); |
| | | jsonObject.getJSONArray("vertices").add(ProjectionToGeographicUtil.getPoint(Double.valueOf(object.get("x").toString()),Double.valueOf(object.get("y").toString()))); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()-1); |
| | | } |
| | | JSONArray jsonArray=new JSONArray(); |
| | | jsonArray.add(boundarie); |
| | | metry.put("boundaries", jsonArray); |
| | | JSONArray metryArray=new JSONArray(); |
| | | metryArray.add(metry); |
| | | cityObject.put("geometry",metryArray); |
| | | cityObject.put("attributes",attribute); |
| | | cityObject.put("attributes", attribute); |
| | | geometry.add(metry); |
| | | jsonObject.getJSONObject("CityObjects").put("UUID_" + UUID.randomUUID().toString(), cityObject); |
| | | } |
| | | long times = System.currentTimeMillis(); |
| | | String pointPath = path + times + "\\管线.json"; |
| | | File dirFile = new File(path + times); |
| | | if (!dirFile.exists()) { |
| | | dirFile.mkdirs(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(pointPath); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | SemUtils.cityJsonToSem(pointPath, path + times + "\\管线.sem"); |
| | | return success(pointPath); |
| | | } |
| | | @ApiOperation(value = "地形转cityjson") |
| | | @GetMapping(value = "/terrainToCityJson", produces = "application/json; charset=UTF-8") |
| | | public R<String> terrainToCityJson(@RequestParam("tifPath") String tifPath) throws Exception { |
| | | long times = System.currentTimeMillis(); |
| | | String path = outPath + "\\terrain\\"+times+"\\"; |
| | | File dirFile = new File(path+"appearance"); |
| | | if (!dirFile.exists()) { |
| | | dirFile.mkdirs(); |
| | | } |
| | | 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(); |
| | | SemUtils.cityJsonToSem(path + "terrain.json", path + "terrain.sem"); |
| | | return success(path); |
| | | } |
| | | public JSONObject getModule(String moduleName) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | try { |