feat: 1. 道路自动拍摄多任务判定 2. 道路任务自动录像任务语音提示
This commit is contained in:
parent
52cd04a466
commit
1b6024d0cb
@ -11,6 +11,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.location.Location;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@ -182,7 +183,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private List<Removable> removables; // 地图上渲染的网络获取的道路任务
|
||||
private List<Removable> removablesLocality; // 地图上渲染的本地道路任务
|
||||
private HashMap<String, List<Marker>> removableHashMap;
|
||||
private List<RoadMatchEntity> roadLinkEntityList, roadMatchEntityList;
|
||||
private List<RoadMatchEntity> roadLinkEntityList/*请求到的待匹配道路数据*/, roadMatchEntityList/*已匹配起始点的道路数据*/;
|
||||
private int satelliteCount; // 卫星颗数
|
||||
private final long UN_MATCH_TIME_MAX=30*1000; // 未匹配到的时间阈值,最长为30秒
|
||||
private static double MATCH_BUFFER_DISTANCE=15e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断
|
||||
@ -202,6 +203,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private boolean locationEnable=true;
|
||||
private ImageView imgViewSettingHook; // 调起隐藏设置的按钮
|
||||
private TencentLocation oldCurrentLocation = null;
|
||||
private MediaPlayer mediaPlayer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -211,6 +213,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
|
||||
// 设置当前界面亮度为40%
|
||||
setWindowBrightness(BRIGHTNESS);
|
||||
// 初始化提示音播放器
|
||||
mediaPlayer=MediaPlayer.create(this, R.raw.ding);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@ -650,7 +654,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
matchStartDistance = MATCH_BUFFER_DISTANCE*1.5;
|
||||
}
|
||||
// 此处开始匹配起点
|
||||
List<RoadMatchEntity> matchStartList = roadLinkEntityList.stream().filter(it-> GeometryTools.createGeometry(it.getsPoint()).distance(currentPoint)<MATCH_START_BUFFER_DISTANCE).collect(Collectors.toList());
|
||||
List<RoadMatchEntity> matchStartList = roadLinkEntityList.stream()
|
||||
.filter(it-> GeometryTools.createGeometry(it.getsPoint()).distance(currentPoint)<MATCH_START_BUFFER_DISTANCE)
|
||||
.collect(Collectors.toList());
|
||||
// 判断筛选出的数据是否已经在匹配列表中,如果不存在,需要自动领取该任务、记录开始采集时间
|
||||
matchStartList = matchStartList.stream().filter(
|
||||
o -> roadMatchEntityList.stream().noneMatch(roadMatchEntity -> o.getId()==roadMatchEntity.getId())
|
||||
@ -664,54 +670,91 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
// TODO:自动发送请求领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
});
|
||||
|
||||
// 语音提醒
|
||||
if (roadMatchEntityList.isEmpty()) {
|
||||
// 当前没有已匹配的数据,提示用户“叮~捕捉任务”
|
||||
mediaPlayer.start();
|
||||
systemTTS.playText("捕捉任务");
|
||||
} else {
|
||||
// 当前存在已匹配的任务,有新匹配的任务,提示“叮~任务拍摄中”
|
||||
mediaPlayer.start();
|
||||
systemTTS.playText("任务拍摄中");
|
||||
}
|
||||
|
||||
// 将匹配到的数据加入到已匹配列表中
|
||||
roadMatchEntityList.addAll(matchStartList);
|
||||
}
|
||||
|
||||
// 尝试用当前位置点匹配已经匹配到的roadLink,如果能匹配到,需要将该点记录,如果无法匹配,则需要评估已匹配的link是否需要被剔除
|
||||
if (!roadMatchEntityList.isEmpty()) {
|
||||
// 因为单个点位只能匹配一条任务,需要获取当前点位距离所有任务最近的距离
|
||||
roadMatchEntityList.stream().forEach(it->it.setCurrentLineDistance(GeometryTools.createGeometry(it.getGeometry()).distance(currentPoint)));
|
||||
// 筛选出本次距离最近的线
|
||||
RoadMatchEntity minRoadMatchEntity = roadMatchEntityList.stream().min((o1, o2)-> {
|
||||
if (o1.getCurrentLineDistance()<o2.getCurrentLineDistance()){
|
||||
return -1;
|
||||
} else if (o1.getCurrentLineDistance()==o2.getCurrentLineDistance()) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}).get();
|
||||
|
||||
List<RoadMatchEntity> unMatchList = new ArrayList<>();
|
||||
Map<Integer, RoadMatchEntity> finishEntityMap = new HashMap<>();
|
||||
double finalMatchStartDistance = matchStartDistance;
|
||||
roadMatchEntityList.stream().forEach(
|
||||
roadMatchEntity -> {
|
||||
boolean isMatch=GeometryTools.createGeometry(roadMatchEntity.getGeometry()).distance(currentPoint)< finalMatchStartDistance; // 当前点位是否可以和link匹配到
|
||||
if (isMatch) { // 可以匹配到
|
||||
double currentDistance = roadMatchEntity.getCurrentLineDistance();
|
||||
boolean isMatch=currentDistance<= finalMatchStartDistance; // 当前点位是否可以和link匹配到
|
||||
if (minRoadMatchEntity.getId() == roadMatchEntity.getId()&&isMatch) { // 可以匹配到,并且该条数据还是最近的点
|
||||
roadMatchEntity.setMatchCount(roadMatchEntity.getMatchCount()+1);
|
||||
roadMatchEntity.setUnMatchCount(0); // 有匹配的数据,则连续未匹配个数归0
|
||||
roadMatchEntity.getMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
// 匹配到终点、或匹配距离超过90%
|
||||
if (roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER
|
||||
|| currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint()))<= finalMatchStartDistance) {
|
||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||
double currentEndDistance = currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint())); // 当前距离终点的距离
|
||||
// 记录本次的匹配距离,如果本次匹配距离大于上一次,且上一次匹配距离不为0,则结束匹配,否则继续等待匹配,设置过EndMathchTime的数据即为可以结束匹配的数据,下一次如果未匹配,也可以结束
|
||||
if (roadMatchEntity.getEndMathchTime()>0/*endMatchTime不为0,说明该数据已经匹配到终点*/&¤tEndDistance>roadMatchEntity.getLastEndDistance()) {
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
}
|
||||
} else { // 无法匹配
|
||||
// 将无法匹配的点位个数记录到对象中
|
||||
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
|
||||
roadMatchEntity.setMatchCount(0);
|
||||
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
// 判断当前是否存在已匹配的点
|
||||
if (roadMatchEntity.getMatchPointList().size()>1) { // 存在匹配的点超过1个,根据长度判断
|
||||
if (GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>UNMATCH_GIVE_UP_DISTANCE_BUFFER) {
|
||||
// 匹配距离超过20%,根据匹配点和未匹配点个数的对比率判断是否需要放弃
|
||||
if (((float)roadMatchEntity.getUnMatchPointList().size())/roadMatchEntity.getMatchPointList().size()>UNMATCH_COUNT_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
// 匹配到终点、或匹配距离超过90%
|
||||
if (roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER
|
||||
|| currentEndDistance<= finalMatchStartDistance) {
|
||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||
// 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配
|
||||
roadMatchEntity.setLastEndDistance(currentEndDistance);
|
||||
}
|
||||
} else { // 无法匹配,或当前道路并不是距离最近的数据
|
||||
// 该数据未匹配,但是如果此前已经匹配到结束点,则仍然认为匹配成功
|
||||
if (roadMatchEntity.getEndMathchTime()>0) {
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
} else {
|
||||
// 将无法匹配的点位个数记录到对象中
|
||||
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
|
||||
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
|
||||
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
// 判断当前是否存在已匹配的点
|
||||
if (roadMatchEntity.getMatchPointList().size()>1) { // 存在匹配的点超过1个,根据长度判断
|
||||
if (GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>UNMATCH_GIVE_UP_DISTANCE_BUFFER) {
|
||||
// 匹配距离超过20%,根据匹配点和未匹配点个数的对比率判断是否需要放弃
|
||||
if (((float)roadMatchEntity.getUnMatchPointList().size())/roadMatchEntity.getMatchPointList().size()>UNMATCH_COUNT_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
} else {// 当前匹配距离不超过20%,则必须有连续多个点未匹配才可以放弃该Link
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_MIDDLE_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
}
|
||||
} else {// 当前匹配距离不超过20%,则必须有连续多个点未匹配才可以放弃该Link
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_MIDDLE_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
}
|
||||
} else { // 从未匹配过的数据
|
||||
// 未匹配个数超过指定阈值,也认为数据不匹配
|
||||
if (roadMatchEntity.getMatchPointList().size()==0) { // 已匹配的个数为0
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_START_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
} else if (roadMatchEntity.getMatchPointList().size()==1) { // 已匹配的个数为1
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_MIDDLE_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
} else { // 从未匹配过的数据
|
||||
// 未匹配个数超过指定阈值,也认为数据不匹配
|
||||
if (roadMatchEntity.getMatchPointList().size()==0) { // 已匹配的个数为0
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_START_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
} else if (roadMatchEntity.getMatchPointList().size()==1) { // 已匹配的个数为1
|
||||
if (roadMatchEntity.getUnMatchCount()>UNMATCH_BUFFER_MIDDLE_BUFFER) {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -727,6 +770,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
// TODO 完成的entity数据,需要自动生成对应的数据,还需要自动复制对应的照片,通知服务器采集完成
|
||||
finishRoadTask(finishEntityMap);
|
||||
// 语音提示用户
|
||||
mediaPlayer.start();
|
||||
systemTTS.playText("拍摄完成");
|
||||
}
|
||||
|
||||
if (!unMatchList.isEmpty()) {
|
||||
@ -1278,6 +1324,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
if (gpsUtils!=null) {
|
||||
gpsUtils.unRegisterAllListener();
|
||||
}
|
||||
if (mediaPlayer!=null) {
|
||||
mediaPlayer.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +30,8 @@ public class RoadMatchEntity implements Serializable {
|
||||
private String ePoint; // 起点
|
||||
private long startMatchTime; // 开始匹配的时间
|
||||
private long endMathchTime; // 结束匹配的时间
|
||||
private double lastDistance=0; // 上次匹配到的距离
|
||||
private double currentLineDistance=0f; // 当前匹配到的距离道路线的距离
|
||||
private double lastEndDistance=0f; // 上次匹配到的距离终点的距离
|
||||
private int matchCount; // <连续>匹配到的点位个数
|
||||
private int unMatchCount; // <连续>未匹配到的点位个数
|
||||
private List<MyCoordinate> matchPointList = new ArrayList<>(); // 已匹配的点位列表
|
||||
@ -113,12 +114,12 @@ public class RoadMatchEntity implements Serializable {
|
||||
this.endMathchTime = endMathchTime;
|
||||
}
|
||||
|
||||
public double getLastDistance() {
|
||||
return lastDistance;
|
||||
public double getLastEndDistance() {
|
||||
return lastEndDistance;
|
||||
}
|
||||
|
||||
public void setLastDistance(double lastDistance) {
|
||||
this.lastDistance = lastDistance;
|
||||
public void setLastEndDistance(double lastEndDistance) {
|
||||
this.lastEndDistance = lastEndDistance;
|
||||
}
|
||||
|
||||
public int getMatchCount() {
|
||||
@ -153,6 +154,14 @@ public class RoadMatchEntity implements Serializable {
|
||||
this.unMatchPointList = unMatchPointList;
|
||||
}
|
||||
|
||||
public double getCurrentLineDistance() {
|
||||
return currentLineDistance;
|
||||
}
|
||||
|
||||
public void setCurrentLineDistance(double currentLineDistance) {
|
||||
this.currentLineDistance = currentLineDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.navinfo.outdoor.http;
|
||||
|
||||
public class HttpInterface {
|
||||
public static final String IP1 = "http://172.23.138.133:9999/m4";//测试接口
|
||||
public static final String IP = "http://172.23.138.133:9999/m4";//测试接口
|
||||
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//测试接口-外网
|
||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||
public static final String USER_PATH = "/user/";//我的
|
||||
public static final String MSG_LIST_PATH = "/msgList/";//发现
|
||||
public static final String USER_LOGIN_PATH = "/userlogin/";//登录
|
||||
|
BIN
app/src/main/res/raw/ding.wav
Normal file
BIN
app/src/main/res/raw/ding.wav
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user