|
@@ -1,7 +1,11 @@
|
|
|
package com.fdkankan.indoor.core.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.indoor.base.util.Result;
|
|
|
import com.fdkankan.indoor.core.entity.MeasurementEntity;
|
|
|
+import com.fdkankan.indoor.core.entity.dto.LineDto;
|
|
|
+import com.fdkankan.indoor.core.entity.dto.MeasureGeometry;
|
|
|
import com.fdkankan.indoor.core.entity.dto.MeasurementDto;
|
|
|
import com.fdkankan.indoor.core.mapper.MeasurementMapper;
|
|
|
import com.fdkankan.indoor.core.service.MeasurementService;
|
|
@@ -10,10 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -69,6 +70,20 @@ public class MeasurementServiceImpl extends IBaseServiceImpl implements Measurem
|
|
|
dto.setId(maxId);
|
|
|
}
|
|
|
|
|
|
+ MeasureGeometry geometry = dto.getGeometry();
|
|
|
+ Object coordinates = geometry.getCoordinates();
|
|
|
+ String type = geometry.getType();
|
|
|
+ if ("LineString".equals(type)){
|
|
|
+ List<Double[]> line = this.line(coordinates.toString());
|
|
|
+ geometry.setCoordinates(line);
|
|
|
+
|
|
|
+ // 多边型
|
|
|
+ } else {
|
|
|
+ List<List<Double[]>> polygon = this.polygon(coordinates.toString());
|
|
|
+ geometry.setCoordinates(polygon);
|
|
|
+ }
|
|
|
+ dto.setGeometry(geometry);
|
|
|
+
|
|
|
data.add(dto);
|
|
|
resIds.add(dto.getId());
|
|
|
}
|
|
@@ -83,6 +98,61 @@ public class MeasurementServiceImpl extends IBaseServiceImpl implements Measurem
|
|
|
return Result.success(changeById(sceneCode,resIds));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private List<Double[]> line(String str ){
|
|
|
+
|
|
|
+ JSONArray array = JSONArray.parseArray(str);
|
|
|
+// System.out.printf(array.toJSONString());
|
|
|
+ JSONArray a1 = array.getJSONArray(0);
|
|
|
+ JSONArray a2 = array.getJSONArray(1);
|
|
|
+
|
|
|
+ Double a1_0 = a1.getDouble(0);
|
|
|
+ Double a1_1 = a1.getDouble(1);
|
|
|
+ Double a1_2 = a1.getDouble(2);
|
|
|
+
|
|
|
+ Double a2_0 = a2.getDouble(0);
|
|
|
+ Double a2_1 = a2.getDouble(1);
|
|
|
+ Double a2_2 = a2.getDouble(2);
|
|
|
+
|
|
|
+
|
|
|
+ Double[] t1 = {a1_0, a1_1, a1_2};
|
|
|
+ Double[] t2 = {a2_0, a2_1, a2_2};
|
|
|
+
|
|
|
+ List<Double[]> list = new ArrayList<>();
|
|
|
+ list.add(t1);
|
|
|
+ list.add(t2);
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<Double[]>> polygon(String str ){
|
|
|
+
|
|
|
+ JSONArray array = JSONArray.parseArray(str);
|
|
|
+// System.out.printf(array.toJSONString());
|
|
|
+
|
|
|
+ List<List<Double[]>> r2List = new ArrayList<>();
|
|
|
+ for (Object o : array) {
|
|
|
+ JSONArray t1 = JSONArray.parseArray(o.toString());
|
|
|
+
|
|
|
+ List<Double[]> r1List = new ArrayList<>();
|
|
|
+ for (Object o1 : t1) {
|
|
|
+ JSONArray t2 = JSONArray.parseArray(o1.toString());
|
|
|
+// System.out.printf("");
|
|
|
+
|
|
|
+ Double a1_0 = t2.getDouble(0);
|
|
|
+ Double a1_1 = t2.getDouble(1);
|
|
|
+ Double a1_2 = t2.getDouble(2);
|
|
|
+
|
|
|
+ Double[] r1 = {a1_0, a1_1, a1_2};
|
|
|
+ r1List.add(r1);
|
|
|
+ }
|
|
|
+
|
|
|
+ r2List.add(r1List);
|
|
|
+ }
|
|
|
+
|
|
|
+ return r2List;
|
|
|
+ }
|
|
|
+
|
|
|
// 把更新后的值,返回给前端
|
|
|
private List<MeasurementDto> changeById(String sceneCode, List<Integer> resIds){
|
|
|
List<MeasurementDto> data = getDataBySceneCode(sceneCode);
|