|
@@ -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);
|