|
@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
@@ -46,7 +47,7 @@ public class RasterController {
|
|
|
|
|
|
// 文件名全名
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
- String s = StringUtils.substringAfter(fileName, ".");
|
|
|
+ String s = StringUtils.substringAfterLast(fileName, ".");
|
|
|
if (!"tif".equals(s)) {
|
|
|
return new R(50008,MsgCode.E50008);
|
|
|
}
|
|
@@ -175,17 +176,16 @@ public class RasterController {
|
|
|
String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
// fileName_tiles
|
|
|
fileName = fileName + "_tiles";
|
|
|
- String cmd = Command.RASTER_OSGEO;
|
|
|
+ String cmd = Command.RASTER_SLICE_OSGEO;
|
|
|
cmd = cmd.replace("@filePath", entity.getFileUrl());
|
|
|
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);
|
|
|
- }
|
|
|
-
|
|
|
+// Integer integer = cmdServer.exeCmdRasterSlice(cmd);
|
|
|
+// if (integer != 0) {
|
|
|
+// log.info("error command exeCmdRasterSlice");
|
|
|
+// return new R(50005, MsgCode.E50005);
|
|
|
+// }
|
|
|
|
|
|
FileEntity fileEntity = new FileEntity();
|
|
|
fileEntity.setFileName(fileName);
|
|
@@ -195,9 +195,43 @@ public class RasterController {
|
|
|
fileEntity.setType(TypeCode.FILE_TYPE_RASTER_TIF);
|
|
|
fileEntity = fileServer.save(fileEntity);
|
|
|
|
|
|
+ // 多线程运行切片
|
|
|
+ new Thread(new RasterSliceThread(cmd, fileEntity)).start();
|
|
|
+
|
|
|
return new R(200, fileEntity) ;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public class RasterSliceThread implements Runnable{
|
|
|
+
|
|
|
+ private String cmd;
|
|
|
+
|
|
|
+ private FileEntity entity;
|
|
|
+
|
|
|
+ private RasterSliceThread(String cmd, FileEntity entity){
|
|
|
+ this.cmd = cmd;
|
|
|
+ this.entity = entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ log.warn("run RasterSliceThread");
|
|
|
+ Integer integer = cmdServer.exeCmdRasterSlice(cmd, entity);
|
|
|
+ if (integer != 0) {
|
|
|
+ log.info("error command exeCmdRasterSlice");
|
|
|
+// return new R(50005, MsgCode.E50005);
|
|
|
+ // 如果命令运行失败,删除刚才创建的实体类
|
|
|
+ fileServer.deleteById(entity.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// // 需要告诉前端,当状态为1是,才是可以的
|
|
|
+// entity.setStatus(1);
|
|
|
+// fileServer.save(entity);
|
|
|
+
|
|
|
+ log.warn("end RasterSliceThread");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 严格坐标转换
|
|
|
private FileEntity cmdTansformGdalwarpStrict(Long fileId){
|
|
|
log.info("run cmdTansformGdalwarpStrict: {}", fileId);
|
|
@@ -233,21 +267,46 @@ public class RasterController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // String a = "112222.zip";
|
|
|
+// 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("After: " + StringUtils.substringAfter(a, "."));
|
|
|
+// System.out.println("before: " + 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("/")));
|
|
|
+// System.out.println("===========================================");
|
|
|
+// System.out.println();
|
|
|
+//
|
|
|
+// System.out.println("a: " + StringUtils.substringAfterLast(a, "."));
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
- String a = "112222.zip";
|
|
|
- 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("After: "+StringUtils.substringAfter(a,"."));
|
|
|
- System.out.println("before: "+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,"/");
|
|
|
+ String a = "0...10...20...30...40...50...60...70...80...90...100.....10..11";
|
|
|
+ String b = "...10";
|
|
|
+ String c = "...10...20";
|
|
|
+ String d = "...10...100";
|
|
|
+ String re = "\\.\\.\\.";
|
|
|
+ String r1 = "...";
|
|
|
+// String s = a.replaceAll(re, "@");
|
|
|
+ String rr = "\\.\\.\\.[0-9]{2,3}";
|
|
|
+ System.out.println("b: " + b.matches(rr));
|
|
|
+ System.out.println("c: " + c.matches(rr));
|
|
|
+
|
|
|
+ System.out.println("c: " + StringUtils.substring(c, -2));
|
|
|
+ System.out.println("d: " + StringUtils.substring(d, -2));
|
|
|
+
|
|
|
+ System.out.println("a: " + StringUtils.contains(a, "..."));
|
|
|
+
|
|
|
+ System.out.println("d: " + StringUtils.substring(d, -6));
|
|
|
+ System.out.println("c: " + StringUtils.substring(c, -6));
|
|
|
+
|
|
|
+ System.out.println("a: " + a.matches(r1));
|
|
|
+
|
|
|
}
|
|
|
}
|