wuweihao 5 rokov pred
rodič
commit
c07678a6e0

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 4 - 6
src/main/java/com/fd/constant/Command.java


+ 53 - 9
src/main/java/com/fd/controller/RasterController.java

@@ -1,5 +1,7 @@
 package com.fd.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.fd.constant.Command;
 import com.fd.constant.MsgCode;
 import com.fd.constant.TypeCode;
@@ -237,14 +239,15 @@ public class RasterController {
                     if (data != null) {
                         log.info("消费者,拿到队列中的数据data:" + data.toString());
 
-                        Integer isJudge = cmdServer.exeCmdRasterJudgeCoord(data.getStr());
+//                        Integer isJudge = cmdServer.exeCmdRasterJudgeCoord(data.getStr());
                         entity = data.getOutputFile();
 
-                        if (1000 == isJudge){
+//                        if (1000 == isJudge){
+                        if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())){
                             log.info("need to transform");
                             // 严格坐标转换
                             entity = cmdTansformGdalwarpStrict(entity);
-                        } else if (0 == isJudge){
+                        } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())){
                             log.info("not to transform");
                             // 4:未切片
                             entity.setStatus(4);
@@ -378,7 +381,6 @@ public class RasterController {
     @ApiOperation("栅格数据进度查询")
     @GetMapping("progress/{fileId}/")
     private R getProgress(@PathVariable("fileId") Long fileId) {
-//        log.info("run getProgress: {}", fileId);
         OutputFileEntity entity = rasterServer.findById(fileId);
         return new R(200, entity);
     }
@@ -407,12 +409,46 @@ public class RasterController {
 
         // 坐标处理
         String coord = entity.getCoord();
+        log.info("convert coord: {}", coord);
+        JSONArray array = JSON.parseArray(coord);
 
         String step_1 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_1;
-        String step_2 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_2;
         step_1 = step_1.replace("@inputFile", entity.getUploadPath());
         step_1 = step_1.replace("@outputFile", outFileStep1);
 
+
+        // 3位数坐标
+        if (array.size() == 3) {
+            step_1 = step_1.replace("@x", array.getString(0));
+            step_1 = step_1.replace("@y", array.getString(1));
+            step_1 = step_1.replace("@z", array.getString(2));
+            step_1 = step_1.replace("@rx","0");
+            step_1 = step_1.replace("@ry","0");
+            step_1 = step_1.replace("@rz","0");
+
+            // 坐标为空时
+        } else if (array.size() == 0) {
+            step_1 = step_1.replace("@x","0");
+            step_1 = step_1.replace("@y","0");
+            step_1 = step_1.replace("@z","0");
+            step_1 = step_1.replace("@rx","0");
+            step_1 = step_1.replace("@ry","0");
+            step_1 = step_1.replace("@rz","0");
+
+            // 6位数坐标
+        }else  {
+            step_1 = step_1.replace("@x", array.getString(0));
+            step_1 = step_1.replace("@y", array.getString(1));
+            step_1 = step_1.replace("@z", array.getString(2));
+            step_1 = step_1.replace("@rx",array.getString(3));
+            step_1 = step_1.replace("@ry",array.getString(4));
+            step_1 = step_1.replace("@rz",array.getString(5));
+        }
+
+
+        String step_2 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_2;
+
+
         String outFileStep2 = OUTPUT_FILE_PATH + "transform_strict";
         FileUtils.createDir(outFileStep2);
         outFileStep2 = outFileStep2 + File.separator + entity.getFileName();
@@ -440,12 +476,20 @@ public class RasterController {
     }
 
 
-
-
     public static void main(String[] args) {
         String [] a = {"1.1","1.2","1.3"};
-        List<String> list = Arrays.asList(a);
-        System.out.println(list.get(1));
+        System.out.println("a: " +  Arrays.toString(a));
+
+        String b = Arrays.toString(a);
+
+        JSONArray array = JSON.parseArray(b);
+        System.out.println(array.getString(2));
+        System.out.println(array.getString(1));
+        System.out.println(array.get(1));
+        System.out.println(array.get(0));
+        System.out.println(array.get(3));
+
+
     }
 
 }

+ 28 - 58
src/main/java/com/fd/controller/VectorController.java

@@ -1,5 +1,7 @@
 package com.fd.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.fd.constant.Command;
 import com.fd.constant.MsgCode;
 import com.fd.constant.TypeCode;
@@ -74,57 +76,11 @@ public class VectorController {
 
 
 
-//    @ApiOperation("上传矢量数据, coord:坐标(可以为空), 坐标格式:0,0,0,0,0,0,0")
-//    @PostMapping(value = "upload/{directoryName}/", consumes = { "multipart/form-data" })
-//    private R upload(@RequestParam("file") MultipartFile file,
-//                           @PathVariable("directoryName") String directoryName,
-//                           @RequestParam(value = "coord",required = false) String coord){
-//        log.info("run uploadVector");
-//        log.info("coord: {}", coord);
-//
-//        // 文件是否包含中文字符
-//        if (RegexUtils.regexChinese(file.getOriginalFilename())) {
-//            return new R(51005, MsgCode.E51005);
-//        }
-//
-////        FileEntity en = vectorServer.findByDirectory(directoryName);
-////        if (en != null){
-////            return new R(51006, MsgCode.E51006);
-////        }
-//
-//        return vectorServer.uploadDirectoryFile(file, directoryName, coord);
-//    }
-
-    /**
-     * 因为他是要目录上传,所以一目录名为唯一标识符。
-     * 这个模块的所有生成的文件都需要加个目录,以防重名覆盖
-     */
-//    @ApiOperation("上传矢量数据, coord:坐标(可以为空), 坐标格式:0,0,0,0,0,0,0")
-//    @PostMapping(value = "uploadMult/{directoryName}", consumes = { "multipart/form-data" })
-//    private R uploadMult(@RequestParam("file") MultipartFile[] file,
-//                     @PathVariable("directoryName") String directoryName,
-//                     @RequestParam(value = "coord",required = false) String coord){
-//        log.info("run uploadMult");
-//        log.info("coord: {}", coord);
-//
-//        R r = vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
-//
-//        OutputFileEntity entity = (OutputFileEntity) r.getData();
-//
-//        // 判断坐标
-//        entity = JudgeCoord(entity);
-//
-//        return new R(200, entity);
-//
-////        return vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
-//    }
-
-
     @ApiOperation("上传矢量数据, coord:坐标(可以为空), 坐标格式:0,0,0,0,0,0,0")
     @PostMapping(value = "uploadMult/{directoryName}", consumes = { "multipart/form-data" })
     private R uploadMult(@RequestParam("file") MultipartFile[] file,
                          @PathVariable("directoryName") String directoryName,
-                         @RequestParam("coord") String[] coord){
+                         @RequestParam(value = "coord",required = false) String[] coord){
         log.info("run uploadMult");
         log.info("coord: {}", Arrays.toString(coord));
         String strCoord = Arrays.toString(coord);
@@ -138,7 +94,6 @@ public class VectorController {
 
         return new R(200, entity);
 
-//        return vectorServer.uploadDirectoryFileMul(file, directoryName, coord);
     }
 
 
@@ -157,6 +112,7 @@ public class VectorController {
 
         Map map = vectorServer.cmdJudgeCoord(cmd);
         Integer code = (int)map.get("code");
+        log.info("judgeCoord code: {}", code);
 
 
         // 转换坐标 普通坐标转换
@@ -226,8 +182,8 @@ public class VectorController {
         entity = vectorServer.save(entity);
 
         // 坐标参数
-        String coord = entity.getCoord();
-        log.info("coord: {}", coord);
+//        String coord = entity.getCoord();
+//        log.info("coord: {}", coord);
 
         // 判断是否需要坐标转换
         String cmd = Command.VECTOR_JUDGE_COORD;
@@ -277,14 +233,21 @@ public class VectorController {
                     if (data != null) {
                         log.info("消费者,拿到队列中的数据data: " + data.toString());
 
-                        Integer isJudge = cmdServer.exeCmdJudgeCoord(data.getStr());
+//                        Integer isJudge = cmdServer.exeCmdJudgeCoord(data.getStr());
                         entity = data.getOutputFile();
 
+                        // 坐标处理
+                        String coord = entity.getCoord();
+                        log.info("convert coord: {}", coord);
+                        JSONArray arrayCoord = JSON.parseArray(coord);
+
+
                         // 转换坐标 普通坐标转换
-                        if (isJudge == 1000){
+//                        if (isJudge == 1000){
+                        if (TypeCode.COORD_SYSTEM_2000.equals(entity.getCoordType())){
                             // 普通坐标转换
                             log.info("need to general transform");
-                            if (entity.getCoord() == null) {
+                            if (arrayCoord.size() == 0) {
                                 // 没有坐标参数,执行普通坐标转换(ogrinfo)
                                 log.info("run generalCoordTransform");
                                 entity = generalCoordTransform(entity, Command.VECTOR_TRANSFORM_GENERAL);
@@ -295,11 +258,12 @@ public class VectorController {
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS80);
                             }
 
-                        } else if (isJudge == 1001) {
+//                        } else if (isJudge == 1001) {
+                        } else if (TypeCode.COORD_XIAN_1980.equals(entity.getCoordType())) {
 
                             // 严格坐标转换 (西安80转wgs84),需要参数
-                            log.info("need to strict transform, code: {}", isJudge);
-                            if (entity.getCoord() == null) {
+                            log.info("need to strict transform, CoordType: {}", entity.getCoordType());
+                            if (arrayCoord.size() == 0) {
                                 log.info("error: {}", MsgCode.E50009);
                                 entity.setStatus(7);
                                 entity.setUpdateTime(new Date());
@@ -309,7 +273,8 @@ public class VectorController {
                                 entity = strictCoordTransform(entity, Command.VECTOR_TRANSFORM_STRICT_WGS84);
                             }
 
-                        } else if (0 == isJudge){
+//                        } else if (0 == isJudge){
+                        } else if (TypeCode.COORD_WGS84.equals(entity.getCoordType())){
                             // 不转换坐标 把文件信息移动到CoordStrictPath 这路径下
                             log.info("not to transform");
 
@@ -457,8 +422,13 @@ public class VectorController {
 
         String directory = createDirectory(entity);
         directory = directory + File.separator + entity.getFileName();
+        String coord = entity.getCoord();
+        coord = coord.replace("[","");
+        coord = coord.replace("]","");
+        // 去空格
+        coord = StringUtils.deleteWhitespace(coord);
 
-        cmd = cmd.replace("@coord", entity.getCoord());
+        cmd = cmd.replace("@coord", coord);
         cmd = cmd.replace("@inputFile", entity.getUploadPath());
         cmd = cmd.replace("@outputFile", directory);
         log.info("cmd: {}", cmd);

+ 0 - 4
src/main/java/com/fd/server/impl/RasterServerImpl.java

@@ -70,10 +70,6 @@ public class RasterServerImpl implements RasterServer {
     private CmdServer cmdServer;
 
 
-//    @Autowired
-//    private LayerRepository layerRepository;
-
-
     @Override
     public R deleteById(Long fileId) {
         // 删除服务器文件

+ 5 - 6
src/main/java/com/fd/server/impl/VectorServerImpl.java

@@ -401,7 +401,7 @@ public class VectorServerImpl implements VectorServer {
 
                 // 结束命令行
                 isCmd = ps.waitFor();
-                map.put("code", isCmd);
+
 
                 // 关闭流
                 br.close();
@@ -418,28 +418,27 @@ public class VectorServerImpl implements VectorServer {
                 if (sb.toString().contains("GEOGCS[\"China Geodetic Coordinate System 2000\"")) {
                     // 需要普通坐标转换
                     isCmd = 1000;
+                    map.put("code", isCmd);
                     log.info("需要坐标转换code:{}, GEOGCS[\"China Geodetic Coordinate System 2000\"", isCmd);
                 }
 
                 if (sb.toString().contains("GEOGCS[\"Xian 1980\"")) {
                     // 需要严格坐标转换
                     isCmd = 1001;
+                    map.put("code", isCmd);
                     log.info("需要严格坐标转换code:{}, GEOGCS[\"Xian 1980\"", isCmd);
                 }
 
                 if (sb.toString().contains("GEOGCS[\"WGS 84\"")) {
                     // 不需要坐标转换
                     isCmd = 0;
+                    map.put("code", isCmd);
                     log.info("不需要坐标转换code:{}, GEOGCS[\"WGS 84\"", isCmd);
                 }
 
 
-                // 获取经纬度
-                if (sb.toString().contains("Extent: (")) {
-
-                }
-
             } else {
+                map.put("code", isCmd);
                 log.info("error exeCmd wsitFore: {}", isCmd);
             }