|
|
@ -734,6 +734,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
|
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
//处理 接口响应数据
|
|
|
|
private List<Map<String, Object>> getMaps(String direction, JSONArray jsonArray) throws IOException { |
|
|
|
|
|
|
@ -792,6 +793,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
} |
|
|
|
return mapList; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取车流量接口 返回 jsonArray
|
|
|
|
private JSONArray getResponseBody(String startDate, RequestParams requestParams, OkHttp okHttp) throws HttpException, IOException { |
|
|
|
JSONObject parameters = new JSONObject() { |
|
|
@ -902,12 +904,13 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取路况信息 |
|
|
|
* |
|
|
|
* @return |
|
|
|
* @throws HttpException |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JSONObject getTheCurrentCongestedSection() throws HttpException, IOException { |
|
|
|
public JSONArray getTheCurrentCongestedSection() throws HttpException, IOException { |
|
|
|
OkHttp okHttp = new OkHttp(); |
|
|
|
|
|
|
|
RequestParams requestParams = new RequestParams(); |
|
|
@ -927,10 +930,19 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
ResponseBody body = response.body(); |
|
|
|
if (body != null) { |
|
|
|
JSONArray jsonArray = JSON.parseArray(body.string()); |
|
|
|
JSONObject jsonObject = (JSONObject) jsonArray.get(0); |
|
|
|
for (Object object : jsonArray) { |
|
|
|
JSONObject jsonObject = (JSONObject) object; |
|
|
|
Integer asOneRoad = jsonObject.getInteger("as_one_road"); |
|
|
|
double endPileNo = jsonObject.getDouble("end_pile_no"); |
|
|
|
double startPileNo = jsonObject.getDouble("start_pile_no"); |
|
|
|
String stakeMark = formatNumber(startPileNo); |
|
|
|
String endMark = formatNumber(endPileNo); |
|
|
|
jsonObject.put("stakeMark", stakeMark);//当前拥堵距离
|
|
|
|
jsonObject.put("endMark", endMark);//当前拥堵距离
|
|
|
|
|
|
|
|
if (asOneRoad == UniversalEnum.ONE.getNumber()){ |
|
|
|
//as_one_road
|
|
|
|
//是否为同一条路,1-是,0-否
|
|
|
|
if (asOneRoad == UniversalEnum.ZERO.getNumber()) { |
|
|
|
|
|
|
|
String string = jsonObject.getString("list_link_info"); |
|
|
|
JSONArray jsonlist = JSON.parseArray(string); |
|
|
@ -962,14 +974,14 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
//System.out.printf("两点之间的距离为: %.2f 米%n", distanceMeters);
|
|
|
|
jsonObject.put("jam_dist", distanceMeters);//当前拥堵距离
|
|
|
|
|
|
|
|
return jsonObject; |
|
|
|
}else { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return jsonArray; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new JSONObject(); |
|
|
|
return new JSONArray(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -997,6 +1009,17 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
|
|
|
|
return nearestFacility; // 返回最近的桩号信息
|
|
|
|
} |
|
|
|
|
|
|
|
//桩号转换
|
|
|
|
public static String formatNumber(double number) { |
|
|
|
//将数字分成整数和四舍五入的小数部分
|
|
|
|
int integerPart = (int) number; |
|
|
|
int decimalPart = (int) Math.round((number - integerPart) * 1000); // 四舍五入到最接近的整数
|
|
|
|
|
|
|
|
// 将数字格式化为 "K 000+000"
|
|
|
|
String formattedString = String.format("K%03d+%03d", integerPart, decimalPart); |
|
|
|
return formattedString; |
|
|
|
} |
|
|
|
//经纬度计算距离
|
|
|
|
|
|
|
|
public static double calculateDistance(double startLat, double startLon, double endLat, double endLon) { |
|
|
@ -1019,6 +1042,8 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi |
|
|
|
|
|
|
|
// 计算两点间的距离
|
|
|
|
double distance = EARTH_RADIUS * c; |
|
|
|
// 保留两位小数,四舍五入
|
|
|
|
distance = Double.parseDouble(String.format("%.5f", distance)); |
|
|
|
|
|
|
|
return distance; |
|
|
|
} |
|
|
|