|
@@ -1,22 +1,23 @@
|
|
package com.fdkankan.scene.service.impl;
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
|
+import com.fdkankan.scene.dto.GeoPoint;
|
|
import com.fdkankan.scene.service.IVisionService;
|
|
import com.fdkankan.scene.service.IVisionService;
|
|
|
|
+import com.fdkankan.scene.util.CoordinateUtil;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -26,33 +27,75 @@ public class VisionServiceImpl implements IVisionService {
|
|
private FYunFileServiceInterface fYunFileService;
|
|
private FYunFileServiceInterface fYunFileService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Map<String, Object>> getPointLatAndLon(String num) {
|
|
|
|
|
|
+ public List<GeoPoint> getPointLatAndLon(String num) {
|
|
List<Map<String, Object>> list = Lists.newArrayList();
|
|
List<Map<String, Object>> list = Lists.newArrayList();
|
|
String visionTxt = fYunFileService.getFileContent(String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt");
|
|
String visionTxt = fYunFileService.getFileContent(String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt");
|
|
JSONObject visionJson = JSON.parseObject(visionTxt);
|
|
JSONObject visionJson = JSON.parseObject(visionTxt);
|
|
if(!visionJson.containsKey("sweepLocations")){
|
|
if(!visionJson.containsKey("sweepLocations")){
|
|
- return list;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
JSONArray sweepLocations = visionJson.getJSONArray("sweepLocations");
|
|
JSONArray sweepLocations = visionJson.getJSONArray("sweepLocations");
|
|
|
|
+ List<GeoPoint> geoPoints = new ArrayList<>();
|
|
for (int i = 0; i < sweepLocations.size(); ++i) {
|
|
for (int i = 0; i < sweepLocations.size(); ++i) {
|
|
JSONObject sweepItem = sweepLocations.getJSONObject(i);
|
|
JSONObject sweepItem = sweepLocations.getJSONObject(i);
|
|
- String id = sweepItem.getString("id");
|
|
|
|
- String uuid = sweepItem.getString("uuid");
|
|
|
|
|
|
+ Long id = sweepItem.getLong("id");
|
|
|
|
+ Long uuid = sweepItem.getLong("uuid");
|
|
JSONObject ggaLocation = sweepItem.getJSONObject("ggaLocation");
|
|
JSONObject ggaLocation = sweepItem.getJSONObject("ggaLocation");
|
|
|
|
+ GeoPoint geoPoint = new GeoPoint();
|
|
if (Objects.nonNull(ggaLocation)
|
|
if (Objects.nonNull(ggaLocation)
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("lon"))
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("lon"))
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("lat"))
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("lat"))
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("alt"))) {
|
|
&& StrUtil.isNotEmpty(ggaLocation.getString("alt"))) {
|
|
Map<String, Object> item = new HashMap<>();
|
|
Map<String, Object> item = new HashMap<>();
|
|
- item.put("lon", ggaLocation.getString("lon"));
|
|
|
|
- item.put("lat", ggaLocation.getString("lat"));
|
|
|
|
- item.put("alt", ggaLocation.getString("alt"));
|
|
|
|
item.put("id", id);
|
|
item.put("id", id);
|
|
item.put("uuid", uuid);
|
|
item.put("uuid", uuid);
|
|
list.add(item);
|
|
list.add(item);
|
|
|
|
+ Double[] ggaLocationGps = new Double[3];
|
|
|
|
+ ggaLocationGps[0] = ggaLocation.getDouble("lon");
|
|
|
|
+ ggaLocationGps[1] = ggaLocation.getDouble("lat");
|
|
|
|
+ ggaLocationGps[2] = ggaLocation.getDouble("alt");
|
|
|
|
+
|
|
|
|
+ geoPoint.setId(id);
|
|
|
|
+ geoPoint.setUuid(uuid);
|
|
|
|
+ geoPoint.setCoordinates(ggaLocationGps);
|
|
|
|
+ geoPoint.setStatusIndicator(ggaLocation.getInteger("StatusIndicator"));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (sweepItem.containsKey("puck")){
|
|
|
|
+ JSONObject puck = sweepItem.getJSONObject("puck");
|
|
|
|
+ Double[] floor_location = new Double[3];
|
|
|
|
+ floor_location[0] = puck.getDouble("x");
|
|
|
|
+ floor_location[1] = puck.getDouble("y");
|
|
|
|
+ floor_location[2] = puck.getDouble("z");
|
|
|
|
+ geoPoint.setLocation(floor_location);
|
|
}
|
|
}
|
|
|
|
+ geoPoints.add(geoPoint);
|
|
}
|
|
}
|
|
-
|
|
|
|
- return list;
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(geoPoints) && geoPoints.size() >= 2) {
|
|
|
|
+ Map<String, GeoPoint> res = new HashMap<>();
|
|
|
|
+ List<GeoPoint> statusFourPoints = geoPoints.stream().filter(item -> item.getStatusIndicator() == 4).collect(Collectors.toList());
|
|
|
|
+ if (statusFourPoints.size() >= 2) {
|
|
|
|
+ CoordinateUtil.divide(0, statusFourPoints.size() - 1, statusFourPoints.toArray(new GeoPoint[0]), res);
|
|
|
|
+ }else {
|
|
|
|
+ return null ;
|
|
|
|
+ }
|
|
|
|
+ for (GeoPoint geoPoint : geoPoints) {
|
|
|
|
+ if (res.containsKey("pointA")) {
|
|
|
|
+ GeoPoint pointA = res.get("pointA");
|
|
|
|
+ if (geoPoint.getId()==pointA.getId()){
|
|
|
|
+ geoPoint.setPointA(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (res.containsKey("pointB")) {
|
|
|
|
+ GeoPoint pointB = res.get("pointB");
|
|
|
|
+ if (geoPoint.getId()==pointB.getId()){
|
|
|
|
+ geoPoint.setPointB(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return geoPoints;
|
|
}
|
|
}
|
|
}
|
|
}
|