From d4447ca99df2cfe978ca51790dd2891e9df0d492 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Thu, 25 Jul 2024 16:19:05 +0800
Subject: [PATCH] 修改人工拍照图片保存,新增面状航线保存、修改接口,图斑文件上传格式修改
---
src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java | 78 ++++++++++++++++++++++++++-------------
1 files changed, 52 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java b/src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java
index 218745b..58501cc 100644
--- a/src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java
+++ b/src/main/java/com/dji/sample/patches/utils/ShapeFileUtil.java
@@ -22,6 +22,9 @@
import java.io.StringWriter;
import java.util.*;
+import static com.dji.sample.patches.utils.TimerUtil.getNowDay;
+import static com.dji.sample.patches.utils.TimerUtil.getNowTimeName;
+
public class ShapeFileUtil {
//将文件解压
@@ -69,37 +72,60 @@
FeatureJSON fjson = new FeatureJSON();
JSONObject geoJsonObject = new JSONObject();
geoJsonObject.put("type", "FeatureCollection");
- // 获取FeatureCollection
- FeatureCollection collection = getFeatureCollectionByShpFile(zipFile);
+ // 获取FeatureCollection
+ FeatureCollection collection = getFeatureCollectionByShpFile(zipFile);
- FeatureIterator iterator = collection.features();
- //遍历feature转为json对象
- while (iterator.hasNext()) {
- ShpDTO shpDTO = new ShpDTO();
- SimpleFeature feature = (SimpleFeature) iterator.next();
- StringWriter writer = new StringWriter();
- fjson.writeFeature(feature, writer);
- String temp = writer.toString();
- byte[] b = temp.getBytes("iso8859-1");
- temp = new String(b, "gbk");
- JSONObject json = JSONObject.parseObject(temp);
- shpDTO.setDKFW(json.getJSONObject("geometry").get("coordinates").toString());
- shpDTO.setGEO(json.getJSONObject("geometry").get("type").toString());
- shpDTO.setXZQDM(json.getJSONObject("properties").get("XZQDM").toString());
+ FeatureIterator iterator = collection.features();
+ //遍历feature转为json对象
+ while (iterator.hasNext()) {
+ ShpDTO shpDTO = new ShpDTO();
+ SimpleFeature feature = (SimpleFeature) iterator.next();
+ StringWriter writer = new StringWriter();
+ fjson.writeFeature(feature, writer);
+ String temp = writer.toString();
+ byte[] b = temp.getBytes("iso8859-1");
+ temp = new String(b, "gbk");
+ JSONObject json = JSONObject.parseObject(temp);
+ shpDTO.setDKFW(json.getJSONObject("geometry").getString("coordinates"));
+
+ if ((json.getJSONObject("geometry").get("type")) != null) {
+ shpDTO.setGEO(json.getJSONObject("geometry").getString("type"));
+ }
+
+ if ((json.getJSONObject("properties").get("XZQDM")) != null) {
+ shpDTO.setXZQDM(json.getJSONObject("properties").getString("XZQDM"));
+ }
+ if ((json.getJSONObject("properties").getDouble("XZB")) != null &&
+ json.getJSONObject("properties").getDouble("YZB") != null) {
double[] xy = getLongitudeLatitude(CoordinateSystemUtil.pointCGCStoWGS(
- json.getJSONObject("properties").getDouble("XZB"),
- json.getJSONObject("properties").getDouble("YZB")));
+ json.getJSONObject("properties").getDouble("XZB"),
+ json.getJSONObject("properties").getDouble("YZB")));
shpDTO.setXZB(xy[0]);
shpDTO.setYZB(xy[1]);
- shpDTO.setDKBH(json.getJSONObject("properties").getString("JCBH"));
- shpDTO.setJCMJ(json.getJSONObject("properties").getDouble("JCMC"));
- shpDTO.setTBLX(json.getJSONObject("properties").getString("TBLX"));
- shpDTO.setDDTC(json.getJSONObject("properties").getString("DDTC"));
- shpDTO.setHSX(json.getJSONObject("properties").getString("HSX"));
- shpDTO.setJCLX(json.getJSONObject("properties").getString("JCLX"));
- dtoList.add(shpDTO);
}
- iterator.close();
+ if ((json.getJSONObject("properties").getString("JCBH") != null)) {
+ shpDTO.setDKBH(json.getJSONObject("properties").getString("JCBH"));
+ }else {
+ shpDTO.setDKBH(getNowDay());
+ }
+ if (json.getJSONObject("properties").getDouble("JCMC") != null) {
+ shpDTO.setJCMJ(json.getJSONObject("properties").getDouble("JCMC"));
+ }
+ if (json.getJSONObject("properties").getString("TBLX") != null) {
+ shpDTO.setTBLX(json.getJSONObject("properties").getString("TBLX"));
+ }
+ if (json.getJSONObject("properties").getString("DDTC") != null) {
+ shpDTO.setDDTC(json.getJSONObject("properties").getString("DDTC"));
+ }
+ if (json.getJSONObject("properties").getString("HSX") != null) {
+ shpDTO.setHSX(json.getJSONObject("properties").getString("HSX"));
+ }
+ if (json.getJSONObject("properties").getString("JCLX") != null) {
+ shpDTO.setJCLX(json.getJSONObject("properties").getString("JCLX"));
+ }
+ dtoList.add(shpDTO);
+ }
+ iterator.close();
return dtoList;
}
--
Gitblit v1.9.3