| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.google.common.io.Resources; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.dto.GeDb; |
| | | import com.se.simu.domain.dto.GeLayer; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.*; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api(tags = "仿ç管ç") |
| | | @Slf4j |
| | |
| | | @GetMapping(value = "/testZarr", produces = "application/json; charset=UTF-8") |
| | | public R<Boolean> testZarr(@RequestParam("name") String tableName) throws IOException { |
| | | List<String> list = CsvToSQLiteUtils.getNameList(tableName); |
| | | String basePath="D:\\åå¸å
æ¶\\sem\\é¨éç«ç¹æ°æ®\\"+tableName+"\\rainfall\\"; |
| | | String path = "D:\\åå¸å
æ¶\\sem\\é¨éç«ç¹æ°æ®\\"; |
| | | String rainfall = "rainfall\\"; |
| | | String basePath = path + tableName + "\\" + rainfall; |
| | | JSONObject jsonObject = getModule("rainfallmodule.json"); |
| | | for (String src : list |
| | | ) { |
| | | File directories = new File(basePath); |
| | |
| | | ZarrUtils.saveZarrTime(basePath+src,stationRainVos); |
| | | ZipUtils.toZarr(basePath+src,basePath+src+".zip"); |
| | | System.out.println(src+"çzarræ°æ®çæ====================="); |
| | | //jsonæ¼è£
|
| | | String uuid = "UUID_" + UUID.randomUUID().toString(); |
| | | //æ¼è£
zarr |
| | | JSONObject dynamizer = new JSONObject(); |
| | | dynamizer.put("url", rainfall.replace("\\","/") + src + ".zarr"); |
| | | dynamizer.put("gmlId", uuid); |
| | | jsonObject.getJSONArray("Dynamizers").add(dynamizer); |
| | | //æ¼è£
åæ |
| | | JSONArray vertice = new JSONArray(); |
| | | vertice.add(stationRainVos.get(0).getLongitude()); |
| | | vertice.add(stationRainVos.get(0).getLatitude()); |
| | | vertice.add(0.0); |
| | | jsonObject.getJSONArray("vertices").add(vertice); |
| | | //æ¼è£
åºç¡ä¿¡æ¯ |
| | | JSONObject cityObject = new JSONObject(); |
| | | cityObject.put("type", "+Rainfall"); |
| | | JSONObject attribute = new JSONObject(); |
| | | attribute.put("name", src); |
| | | cityObject.put("attributes", attribute); |
| | | JSONArray geometry = new JSONArray(); |
| | | JSONObject metry = new JSONObject(); |
| | | metry.put("type", "MultiPoint"); |
| | | metry.put("lod", 0); |
| | | JSONArray boundarie = new JSONArray(); |
| | | boundarie.add(jsonObject.getJSONArray("vertices").size()); |
| | | metry.put("boundaries", boundarie); |
| | | geometry.add(metry); |
| | | cityObject.put("geometry", geometry); |
| | | jsonObject.getJSONObject("CityObjects").put(uuid, cityObject); |
| | | } |
| | | File jsonFile = new File(path + tableName + "\\éé¨é.json"); |
| | | if (jsonFile.exists()) { |
| | | jsonFile.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(path + tableName + "\\éé¨é.json"); |
| | | fileWriter.write(jsonObject.toJSONString()); |
| | | fileWriter.close(); |
| | | return success(true); |
| | | } |
| | | |
| | | public JSONObject getModule(String moduleName) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | try { |
| | | URL resource = Resources.getResource(moduleName); |
| | | String fileContent = Resources.toString(resource, StandardCharsets.UTF_8); |
| | | jsonObject = JSONObject.parseObject(fileContent); |
| | | System.out.println(fileContent); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return jsonObject; |
| | | } |
| | | |
| | | } |