|
@@ -1,6 +1,7 @@
|
|
|
package com.fd.controller;
|
|
|
|
|
|
import com.fd.constant.Command;
|
|
|
+import com.fd.constant.MsgCode;
|
|
|
import com.fd.constant.TypeCode;
|
|
|
import com.fd.dto.PageDto;
|
|
|
import com.fd.entity.FileEntity;
|
|
@@ -11,9 +12,13 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
/**
|
|
|
* Created by Owen on 2019/11/12 0012 9:40
|
|
|
*
|
|
@@ -24,6 +29,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
@RestController
|
|
|
public class RasterController {
|
|
|
|
|
|
+ @Value("${input.file.path}")
|
|
|
+ private String INPUT_FILE_PATH;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FileServer fileServer;
|
|
|
|
|
@@ -65,6 +73,7 @@ public class RasterController {
|
|
|
String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
|
|
|
String cmd = Command.RASTER_OSGEO;
|
|
|
+ cmd = cmd.replace("@filePath", entity.getFileUrl());
|
|
|
cmd = cmd.replace("@fileName",fileName);
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
@@ -72,14 +81,88 @@ public class RasterController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private String getPrefix() {
|
|
|
- return null;
|
|
|
+ @ApiOperation("栅格数据普通坐标转换")
|
|
|
+ @GetMapping("command/transform/gdalwarp/{fileId}/")
|
|
|
+ private R cmdTansformGdalwarp(@PathVariable("fileId") Long fileId) {
|
|
|
+ log.info("run cmdTansformGdalwarp: {}", fileId);
|
|
|
+ FileEntity entity = fileServer.findById(fileId);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
+
|
|
|
+ String cmd = Command.RASTER_TRANSFORM_GDALWARP;
|
|
|
+ cmd = cmd.replace("@fileName",fileName);
|
|
|
+ log.info("cmd: {}", cmd);
|
|
|
+
|
|
|
+ Integer integer = cmdServer.exeCmdInt(cmd);
|
|
|
+ if (integer != 0) {
|
|
|
+ log.info("error command transform");
|
|
|
+ return new R(50005, MsgCode.E50005);
|
|
|
+ }
|
|
|
+
|
|
|
+ FileEntity fileEntity = new FileEntity();
|
|
|
+ fileEntity.setFileName(entity.getFileName());
|
|
|
+ // /root/gis/cesium/input/transform/@fileName.tif
|
|
|
+ fileEntity.setFileUrl(INPUT_FILE_PATH + "transform" + File.separator + entity.getFileName());
|
|
|
+ fileEntity.setCreateTime(new Date());
|
|
|
+ fileEntity.setUpdateTime(new Date());
|
|
|
+ fileEntity.setType(TypeCode.FILE_TYPE_RASTER_TIF);
|
|
|
+ fileEntity = fileServer.save(fileEntity);
|
|
|
+
|
|
|
+ return new R(200, fileEntity) ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("栅格数据严格坐标转换")
|
|
|
+ @GetMapping("command/transform/strict/gdalwarp/{fileId}/")
|
|
|
+ private R cmdTansformGdalwarpStrict(@PathVariable("fileId") Long fileId) {
|
|
|
+ log.info("run cmdTansformGdalwarpStrict: {}", fileId);
|
|
|
+ FileEntity entity = fileServer.findById(fileId);
|
|
|
+
|
|
|
+ String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
+
|
|
|
+ String step_1 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_1;
|
|
|
+ String step_2 = Command.RASTER_TRANSFORM_GDALWARP_STRICT_2;
|
|
|
+ step_1 = step_1.replace("@fileName",fileName);
|
|
|
+ step_2 = step_2.replace("@fileName",fileName);
|
|
|
+ log.info("cmd1: {}", step_1);
|
|
|
+ log.info("cmd2: {}", step_2);
|
|
|
+
|
|
|
+ Integer integer = cmdServer.exeCmd(step_1, step_2);
|
|
|
+
|
|
|
+ if (integer != 0) {
|
|
|
+ log.info("error command transform");
|
|
|
+ return new R(50005, MsgCode.E50005);
|
|
|
+ }
|
|
|
+
|
|
|
+ FileEntity fileEntity = new FileEntity();
|
|
|
+ fileEntity.setFileName(entity.getFileName());
|
|
|
+ // /root/gis/cesium/input/transform_strict/@fileName.tif
|
|
|
+ fileEntity.setFileUrl(INPUT_FILE_PATH + "transform_strict" + File.separator + entity.getFileName());
|
|
|
+ fileEntity.setCreateTime(new Date());
|
|
|
+ fileEntity.setUpdateTime(new Date());
|
|
|
+ fileEntity.setType(TypeCode.FILE_TYPE_RASTER_TIF);
|
|
|
+ fileEntity = fileServer.save(fileEntity);
|
|
|
+
|
|
|
+ return new R(200, fileEntity) ;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
String a = "112222.aa";
|
|
|
+ String b = "11/2222/aa";
|
|
|
+ String c = "11/2222/aa.zip";
|
|
|
+ String e = "/root/gis/cesium/input/test/clip.shp";
|
|
|
System.out.println(StringUtils.stripStart(a,"."));
|
|
|
System.out.println(StringUtils.substringAfter(a,"."));
|
|
|
System.out.println(StringUtils.substringBefore(a,"."));
|
|
|
+ System.out.println("c: "+ StringUtils.substringBefore(c,"/"));
|
|
|
+ System.out.println("c: "+ StringUtils.substringBeforeLast(c,"/"));
|
|
|
+ System.out.println(StringUtils.substringBefore(b,"/"));
|
|
|
+ System.out.println(StringUtils.substringBeforeLast(b,"/"));
|
|
|
+ System.out.println(StringUtils.substring(b, b.lastIndexOf("/")+1, b.length()));
|
|
|
+ System.out.println("e: " + StringUtils.substringBeforeLast(e,"/"));
|
|
|
+ System.out.println("e1: " + StringUtils.substring(e,e.indexOf("input/") +6,e.lastIndexOf("/")));
|
|
|
+// String path = StringUtils.substringBefore(e,"/");
|
|
|
}
|
|
|
}
|