|
@@ -39,10 +39,18 @@ public class RasterController {
|
|
|
private CmdServer cmdServer;
|
|
|
|
|
|
|
|
|
- @ApiOperation("上传栅格数据")
|
|
|
+ @ApiOperation("上传栅格数据,只能上传tif文件")
|
|
|
@PostMapping(value = "upload", consumes = { "multipart/form-data" })
|
|
|
private R upload(@RequestParam("file") MultipartFile file){
|
|
|
log.info("run upload");
|
|
|
+
|
|
|
+ // 文件名全名
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String s = StringUtils.substringAfter(fileName, ".");
|
|
|
+ if (!"tif".equals(s)) {
|
|
|
+ return new R(50008,MsgCode.E50008);
|
|
|
+ }
|
|
|
+
|
|
|
return fileServer.uploadBigFile(file, TypeCode.FILE_TYPE_RASTER_TIF);
|
|
|
}
|
|
|
|
|
@@ -64,18 +72,111 @@ public class RasterController {
|
|
|
return fileServer.deleteById(fileId);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("栅格数据判断坐标")
|
|
|
+ @GetMapping("command/judge/coord/{fileId}/")
|
|
|
+ private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
|
+ log.info("run cmdJudgeCoord: {}", fileId);
|
|
|
+ FileEntity entity = fileServer.findById(fileId);
|
|
|
+
|
|
|
+ String cmd = Command.RASTER_JUDGE_COORD;
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
|
+ log.info("cmd: {}", cmd);
|
|
|
+
|
|
|
+ Integer isJudge = cmdServer.exeCmdRasterJudgeCoord(cmd);
|
|
|
+
|
|
|
+ if (1000 == isJudge){
|
|
|
+ log.info("need to transform");
|
|
|
+ // 严格坐标转换
|
|
|
+ entity = cmdTansformGdalwarpStrict(fileId);
|
|
|
+ } else if (0 == isJudge){
|
|
|
+ log.info("not to transform");
|
|
|
+ } else {
|
|
|
+ log.info("error exeCmd");
|
|
|
+ return new R(50005, MsgCode.E50005);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return new R(200, entity);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
+// @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) ;
|
|
|
+// }
|
|
|
|
|
|
- @ApiOperation("栅格数据普通坐标转换")
|
|
|
- @GetMapping("command/transform/gdalwarp/{fileId}/")
|
|
|
- private R cmdTansformGdalwarp(@PathVariable("fileId") Long fileId) {
|
|
|
- log.info("run cmdTansformGdalwarp: {}", fileId);
|
|
|
+ @ApiOperation("栅格数据切片命令")
|
|
|
+ @GetMapping("command/osgeo/{fileId}/")
|
|
|
+ private R cmdOsgeo(@PathVariable("fileId") Long fileId) {
|
|
|
+ log.info("run cmdOsgeo: {}", fileId);
|
|
|
FileEntity entity = fileServer.findById(fileId);
|
|
|
|
|
|
String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
-
|
|
|
- String cmd = Command.RASTER_TRANSFORM_GDALWARP;
|
|
|
+ // fileName_tiles
|
|
|
+ fileName = fileName + "_tiles";
|
|
|
+ String cmd = Command.RASTER_OSGEO;
|
|
|
+ cmd = cmd.replace("@filePath", entity.getFileUrl());
|
|
|
cmd = cmd.replace("@fileName",fileName);
|
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
@@ -85,10 +186,10 @@ public class RasterController {
|
|
|
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.setFileName(fileName);
|
|
|
+ fileEntity.setFileUrl(INPUT_FILE_PATH + fileName);
|
|
|
fileEntity.setCreateTime(new Date());
|
|
|
fileEntity.setUpdateTime(new Date());
|
|
|
fileEntity.setType(TypeCode.FILE_TYPE_RASTER_TIF);
|
|
@@ -97,10 +198,8 @@ public class RasterController {
|
|
|
return new R(200, fileEntity) ;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @ApiOperation("栅格数据严格坐标转换")
|
|
|
- @GetMapping("command/transform/strict/gdalwarp/{fileId}/")
|
|
|
- private R cmdTansformGdalwarpStrict(@PathVariable("fileId") Long fileId) {
|
|
|
+ // 严格坐标转换
|
|
|
+ private FileEntity cmdTansformGdalwarpStrict(Long fileId){
|
|
|
log.info("run cmdTansformGdalwarpStrict: {}", fileId);
|
|
|
FileEntity entity = fileServer.findById(fileId);
|
|
|
|
|
@@ -117,7 +216,8 @@ public class RasterController {
|
|
|
|
|
|
if (integer != 0) {
|
|
|
log.info("error command transform");
|
|
|
- return new R(50005, MsgCode.E50005);
|
|
|
+ return null;
|
|
|
+// return new R(50005, MsgCode.E50005);
|
|
|
}
|
|
|
|
|
|
FileEntity fileEntity = new FileEntity();
|
|
@@ -129,42 +229,9 @@ public class RasterController {
|
|
|
fileEntity.setType(TypeCode.FILE_TYPE_RASTER_TIF);
|
|
|
fileEntity = fileServer.save(fileEntity);
|
|
|
|
|
|
- return new R(200, fileEntity) ;
|
|
|
+ return fileEntity;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("栅格数据切片命令")
|
|
|
- @GetMapping("command/osgeo/{fileId}/")
|
|
|
- private R cmdOsgeo(@PathVariable("fileId") Long fileId) {
|
|
|
- log.info("run cmdOsgeo: {}", fileId);
|
|
|
- FileEntity entity = fileServer.findById(fileId);
|
|
|
-
|
|
|
- String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
- // fileName_tiles
|
|
|
- fileName = fileName + "_tiles";
|
|
|
- String cmd = Command.RASTER_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);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- FileEntity fileEntity = new FileEntity();
|
|
|
- fileEntity.setFileName(fileName);
|
|
|
- fileEntity.setFileUrl(INPUT_FILE_PATH + fileName);
|
|
|
- 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.zip";
|