Commit 7be8aa05 authored by caotao's avatar caotao

1.车辆车速原距离算法调整为插帧算法。

parent 31967a74
......@@ -238,17 +238,18 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
if (jsonObject.containsKey("data")) {
JSONObject data3 = JSONObject.parseObject(jsonObject.get("data").toString());
JSONArray points1 = JSONArray.parseArray(data3.get("points").toString());
for (int i = 0; i < points1.size(); i++) {
JSONObject jsonObject1 = JSONObject.parseObject(points1.get(i).toString());
List<Double> doubles = new ArrayList<>();
Coordinate coordinate = new Coordinate();
doubles.add(Double.valueOf(jsonObject1.get("x").toString()));
doubles.add(Double.valueOf(jsonObject1.get("y").toString()));
coordinate.setLnglat(doubles);
Double speeed = getSpeedByOriginalData(objects, Double.valueOf(jsonObject1.get("x").toString()), Double.valueOf(jsonObject1.get("y").toString()));
coordinate.setSpeed(speeed);
coordinates.add(coordinate);
}
// for (int i = 0; i < points1.size(); i++) {
// JSONObject jsonObject1 = JSONObject.parseObject(points1.get(i).toString());
// List<Double> doubles = new ArrayList<>();
// Coordinate coordinate = new Coordinate();
// doubles.add(Double.valueOf(jsonObject1.get("x").toString()));
// doubles.add(Double.valueOf(jsonObject1.get("y").toString()));
// coordinate.setLnglat(doubles);
// Double speeed = getSpeedByOriginalData(objects, Double.valueOf(jsonObject1.get("x").toString()), Double.valueOf(jsonObject1.get("y").toString()));
// coordinate.setSpeed(speeed);
// coordinates.add(coordinate);
// }
coordinates = giveSpeedToCoordinate(objects,points1);
}
}
......@@ -537,10 +538,14 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
for (int i = 0; i < objects.size() - 1; i++) {
JSONObject jsonObject1 = objects.getJSONObject(i);
JSONObject jsonObject2 = objects.getJSONObject(i+1);
Double travel1 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject1.getDoubleValue("x"), jsonObject1.getDoubleValue("y"));
Double travel2 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject2.getDoubleValue("x"), jsonObject2.getDoubleValue("y"));
log.info("travel1:"+travel1+"travel2:"+travel2);
if (travel2 >= travel1) {
if (travel2 >travel1) {
log.info("travel1:"+travel1+"travel2:"+travel2);
log.info("lat:"+startLatitude+"long:"+startLongitude);
log.info("lat:"+jsonObject1.getDoubleValue("x")+"long:"+jsonObject1.getDoubleValue("y"));
speed = jsonObject1.getDoubleValue("sp");
break;
}else{
......@@ -549,4 +554,27 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
}
return speed;
}
/**
*
* @param originalPoints 原始数据点位
* @param aMapPoints 高德纠偏之后的数据点位
* @return List<Coordinate> 处理之后的数据
*/
public ArrayList<Coordinate> giveSpeedToCoordinate(JSONArray originalPoints,JSONArray aMapPoints ){
ArrayList<Coordinate> result = new ArrayList<>();
Double rate = originalPoints.size()/(aMapPoints.size()*1.0);
for (int i = 0; i < aMapPoints.size(); i++) {
Integer speedIndex = Double.valueOf(i*rate).intValue();
JSONObject jsonObject1 = JSONObject.parseObject(aMapPoints.get(i).toString());
List<Double> doubles = new ArrayList<>();
Coordinate coordinate = new Coordinate();
doubles.add(Double.valueOf(jsonObject1.get("x").toString()));
doubles.add(Double.valueOf(jsonObject1.get("y").toString()));
coordinate.setLnglat(doubles);
coordinate.setSpeed(originalPoints.getJSONObject(speedIndex).getDoubleValue("sp"));
result.add(coordinate);
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment