Commit 7bcd0232 by yangyang

弱轨迹涉及调整提交(标准)

parent f97a68dd
......@@ -50,12 +50,18 @@ public class SkTrail extends Model<SkTrail> implements Comparable<SkTrail>{
@ApiModelProperty(value = "近照片")
private String nearimglist;
@ApiModelProperty(value = "13位时间戳")
@ApiModelProperty(value = "13位时间戳开始")
private String time;
@ApiModelProperty(value = "过车时间(年月日 时分秒)")
@ApiModelProperty(value = "开始时间(年月日 时分秒)")
private String date;
@ApiModelProperty(value = "结束时间(年月日 时分秒)")
private String jssj;
@ApiModelProperty(value = "13位时间戳结束")
private String jssjtime;
@ApiModelProperty(value = "地址")
private String address;
/**
......
......@@ -15,6 +15,10 @@ public class Coordinate {
private double x;
@ApiModelProperty(value = "y轴")
private double y;
@ApiModelProperty(value = "开始时间")
private String kssjtime;
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "结束时间")
private String jssjtime;
}
package com.founder.commonutils.util.map;
import com.founder.commonutils.model.newPublicEntity.TogetherEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import java.util.*;
public class LCSS {
......@@ -33,6 +37,9 @@ public class LCSS {
public Map lcs(List<Coordinate> l1, List<Coordinate> l2, int radius,int minutes) {
long timeItervalMinutes = minutes * 60 * 1000;
// 弱轨迹转换
l1 = getRgjSjd(l1, timeItervalMinutes);
l2 = getRgjSjd(l2, timeItervalMinutes);
Map map = new HashMap();
Set<Coordinate> loneMz = new HashSet<>();
Set<Coordinate> ltwoMz = new HashSet<>();
......@@ -74,6 +81,7 @@ public class LCSS {
//归一化处理
return map;
}
// 两点间距离获取(米)
private static double EARTH_RADIUS = 6371.393;
private static double rad(double d) {
return d * Math.PI / 180.0;
......@@ -89,4 +97,47 @@ public class LCSS {
s = Math.round(s * 1000);
return s;
}
// 弱轨迹转换
public List<Coordinate> getRgjSjd(List<Coordinate> list,long timeItervalMillns){
List<Coordinate> resultList = new ArrayList<>();
list.stream().forEach(a->{
a.setKssjtime(a.getTime());
//如果是弱轨迹则传入时间段StartTime EndTime
if (a.getX() != 0D && a.getY() != 0D && StringUtils.isNotBlank(a.getKssjtime()) && StringUtils.isNotBlank(a.getJssjtime())) {
List<Long> timeList = getTimeSplitList(Long.valueOf(a.getKssjtime()), Long.valueOf(a.getJssjtime()), timeItervalMillns);
if (timeList != null && timeList.size() != 0) {
Iterator<Long> it = timeList.iterator();
while (it.hasNext()) {
Coordinate b = new Coordinate();
BeanUtils.copyProperties(a,b);
b.setTime(String.valueOf(it.next()));
resultList.add(b);
}
}
}
});
if(resultList.size()>0){
return resultList;
}
return list;
}
/**
* 将开始时间和结束时间的时间段转为时间点*/
public List<Long> getTimeSplitList(long startTime, long endTime, long timeItervalMillns) {
List resultList = new ArrayList();
resultList.add(startTime);
do {
startTime += timeItervalMillns;
if (startTime < endTime) {
resultList.add(startTime);
} else if (startTime >= endTime){
resultList.add(endTime);
break;
}
}
while (startTime < endTime);
return resultList;
}
}
\ No newline at end of file
......@@ -35,14 +35,11 @@ public class SkbsController {
@OperLog(message = "轨迹分析_伴随分析",operation = OperationType.QUERY)
@ApiOperation(value = "轨迹分析_伴随分析")
public MapRestResult getSkbs(@RequestBody SkbsParam skbsParam){
//获取需要伴随的轨迹
// List<SkTrail> list=getYToGjInfo(requestParams);
//转换轨迹
List gjlist=getYToGjInfo(skbsParam.getRequestParams(),skbsParam.getList());
//进行伴随分析
List resultList=getSkbsfx(skbsParam.getRequestParams(),gjlist);
return new MapRestResult(200,"ok",resultList);
// return resultList;
}
/**
......@@ -69,14 +66,11 @@ public class SkbsController {
a.setW(Double.parseDouble(var.getY()));
a.setAddress(var.getAddress());
a.setObjectValue(var.getObjectvalue());
a.setObjectType(var.getObjecttype());
a.setObjectType(var.getObjecttype());// 轨迹类型
a.setStartTime(var.getTime());// 开始时间戳13
a.setEndTime(var.getJssjtime());// 结束时间戳13
//如果是强轨迹则传入时间点 Time
if(StringUtils.isNotBlank(var.getTime())){
a.setTimestamp(Long.parseLong(var.getTime()));
resultList.add(a);
}
//如果是强轨迹则传入时间段StartTime EndTime
//如果是弱轨迹则传入时间段StartTime EndTime
if (a.getJ() != 0D && a.getW() != 0D && StringUtils.isNotBlank(a.getStartTime()) && StringUtils.isNotBlank(a.getEndTime())) {
a.setStarttimestamp(getDateMinusToStr(a.getStartTime(), 0));
a.setEndtimestamp(getDateMinusToStr(a.getEndTime(), 0));
......@@ -88,11 +82,9 @@ public class SkbsController {
resultList.add(a);
}
}
} else if (a.getJ() != 0D && a.getW() != 0D && StringUtils.isNotBlank(a.getStartTime())) {
a.setTimestamp(getDateMinusToStr(a.getStartTime(), 0));
resultList.add(a);
} else if (a.getJ() != 0D && a.getW() != 0D && StringUtils.isNotBlank(a.getEndTime())) {
a.setTimestamp(getDateMinusToStr(a.getStartTime(), 0));
} //如果是强轨迹则传入时间点 Time
else if(StringUtils.isNotBlank(var.getTime())){
a.setTimestamp(Long.parseLong(var.getTime()));
resultList.add(a);
}
}
......@@ -145,9 +137,6 @@ public class SkbsController {
* list2为所有数据的集合,将集合按轨迹开始时间排序
* */
Collections.sort(paramList, Comparator.comparing(TogetherEntity::getTimestamp));
// 根据ObjectValue去重
List<TogetherEntity> resultListDistinct = resultList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
-> new TreeSet<>(Comparator.comparing(TogetherEntity :: getObjectValue))), ArrayList::new));
for (int i = 1; i < paramList.size(); i++) {
TogetherEntity a = paramList.get(i - 1);
......@@ -163,7 +152,7 @@ public class SkbsController {
long timeIterval = t1.getTimestamp() - t.getTimestamp();
double s = getDistance(t.getJ(), t.getW(), t1.getJ(), t1.getW());
if (s < requestParams.getRadius() && timeIterval < timeItervalMinutes) {
resultList.add(t);
resultList.add(t);// 将该地址放入
t1.setTimeIterval(timeIterval);
t1.setTimeItervalStr(String.valueOf(timeIterval));
......@@ -176,7 +165,7 @@ public class SkbsController {
sbdescripText.append(" 米");
t1.setDescripText(sbdescripText.toString());
resultList.add(t1);
resultList.add(t1);// 比中地址放入
}
}
}
......
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