feat: 增加道路任务拍摄时的距离判定,当连续5个点距离小于2米时暂停拍摄
This commit is contained in:
parent
88dd96f572
commit
37e4c59041
@ -12,8 +12,8 @@ android {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 48
|
||||
versionName "8.230221"
|
||||
versionCode 49
|
||||
versionName "8.230317"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
ndk {
|
||||
|
@ -85,6 +85,7 @@ import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MyLocation;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.navinfo.outdoor.util.PicturesSpeedCheck;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.SystemTTS;
|
||||
import com.navinfo.outdoor.util.TencentLocationObtain;
|
||||
@ -239,10 +240,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private boolean startMatchEnableDirection = true; // 是否启用方向匹配起点
|
||||
private Logger logger;
|
||||
private ImageView imgLocationType;
|
||||
private PicturesSpeedCheck speedCheck;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
speedCheck = new PicturesSpeedCheck();
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("pic", Context.MODE_PRIVATE);
|
||||
BRIGHTNESS = sharedPreferences.getInt("brightness", 40);
|
||||
FRAMENESS = sharedPreferences.getInt("framness", 30);
|
||||
@ -575,6 +578,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
return;
|
||||
}
|
||||
|
||||
// 道路任务增加检查
|
||||
// 检测到当前车辆未移动,则无需进行拍摄
|
||||
if (!speedCheck.checkIsMove(LocationLifeCycle.getInstance().getMainLocation(), GPSUtils.getInstance(AutoTakePictureActivity.this).getSateliteCount())) {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, "车辆静止中,暂停拍摄!");
|
||||
return;
|
||||
}
|
||||
|
||||
File tmpPicFolder = new File(tmpPicFoldPath);
|
||||
if (!tmpPicFolder.exists()) {
|
||||
tmpPicFolder.mkdirs();
|
||||
|
@ -53,6 +53,7 @@ import com.navinfo.outdoor.util.Gps;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MyLocation;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.PicturesSpeedCheck;
|
||||
import com.navinfo.outdoor.util.SystemTTS;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
@ -159,6 +160,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private SimpleDateFormat formatter;
|
||||
private PicturesSpeedCheck speedCheck;
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
@ -194,6 +196,7 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
// 设置当前界面亮度为40%
|
||||
setWindowBrightness(BRIGHTNESS);
|
||||
LocationLifeCycle.getInstance().startGPSLocation();
|
||||
speedCheck = new PicturesSpeedCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -415,6 +418,15 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
}
|
||||
}
|
||||
|
||||
// 道路任务增加检查
|
||||
if (type == 4) {
|
||||
// 检测到当前车辆未移动,则无需进行拍摄
|
||||
if (!speedCheck.checkIsMove(LocationLifeCycle.getInstance().getMainLocation(), GPSUtils.getInstance(PicturesActivity.this).getSateliteCount())) {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(PicturesActivity.this, "车辆静止中,暂停拍摄!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(finalVideoPath);
|
||||
synchronized (finalVideoPath) {
|
||||
// 生成点位marker
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng
|
||||
|
||||
class PicturesSpeedCheck {
|
||||
val pointList = mutableListOf<MyLocation>()
|
||||
val LIST_SIZE = 5
|
||||
val DISTANCE = 2
|
||||
|
||||
/**
|
||||
* 与前面的4个点做检查,如果当前点位距离前面4个点的距离超过阈值,且当前卫星信号强度为中以上(8颗),则返回false
|
||||
* */
|
||||
fun checkIsMove(myLocation: MyLocation, sateliteCount: Int/*卫星颗数*/): Boolean {
|
||||
pointList.add(myLocation)
|
||||
if (pointList.size<5) { // 点位小于4个,不做判断,默认为运动中
|
||||
return true
|
||||
}
|
||||
if (pointList.size>5) { // 如果点位信息超过5个,移除第一个数据
|
||||
pointList.removeAt(0)
|
||||
}
|
||||
|
||||
if (sateliteCount<=3) { // 卫星颗数小于等于3,说明当前卫星信号弱,则忽略距离因素,认为车辆在移动中
|
||||
return true
|
||||
}
|
||||
|
||||
var distance = 0.0
|
||||
for (index in pointList.indices) {
|
||||
if (index+1<pointList.size) {
|
||||
distance += GeometryTools.distanceToDouble(
|
||||
LatLng(
|
||||
pointList[index].latitude,
|
||||
pointList[index].longitude
|
||||
),
|
||||
LatLng(pointList[index + 1].latitude, pointList[index + 1].longitude)
|
||||
)
|
||||
}
|
||||
if (distance>DISTANCE) { // 如果距离已经大于设置的距离阈值,无需再计算后面的点位,车辆运动中
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user