fix: 修改自动匹配策略
This commit is contained in:
parent
b2a03b8d8b
commit
49e428c037
@ -199,18 +199,17 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private HashMap<String, List<Marker>> removableHashMap;
|
||||
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米使用简易判断
|
||||
private static double MATCH_START_BUFFER_DISTANCE=30e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断
|
||||
private static double MATCH_START_BUFFER_DISTANCE=50e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断
|
||||
private static double MATCH_BUFFER_DISTANCE=30e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断
|
||||
private static float /*UNMATCH_GIVE_UP_DISTANCE_BUFFER = 0.2f*//*放弃的距离匹配阈值*//*, */MATCH_CONFIRM_FINISH_BUFFER=0.75f/*完全匹配的距离阈值*/;
|
||||
private static int /*UNMATCH_BUFFER_START_BUFFER = 5*//*匹配开始后连续未匹配的个数*//*,*/ UNMATCH_BUFFER_MIDDLE_BUFFER = 20/*匹配过程中连续未匹配的个数*/;
|
||||
// private static float UNMATCH_COUNT_BUFFER = UNMATCH_GIVE_UP_DISTANCE_BUFFER/(1-UNMATCH_GIVE_UP_DISTANCE_BUFFER);
|
||||
private final String tmpPicFoldPath = Constant.PICTURE_FOLDER+"/tmp";
|
||||
private LocationRecorderDao recorderDao;
|
||||
private PoiDao poiDao;
|
||||
private SimpleDateFormat picFormatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
private Button btnClearMatch, btnStopPicture;
|
||||
private Point lastPositionPoint; // 最近一次的定位,用来过滤距离较近的点位
|
||||
private static int UNMATCH_BUFFER_START_BUFFER = 5/*匹配开始后连续未匹配的个数*/, UNMATCH_BUFFER_MIDDLE_BUFFER = 20/*匹配过程中连续未匹配的个数*/;
|
||||
private static float UNMATCH_GIVE_UP_DISTANCE_BUFFER = 0.2f/*放弃的距离匹配阈值*/, MATCH_CONFIRM_FINISH_BUFFER=0.9f/*完全匹配的距离阈值*/;
|
||||
private static float UNMATCH_COUNT_BUFFER = UNMATCH_GIVE_UP_DISTANCE_BUFFER/(1-UNMATCH_GIVE_UP_DISTANCE_BUFFER);
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
private Button btnSetting;
|
||||
private Switch locationSwitch;
|
||||
@ -349,14 +348,14 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
EditText midDistance = v.findViewById(R.id.edt_camera_setting_mid_distance);
|
||||
midDistance.setText(MATCH_BUFFER_DISTANCE*100000+"");
|
||||
|
||||
EditText startCount = v.findViewById(R.id.edt_camera_setting_start_count);
|
||||
startCount.setText(UNMATCH_BUFFER_START_BUFFER+"");
|
||||
// EditText startCount = v.findViewById(R.id.edt_camera_setting_start_count);
|
||||
// startCount.setText(UNMATCH_BUFFER_START_BUFFER+"");
|
||||
|
||||
EditText midCount = v.findViewById(R.id.edt_camera_setting_mid_count);
|
||||
midCount.setText(UNMATCH_BUFFER_MIDDLE_BUFFER+"");
|
||||
|
||||
EditText unmatchPecent = v.findViewById(R.id.edt_camera_setting_unmatch_pecent);
|
||||
unmatchPecent.setText(UNMATCH_GIVE_UP_DISTANCE_BUFFER+"");
|
||||
// EditText unmatchPecent = v.findViewById(R.id.edt_camera_setting_unmatch_pecent);
|
||||
// unmatchPecent.setText(UNMATCH_GIVE_UP_DISTANCE_BUFFER+"");
|
||||
|
||||
EditText matchPecent = v.findViewById(R.id.edt_camera_setting_match_pecent);
|
||||
matchPecent.setText(MATCH_CONFIRM_FINISH_BUFFER+"");
|
||||
@ -371,15 +370,15 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
if (!midDistance.getText().toString().isEmpty()) {
|
||||
MATCH_BUFFER_DISTANCE = Double.parseDouble(midDistance.getText().toString())/100000;
|
||||
}
|
||||
if (!startCount.getText().toString().isEmpty()) {
|
||||
UNMATCH_BUFFER_START_BUFFER = Integer.parseInt(startCount.getText().toString());
|
||||
}
|
||||
// if (!startCount.getText().toString().isEmpty()) {
|
||||
// UNMATCH_BUFFER_START_BUFFER = Integer.parseInt(startCount.getText().toString());
|
||||
// }
|
||||
if (!midCount.getText().toString().isEmpty()) {
|
||||
UNMATCH_BUFFER_MIDDLE_BUFFER = Integer.parseInt(midCount.getText().toString());
|
||||
}
|
||||
if (!unmatchPecent.getText().toString().isEmpty()) {
|
||||
UNMATCH_GIVE_UP_DISTANCE_BUFFER = Float.parseFloat(unmatchPecent.getText().toString());
|
||||
}
|
||||
// if (!unmatchPecent.getText().toString().isEmpty()) {
|
||||
// UNMATCH_GIVE_UP_DISTANCE_BUFFER = Float.parseFloat(unmatchPecent.getText().toString());
|
||||
// }
|
||||
if (!matchPecent.getText().toString().isEmpty()) {
|
||||
MATCH_CONFIRM_FINISH_BUFFER = Float.parseFloat(matchPecent.getText().toString());
|
||||
}
|
||||
@ -746,14 +745,22 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
roadMatchEntity -> {
|
||||
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()));
|
||||
if (isMatch) { // 可以匹配到
|
||||
if (minRoadMatchEntity.getId() == roadMatchEntity.getId()) { // 并且该条数据还是最近的点, 将当前点位匹配到此任务下
|
||||
// 可以匹配到,并且是最近的任务,更新任务的开始时间
|
||||
if (roadMatchEntity.getMatchPointList().size() == 0) {
|
||||
roadMatchEntity.setStartMatchTime(System.currentTimeMillis());
|
||||
}
|
||||
roadMatchEntity.setMatchCount(roadMatchEntity.getMatchCount()+1);
|
||||
roadMatchEntity.setUnMatchCount(0); // 有匹配的数据,则连续未匹配个数归0
|
||||
roadMatchEntity.getMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
}
|
||||
double currentEndDistance = currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint())); // 当前距离终点的距离
|
||||
// 记录本次的匹配距离,如果本次匹配距离大于上一次,且上一次匹配距离不为0,则结束匹配,否则继续等待匹配,设置过EndMathchTime的数据即为可以结束匹配的数据,下一次如果未匹配,也可以结束
|
||||
// 记录本次的匹配距离,如果本次匹配距离大于上一次,且上一次匹配终点时间不为0(说明已经提前匹配到终点了),则结束匹配,否则继续等待匹配,设置过EndMathchTime的数据即为可以结束匹配的数据,下一次如果未匹配,也可以结束
|
||||
if (roadMatchEntity.getEndMathchTime()>0/*endMatchTime不为0,说明该数据已经匹配到终点*/&¤tEndDistance>roadMatchEntity.getLastEndDistance()) {
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
// 更新终点时间为距离终点逐渐变大时的时间
|
||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||
}
|
||||
// 匹配到终点、或匹配距离超过90%
|
||||
if ((roadMatchEntity.getMatchPointList().size()>=2&&GeometryTools.getLineStringByMyCoordinate(roadMatchEntity.getMatchPointList()).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER)
|
||||
@ -762,40 +769,55 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
// 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配
|
||||
roadMatchEntity.setLastEndDistance(currentEndDistance);
|
||||
}
|
||||
} else { // 无法匹配,或当前道路并不是距离最近的数据
|
||||
//=============如果在匹配范围内,但是该数据并非最近的点,不需要记录匹配,也无需增加未匹配点的个数
|
||||
} else { // 无法匹配
|
||||
// 将无法匹配的点位个数记录到对象中
|
||||
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
|
||||
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
|
||||
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
|
||||
// 该数据未匹配,但是如果此前已经匹配到结束点,则仍然认为匹配成功
|
||||
if (roadMatchEntity.getEndMathchTime()>0) {
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
} else {
|
||||
// 判断当前是否存在已匹配的点
|
||||
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 { // 从未匹配过的数据
|
||||
// 未匹配个数超过指定阈值,也认为数据不匹配
|
||||
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);
|
||||
}
|
||||
// 当连续未匹配个数大于等于20个时,该任务被认为可以结束(舍弃或完成-需根据匹配到的数据长度与任务长度做对比)
|
||||
if (roadMatchEntity.getUnMatchCount()>=UNMATCH_BUFFER_MIDDLE_BUFFER) { // 连续未匹配大于阈值时
|
||||
List<MyCoordinate> matchPointList = roadMatchEntity.getMatchPointList();
|
||||
if (matchPointList == null || matchPointList.size()<2) { // 已匹配的点位不足2个,无法计算长度,直接放弃该任务
|
||||
unMatchList.add(roadMatchEntity);
|
||||
} else {
|
||||
if (GeometryTools.getLineStringByMyCoordinate(matchPointList).getLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER) { // 已匹配距离与任务长度距离比例超过指定阈值,该任务可完成
|
||||
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
|
||||
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
} else {
|
||||
unMatchList.add(roadMatchEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
// // 该数据未匹配,但是如果此前已经匹配到结束点,则仍然认为匹配成功
|
||||
// if (roadMatchEntity.getEndMathchTime()>0) {
|
||||
// finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
|
||||
// } else {
|
||||
// // 判断当前是否存在已匹配的点
|
||||
// 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 { // 从未匹配过的数据
|
||||
// // 未匹配个数超过指定阈值,也认为数据不匹配
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -1972,7 +1994,17 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
}
|
||||
});
|
||||
|
||||
private float getSpeed() {
|
||||
private float getSpeedAndBearing() {
|
||||
float bearing = 0;
|
||||
if (Constant.currentLocation.getDirection() != 0) {
|
||||
bearing = (float) Constant.currentLocation.getDirection();
|
||||
} else {
|
||||
// 使用上一个点和当前点位的向量计算方向
|
||||
if (oldCurrentLocation!=null&&oldCurrentLocation.getLatitude()!=Constant.currentLocation.getLatitude()&&oldCurrentLocation.getLongitude()!=Constant.currentLocation.getLongitude()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
float speed = Constant.currentLocation.getSpeed();//米/秒
|
||||
if (speed != 0) {
|
||||
speed = (speed * 3600 / 1000);//km/h
|
||||
|
@ -122,6 +122,7 @@ public class LocationRecorder implements Serializable {
|
||||
.append(tencentLocationX)
|
||||
.append(",")
|
||||
.append(bearing)
|
||||
.append(",")
|
||||
.append(Constant.getRssiDesStr(rssi))
|
||||
.append(",")
|
||||
.append(satelliteCount)
|
||||
|
@ -82,7 +82,7 @@
|
||||
android:hint="过程点距离阈值"
|
||||
></EditText>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
<!--<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
@ -99,7 +99,7 @@
|
||||
android:inputType="number"
|
||||
android:hint="起点放弃个数"
|
||||
></EditText>
|
||||
</LinearLayout>
|
||||
</LinearLayout>-->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -118,24 +118,24 @@
|
||||
android:hint="过程点放弃个数"
|
||||
></EditText>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="@dimen/default_widget_padding"
|
||||
android:text="放弃匹配距离阈值"></TextView>
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="horizontal">-->
|
||||
<!-- <TextView-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:paddingHorizontal="@dimen/default_widget_padding"-->
|
||||
<!-- android:text="放弃匹配距离阈值"></TextView>-->
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edt_camera_setting_unmatch_pecent"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberDecimal"
|
||||
android:hint="放弃匹配距离百分比"
|
||||
></EditText>
|
||||
</LinearLayout>
|
||||
<!-- <EditText-->
|
||||
<!-- android:id="@+id/edt_camera_setting_unmatch_pecent"-->
|
||||
<!-- android:layout_width="150dp"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:inputType="numberDecimal"-->
|
||||
<!-- android:hint="放弃匹配距离百分比"-->
|
||||
<!-- ></EditText>-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user