|
@@ -33,6 +33,9 @@ public class VectorController {
|
|
@Value("${input.file.path}")
|
|
@Value("${input.file.path}")
|
|
private String INPUT_FILE_PATH;
|
|
private String INPUT_FILE_PATH;
|
|
|
|
|
|
|
|
+ @Value("${output.file.path}")
|
|
|
|
+ private String OUTPUT_FILE_PATH;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private FileServer fileServer;
|
|
private FileServer fileServer;
|
|
|
|
|
|
@@ -66,40 +69,79 @@ public class VectorController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @ApiOperation("矢量数据普通坐标转换")
|
|
|
|
- @GetMapping("command/transform/{fileId}/")
|
|
|
|
- private R cmdTransform(@PathVariable("fileId") Long fileId) {
|
|
|
|
- log.info("run cmdTransform: {}", 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.VECTOR_JUDGE_COORD;
|
|
|
|
+// cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
|
|
+// log.info("cmd: {}", cmd);
|
|
|
|
+//
|
|
|
|
+// boolean isJudge = cmdServer.exeCmdJudgeCoord(cmd);
|
|
|
|
+//
|
|
|
|
+// if (isJudge){
|
|
|
|
+// log.info("need to transform");
|
|
|
|
+// } else {
|
|
|
|
+// log.info("not to transform");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+// return new R(200, isJudge);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation("矢量数据判断坐标")
|
|
|
|
+ @GetMapping("command/judge/coord/{fileId}/")
|
|
|
|
+ private R cmdJudgeCoord(@PathVariable("fileId") Long fileId) {
|
|
|
|
+ log.info("run cmdJudgeCoord: {}", fileId);
|
|
FileEntity entity = fileServer.findById(fileId);
|
|
FileEntity entity = fileServer.findById(fileId);
|
|
|
|
|
|
- String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
|
- // 截取目录名称
|
|
|
|
- String fileUrl = entity.getFileUrl();
|
|
|
|
- String directoryName = StringUtils.substring(fileUrl, fileUrl.indexOf("input/") + 6, fileUrl.lastIndexOf("/"));
|
|
|
|
-
|
|
|
|
- String cmd = Command.VECTOR_TRANSFORM_OGR2OGR;
|
|
|
|
- cmd = cmd.replace("@fileName", fileName);
|
|
|
|
- cmd = cmd.replace("@directory", directoryName);
|
|
|
|
|
|
+ // 判断是否需要坐标转换
|
|
|
|
+ String cmd = Command.VECTOR_JUDGE_COORD;
|
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
log.info("cmd: {}", cmd);
|
|
log.info("cmd: {}", cmd);
|
|
|
|
|
|
- // 创建个目录,用来存转换后的文件,目录以文件名命名
|
|
|
|
- String directoryPath = INPUT_FILE_PATH + "transform" + File.separator + directoryName;
|
|
|
|
- FileUtils.createDir(directoryPath);
|
|
|
|
-
|
|
|
|
- Integer integer = cmdServer.exeCmdInt(cmd);
|
|
|
|
- if (integer != 0) {
|
|
|
|
- return new R(50005, MsgCode.E50005);
|
|
|
|
|
|
+ boolean isJudge = cmdServer.exeCmdJudgeCoord(cmd);
|
|
|
|
+
|
|
|
|
+ FileEntity fileEntity = null;
|
|
|
|
+ // 转换坐标 普通坐标转换
|
|
|
|
+ if (isJudge){
|
|
|
|
+ log.info("need to transform");
|
|
|
|
+
|
|
|
|
+ String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
|
+ // 截取目录名称
|
|
|
|
+ String fileUrl = entity.getFileUrl();
|
|
|
|
+ String directoryName = StringUtils.substring(fileUrl, fileUrl.indexOf("input/") + 6, fileUrl.lastIndexOf("/"));
|
|
|
|
+ cmd = Command.VECTOR_TRANSFORM_OGR2OGR;
|
|
|
|
+ cmd = cmd.replace("@fileName", fileName);
|
|
|
|
+ cmd = cmd.replace("@directory", directoryName);
|
|
|
|
+ log.info("cmd: {}", cmd);
|
|
|
|
+
|
|
|
|
+ // 创建个目录,用来存转换后的文件,目录以文件名命名
|
|
|
|
+ String directoryPath = INPUT_FILE_PATH + "transform" + File.separator + directoryName;
|
|
|
|
+ FileUtils.createDir(directoryPath);
|
|
|
|
+
|
|
|
|
+ Integer integer = cmdServer.exeCmdInt(cmd);
|
|
|
|
+ if (integer != 0) {
|
|
|
|
+ return new R(50005, MsgCode.E50005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fileEntity = new FileEntity();
|
|
|
|
+ fileEntity.setFileName(entity.getFileName());
|
|
|
|
+ fileEntity.setFileUrl(directoryPath + File.separator + entity.getFileName());
|
|
|
|
+ fileEntity.setCreateTime(new Date());
|
|
|
|
+ fileEntity.setUpdateTime(new Date());
|
|
|
|
+ fileEntity.setType(TypeCode.FILE_TYPE_VECTOR_SHP);
|
|
|
|
+ fileEntity = fileServer.save(fileEntity);
|
|
|
|
+ } else { // 不转换坐标
|
|
|
|
+ log.info("not to transform");
|
|
|
|
+ fileEntity = entity;
|
|
}
|
|
}
|
|
|
|
|
|
- FileEntity shpFile = new FileEntity();
|
|
|
|
- shpFile.setFileName(entity.getFileName());
|
|
|
|
- shpFile.setFileUrl(directoryPath + File.separator + entity.getFileName());
|
|
|
|
- shpFile.setCreateTime(new Date());
|
|
|
|
- shpFile.setUpdateTime(new Date());
|
|
|
|
- shpFile.setType(TypeCode.FILE_TYPE_VECTOR_SHP);
|
|
|
|
- shpFile = fileServer.save(shpFile);
|
|
|
|
|
|
|
|
- return new R(200, shpFile);
|
|
|
|
|
|
+ return new R(200, fileEntity);
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("矢量数据转geojson")
|
|
@ApiOperation("矢量数据转geojson")
|
|
@@ -135,4 +177,36 @@ public class VectorController {
|
|
|
|
|
|
return new R(200, fileEntity);
|
|
return new R(200, fileEntity);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ApiOperation("矢量数据切片")
|
|
|
|
+ @GetMapping("command/slice/{fileId}/")
|
|
|
|
+ private R cmdSlice (@PathVariable("fileId") Long fileId) {
|
|
|
|
+ log.info("run cmdSlice: {}", fileId);
|
|
|
|
+ FileEntity entity = fileServer.findById(fileId);
|
|
|
|
+
|
|
|
|
+ String fileName = StringUtils.substringBefore(entity.getFileName(), ".");
|
|
|
|
+ String outputFile = OUTPUT_FILE_PATH + fileName + ".mbtiles";
|
|
|
|
+
|
|
|
|
+ String cmd = Command.VECTOR_SLICE_TIPPECANOE;
|
|
|
|
+ cmd = cmd.replace("@inputFile", entity.getFileUrl());
|
|
|
|
+ cmd = cmd.replace("@outputFile", outputFile);
|
|
|
|
+ log.info("cmd: {}", cmd);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Integer integer = cmdServer.exeCmdInt(cmd);
|
|
|
|
+ if (integer != 0) {
|
|
|
|
+ return new R(50005, MsgCode.E50005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FileEntity fileEntity = new FileEntity();
|
|
|
|
+ fileEntity.setFileName(fileName + ".mbtiles");
|
|
|
|
+ fileEntity.setFileUrl(outputFile);
|
|
|
|
+ fileEntity.setCreateTime(new Date());
|
|
|
|
+ fileEntity.setUpdateTime(new Date());
|
|
|
|
+ fileEntity.setType(TypeCode.FILE_TYPE_VECTOR);
|
|
|
|
+ fileEntity = fileServer.save(fileEntity);
|
|
|
|
+
|
|
|
|
+ return new R(200, fileEntity);
|
|
|
|
+ }
|
|
}
|
|
}
|