Commit a7251597 authored by zhuangzhuang's avatar zhuangzhuang

11.16--优化地图显示点

parent b1cbc7d8
...@@ -2,7 +2,6 @@ package com.example.tdl.util; ...@@ -2,7 +2,6 @@ package com.example.tdl.util;
public class MapUtils { public class MapUtils {
//private static double EARTH_RADIUS = 6378.137;
private static double EARTH_RADIUS = 6371.393; private static double EARTH_RADIUS = 6371.393;
private static double rad(double d) private static double rad(double d)
{ {
...@@ -27,20 +26,28 @@ public class MapUtils { ...@@ -27,20 +26,28 @@ public class MapUtils {
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS; s = s * EARTH_RADIUS;
s = Math.round(s * 1000); s = Math.round(s * 1000);
// System.out.println(s+"----------------");
return s; return s;
} }
//计算速度 //计算速度
public static double getSpeed(double lat1, double lng1, double lat2, double lng2,Long time){ public static double getSpeed(double lat1, double lng1, double lat2, double lng2,Long time){
if(time ==0){
return 0d;
}
double s = getDistance( lat1, lng1, lat2, lng2); double s = getDistance( lat1, lng1, lat2, lng2);
double speed = (double) s/time;
if(s <1000 || s> 10000){ if(s <1000 || s> 10000){
return 0; //计算速度
if(speed>250 || speed <3.3){
return 0;
}
return s/time;
}else{
return s/time;
} }
return s/time;
}
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(MapUtils.getDistance(29.490295,106.486654,29.615467,106.581515)); System.out.println(MapUtils.getDistance(29.490295,106.486654,29.615467,106.581515));
......
package com.example.tdl.util; package com.example.tdl.util;
import org.apache.commons.lang3.StringUtils;
import java.io.*; import java.io.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
......
...@@ -74,10 +74,6 @@ public class DataController { ...@@ -74,10 +74,6 @@ public class DataController {
@Autowired @Autowired
private ProbesService probesService; private ProbesService probesService;
// @Autowired
// private InfluxDBService influxDBService;
@Autowired @Autowired
private AlarmLogService alarmLogService; private AlarmLogService alarmLogService;
...@@ -153,7 +149,11 @@ public class DataController { ...@@ -153,7 +149,11 @@ public class DataController {
//解析经纬度数据 //解析经纬度数据
List<LocationDataVo> locationDataVos = new ArrayList<>(); List<LocationDataVo> locationDataVos = new ArrayList<>();
if (queryResult.getResults().get(0).getSeries() != null) { if (queryResult.getResults().get(0).getSeries() != null) {
locationDataVos = getData(queryResult); if(searchLocationVo.getTransportationNo().equals("CHN20181016G3039")){
locationDataVos =getLocation(queryResult);
}else{
locationDataVos = getData(queryResult);
}
}else{ }else{
return gson.toJson(locationDataVoList); return gson.toJson(locationDataVoList);
} }
...@@ -161,9 +161,9 @@ public class DataController { ...@@ -161,9 +161,9 @@ public class DataController {
String sql2 = ""; String sql2 = "";
if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) { if (resultCircuitVo.getEndTime() != null && resultCircuitVo.getEndTime() != 0) {
Long time = resultCircuitVo.getEndTime() * 1000000l; Long time = resultCircuitVo.getEndTime() * 1000000l;
sql2 = "SELECT \"a1\" FROM \"tdl_policy\".\"" + device + "\"where \"event\" = 'Shock event' and \"a1\" >= 1.5 and time >= " + startTime + " and time<=" + time + " ORDER BY time"; sql2 = "SELECT \"a1\" FROM \"tdl_policy\".\"" + device + "\" where \"event\" = 'Shock event' and \"a1\" >= 1.5 and time >= " + startTime + " and time<=" + time + " ORDER BY time";
} else { } else {
sql2 = "SELECT \"a1\" FROM \"tdl_policy\".\"" + device + "\"where \"event\" = 'Shock event' and \"a1\" >= 1.5 and time >= " + startTime + " ORDER BY time"; sql2 = "SELECT \"a1\" FROM \"tdl_policy\".\"" + device + "\" where \"event\" = 'Shock event' and \"a1\" >= 1.5 and time >= " + startTime + " ORDER BY time";
} }
QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2, database)); QueryResult queryResult2 = influxDBTemplate.query(new Query(sql2, database));
List<String> timeList = new ArrayList<>(); List<String> timeList = new ArrayList<>();
...@@ -627,9 +627,9 @@ public class DataController { ...@@ -627,9 +627,9 @@ public class DataController {
Double lng4 = Double.parseDouble(values.get(i+3).get(1).toString()); Double lng4 = Double.parseDouble(values.get(i+3).get(1).toString());
Double lat4 = Double.parseDouble(values.get(i+3).get(2).toString()); Double lat4 = Double.parseDouble(values.get(i+3).get(2).toString());
//获取运行时间 //获取运行时间
Double speed1 = MapUtils.getSpeed(lat1, lng1,lat2,lng2,(Long.valueOf(time2)-Long.valueOf(time1))/60000); Double speed1 = MapUtils.getSpeed(lat1, lng1,lat2,lng2,(Long.valueOf(time2)-Long.valueOf(time1))/1000);
Double speed2 = MapUtils.getSpeed(lat2, lng2,lat3,lng3,(Long.valueOf(time3)-Long.valueOf(time2))/60000); Double speed2 = MapUtils.getSpeed(lat2, lng2,lat3,lng3,(Long.valueOf(time3)-Long.valueOf(time2))/1000);
Double speed3 = MapUtils.getSpeed(lat3, lng3,lat4,lng4,(Long.valueOf(time4)-Long.valueOf(time3))/60000); Double speed3 = MapUtils.getSpeed(lat3, lng3,lat4,lng4,(Long.valueOf(time4)-Long.valueOf(time3))/1000);
//对比三个速度值,如果三者相差很小直接忽略 //对比三个速度值,如果三者相差很小直接忽略
Math.abs(speed1-speed2) ; Math.abs(speed1-speed2) ;
Math.abs(speed3-speed2); Math.abs(speed3-speed2);
...@@ -647,7 +647,7 @@ public class DataController { ...@@ -647,7 +647,7 @@ public class DataController {
Double lat1 = Double.parseDouble(values.get(i).get(2).toString()); Double lat1 = Double.parseDouble(values.get(i).get(2).toString());
Double lng2 = Double.parseDouble(values.get(i+1).get(1).toString()); Double lng2 = Double.parseDouble(values.get(i+1).get(1).toString());
Double lat2 = Double.parseDouble(values.get(i+1).get(2).toString()); Double lat2 = Double.parseDouble(values.get(i+1).get(2).toString());
Double speed2 = MapUtils.getSpeed(lat1, lng1,lat2,lng2,(Long.valueOf(time2)-Long.valueOf(time1))/60000); Double speed2 = MapUtils.getSpeed(lat1, lng1,lat2,lng2,(Long.valueOf(time2)-Long.valueOf(time1))/1000);
if(speed2 >0){ if(speed2 >0){
historyData.setTime(time1); historyData.setTime(time1);
historyData.setLng(lng1); historyData.setLng(lng1);
......
...@@ -89,29 +89,30 @@ public class PicUploadController { ...@@ -89,29 +89,30 @@ public class PicUploadController {
fb.setMessage(i18n.getMessage(request,"truckPictureDimension")); fb.setMessage(i18n.getMessage(request,"truckPictureDimension"));
return gson.toJson(fb); return gson.toJson(fb);
} }
}else if("warehouse".equals(imageType)){ }else if("warehouse".equals(imageType)) {
if(sourceImg.getWidth()>150){ if (sourceImg.getWidth() > 150) {
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warePictureDimension")); fb.setMessage(i18n.getMessage(request, "warePictureDimension"));
return gson.toJson(fb); return gson.toJson(fb);
}
if(sourceImg.getHeight()>120){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"warePictureDimension"));
return gson.toJson(fb);
} }
}else if("company".equals(imageType)){ if (sourceImg.getHeight() > 120) {
if(sourceImg.getWidth()>150){
fb.setCode(0); fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"comPictureDimension")); fb.setMessage(i18n.getMessage(request, "warePictureDimension"));
return gson.toJson(fb); return gson.toJson(fb);
}
if(sourceImg.getHeight()>200){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
return gson.toJson(fb);
} }
} }
// }else if("company".equals(imageType)){
// if(sourceImg.getWidth()>150){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
// return gson.toJson(fb);
// }
// if(sourceImg.getHeight()>200){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
// return gson.toJson(fb);
// }
// }
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -212,18 +213,19 @@ public class PicUploadController { ...@@ -212,18 +213,19 @@ public class PicUploadController {
fb.setMessage(i18n.getMessage(request,"warePictureDimension")); fb.setMessage(i18n.getMessage(request,"warePictureDimension"));
return gson.toJson(fb); return gson.toJson(fb);
} }
}else if("company".equals(imageType)){
if(sourceImg.getWidth()>150){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
return gson.toJson(fb);
}
if(sourceImg.getHeight()>200){
fb.setCode(0);
fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
return gson.toJson(fb);
}
} }
// else if("company".equals(imageType)){
// if(sourceImg.getWidth()>150){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
// return gson.toJson(fb);
// }
// if(sourceImg.getHeight()>200){
// fb.setCode(0);
// fb.setMessage(i18n.getMessage(request,"comPictureDimension"));
// return gson.toJson(fb);
// }
// }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
fb.setCode(0); fb.setCode(0);
......
...@@ -7,7 +7,7 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver ...@@ -7,7 +7,7 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver
threadpool.corepoolsize = 30 threadpool.corepoolsize = 30
threadpool.maxpoolsize = 50 threadpool.maxpoolsize = 50
server.port=8092 server.port=9092
management.security.enabled=false management.security.enabled=false
......
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
</select> </select>
<select id="getByAlias" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCompanyVo"> <select id="getByAlias" parameterType="String" resultType="com.example.tdl.domain.vo.ResultCompanyVo">
SELECT companyNo,companyName,alias,country,city,addressDetail,tel,manager,img,themeColors,fontColors SELECT companyNo,companyName, alias,country,city,addressDetail,tel,manager,img,themeColors,fontColors
from company WHERE state=1 AND alias=#{alias,jdbcType=VARCHAR} from company WHERE state=1 AND alias=#{alias,jdbcType=VARCHAR} limit 1
</select> </select>
<update id="updateImg" parameterType="String"> <update id="updateImg" parameterType="String">
......
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