merge
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -20,13 +20,18 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
implementation project(":foudations:mogo-commons")
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.realtime">
|
||||
<uses-permission
|
||||
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
|
||||
/
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
</manifest>
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.realtime.Imp;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.realtime.Interface.RealTimeProvider;
|
||||
import com.mogo.realtime.connect.IMogoOnMessageListener;
|
||||
import com.mogo.realtime.connect.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.realtime.connect.MsgBody;
|
||||
import com.mogo.realtime.constant.SnapshotUploadInTime;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.location.MogoRTKLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public class RealTimeProviderImp implements RealTimeProvider {
|
||||
private RealTimeProvider mDelegate;
|
||||
|
||||
@Override
|
||||
public List<ADASRecognizedResult> getLastADASRecognizedResult() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getLastADASRecognizedResult();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistanceBetweenTwoPoints() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getDistanceBetweenTwoPoints();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String appId) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.init(context, appId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnMessageListener(int msgType, IMogoOnMessageListener listener) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.registerOnMessageListener(msgType, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMsg(Object body, IMogoOnWebSocketMessageListener listener) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.sendMsg(body, listener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mogo.realtime.Interface;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public final class RealTimeApisHandler {
|
||||
private static volatile RealTimeApisHandler sInstance;
|
||||
private static volatile RealTimeServiceApis sApis;
|
||||
|
||||
public static RealTimeApisHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (RealTimeApisHandler.class) {
|
||||
sInstance = new RealTimeApisHandler();
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void initRealTimeEnvironment() {
|
||||
//socketeinit locationinit rtkinit
|
||||
}
|
||||
|
||||
public RealTimeServiceApis getApis() {
|
||||
if (sApis == null) {
|
||||
synchronized (this) {
|
||||
// sApis = new RealTimeServiceApis();
|
||||
}
|
||||
}
|
||||
return sApis;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mogo.realtime.Interface;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.realtime.connect.IMogoOnMessageListener;
|
||||
import com.mogo.realtime.connect.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.realtime.connect.MsgBody;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public interface RealTimeProvider<T> {
|
||||
/**
|
||||
* 获取 adas 识别列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ADASRecognizedResult> getLastADASRecognizedResult();
|
||||
|
||||
/*
|
||||
* 两个点之间的距离
|
||||
* */
|
||||
float getDistanceBetweenTwoPoints();
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param appId 一般为包名,不参与通道的建立,一般用于发消息
|
||||
*/
|
||||
void init(Context context, String appId);
|
||||
|
||||
/**
|
||||
* 注册消息监听
|
||||
*
|
||||
* @param msgType 消息类型
|
||||
* @param listener 回调
|
||||
*/
|
||||
void registerOnMessageListener(int msgType, IMogoOnMessageListener listener);
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param body 消息体
|
||||
* @param listener 回执监听
|
||||
*/
|
||||
void sendMsg(T body, IMogoOnWebSocketMessageListener listener );
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.realtime.Interface;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/21
|
||||
*/
|
||||
public interface RealTimeServiceApis {
|
||||
RealTimeProvider getRecognizedResultManager();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoOnMessageListener< T > {
|
||||
|
||||
Class< T > target();
|
||||
|
||||
void onMsgReceived(T obj);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
/**
|
||||
* 消息回调
|
||||
*/
|
||||
public interface IMogoOnWebSocketMessageListener<T> {
|
||||
|
||||
default WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default WebSocketMsgType getUpLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Class<T> target() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default void onMsgReceived(T obj) {
|
||||
|
||||
}
|
||||
|
||||
default void onError(String errorMsg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MsgBody {
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private int mMsgType;
|
||||
|
||||
// /**
|
||||
// * 服务端分发,业务线
|
||||
// */
|
||||
// private int mProductLine = MogoCommon.Product.mogoBussiness_VALUE;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// private int mHeaderType = MogoConnsvr.MsgType.mogoMsgTypeDispatchSvrNoRspReq_VALUE;
|
||||
|
||||
/**
|
||||
* 是否回执
|
||||
*/
|
||||
private boolean mAck = false;
|
||||
|
||||
/**
|
||||
* 消息ID
|
||||
*/
|
||||
private final long mMsgId = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private Object mContent;
|
||||
|
||||
public MsgBody msgType( int msgType ) {
|
||||
this.mMsgType = msgType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody ack( boolean ack ) {
|
||||
this.mAck = ack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgBody content( Object object ) {
|
||||
this.mContent = object;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return mMsgType;
|
||||
}
|
||||
|
||||
public boolean isAck() {
|
||||
return mAck;
|
||||
}
|
||||
|
||||
public long getMsgId() {
|
||||
return mMsgId;
|
||||
}
|
||||
|
||||
public Object getContent() {
|
||||
return mContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.realtime.connect;
|
||||
|
||||
public enum WebSocketMsgType {
|
||||
|
||||
MSG_TYPE_UPLINK_CAR_DATA(0,"自车与ADAS数据"),
|
||||
MSG_TYPE_DOWNLINK_CAR_DATA(1,"服务端下发车辆信息"),
|
||||
MSG_TYPE_ACK(3, "ACK");
|
||||
|
||||
private int msgType;
|
||||
private String msg;
|
||||
|
||||
WebSocketMsgType(int msgType, String msg) {
|
||||
this.msgType = msgType;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(int msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package com.mogo.realtime.constant;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.realtime.Interface.RealTimeApisHandler;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.util.MogoLatLng;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定位预测纠错策略
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class SimpleLocationCorrectStrategy {
|
||||
private static final String TAG = "SimpleLocationCorrectStrategy";
|
||||
private static final int ERR_COUNT_THRESHOLD = 3;
|
||||
/**
|
||||
* 目标距离误差是10米,就是在原目标距离基础上增加10米
|
||||
*/
|
||||
private static final float TARGET_DISTANCE_DEVIATION = 10;
|
||||
|
||||
private CloudLocationInfo lastLocation = null;
|
||||
private long anchorTime;
|
||||
private int errCount;
|
||||
|
||||
private static SimpleLocationCorrectStrategy instance = new SimpleLocationCorrectStrategy();
|
||||
|
||||
public static SimpleLocationCorrectStrategy getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<CloudLocationInfo> historyList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> validList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> correctList = new ArrayList<>();
|
||||
private List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
|
||||
public CloudLocationInfo correct(CloudLocationInfo info) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
if(isLocationValid(info)) {
|
||||
if(recordLocation()) {
|
||||
historyList.add(info);
|
||||
}
|
||||
|
||||
if (lastLocation == null) {
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
Logger.d(TAG, "第一条数据");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
if (lastLocation.equals(info)) {
|
||||
Logger.d(TAG, "相同坐标点==");
|
||||
return info;
|
||||
}
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getDistanceBetweenTwoPoints();
|
||||
Logger.d(TAG,
|
||||
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
if (distance <= targetDistance) {
|
||||
// 新的定位点在目标距离范围内,认为此数据有效
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "在范围内,为有效点");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
// 出现异常点
|
||||
if (errCount >= ERR_COUNT_THRESHOLD) {
|
||||
// 出错次数超过阈值,认为本次出错点为正确点
|
||||
if(recordLocation()) {
|
||||
errList.add(new CloudLocationInfo(lastLocation));
|
||||
correctList.add(info);
|
||||
}
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "出错次数超限,异常点变有效点");
|
||||
return info;
|
||||
} else {
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
// return lastLocation;
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
return nextInfo;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
Logger.d(TAG, "定位点异常");
|
||||
if (lastLocation == null) {
|
||||
return null;
|
||||
}else{
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getDistanceBetweenTwoPoints();
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
// return lastLocation;
|
||||
return nextInfo;
|
||||
}catch (Exception e){
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isLocationValid(CloudLocationInfo info) {
|
||||
return info.getLat() != 0 && info.getLon() != 0;
|
||||
}
|
||||
|
||||
private RecordLocationListener recordLocationListener = null;
|
||||
private boolean hasCallbackReocrd = false;
|
||||
|
||||
public void setRecordLocationListener(RecordLocationListener recordLocationListener) {
|
||||
this.recordLocationListener = recordLocationListener;
|
||||
}
|
||||
|
||||
private boolean recordLocation(){
|
||||
if (historyList.size() >= 100 && !hasCallbackReocrd && recordLocationListener != null) {
|
||||
hasCallbackReocrd = true;
|
||||
recordLocationListener.onRecordFinish(historyList, correctList,validList,correctList);
|
||||
}
|
||||
return historyList.size() < 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据距离和角度计算下一个经纬度
|
||||
* 大地坐标系资料WGS-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
|
||||
*/
|
||||
public MogoLatLng computerThatLonLat(double lon, double lat, double brng, double dist) {
|
||||
|
||||
double alpha1 = rad(brng);
|
||||
double sinAlpha1 = Math.sin(alpha1);
|
||||
double cosAlpha1 = Math.cos(alpha1);
|
||||
|
||||
// 扁率f=1/298.2572236
|
||||
double f = 1 / 298.2572236;
|
||||
double tanU1 = (1 - f) * Math.tan(rad(lat));
|
||||
double cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1));
|
||||
double sinU1 = tanU1 * cosU1;
|
||||
double sigma1 = Math.atan2(tanU1, cosAlpha1);
|
||||
double sinAlpha = cosU1 * sinAlpha1;
|
||||
double cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
||||
// 长半径a=6378137
|
||||
double a = 6378137;
|
||||
// 短半径b=6356752.3142
|
||||
double b = 6356752.3142;
|
||||
double uSq = cosSqAlpha * (a * a - b * b) / (b * b);
|
||||
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
|
||||
double cos2SigmaM=0;
|
||||
double sinSigma=0;
|
||||
double cosSigma=0;
|
||||
double sigma = dist / (b * A), sigmaP = 2 * Math.PI;
|
||||
while (Math.abs(sigma - sigmaP) > 1e-12) {
|
||||
cos2SigmaM = Math.cos(2 * sigma1 + sigma);
|
||||
sinSigma = Math.sin(sigma);
|
||||
cosSigma = Math.cos(sigma);
|
||||
double deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
|
||||
- B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
||||
sigmaP = sigma;
|
||||
sigma = dist / (b * A) + deltaSigma;
|
||||
}
|
||||
|
||||
double tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
|
||||
double lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
|
||||
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp));
|
||||
double lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1);
|
||||
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
|
||||
double L = lambda - (1 - C) * f * sinAlpha
|
||||
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
||||
|
||||
// final bearing
|
||||
double revAz = Math.atan2(sinAlpha, -tmp);
|
||||
|
||||
System.out.println(revAz);
|
||||
System.out.println(lon+deg(L)+","+deg(lat2));
|
||||
return new MogoLatLng(deg(lat2), lon + deg(L));
|
||||
}
|
||||
|
||||
/**
|
||||
* 度换成弧度
|
||||
*
|
||||
* @param d
|
||||
* 度
|
||||
* @return 弧度
|
||||
*/
|
||||
private double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弧度换成度
|
||||
*
|
||||
* @param x
|
||||
* 弧度
|
||||
* @return 度
|
||||
*/
|
||||
private double deg(double x) {
|
||||
return x * 180 / Math.PI;
|
||||
}
|
||||
|
||||
public interface RecordLocationListener{
|
||||
void onRecordFinish(List<CloudLocationInfo> history, List<CloudLocationInfo> correct, List<CloudLocationInfo> valid, List<CloudLocationInfo> err);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.mogo.realtime.constant;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.realtime.Interface.RealTimeApisHandler;
|
||||
import com.mogo.realtime.connect.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.realtime.connect.WebSocketMsgType;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.location.LocationResult;
|
||||
import com.mogo.realtime.location.MogoRTKLocation;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
import com.mogo.realtime.socket.OnePerSecondSendContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
* <p>
|
||||
* 实时上报坐标、识别物体
|
||||
*/
|
||||
public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
|
||||
|
||||
private static final String TAG = "SnapshotUploadInTime";
|
||||
|
||||
private static volatile SnapshotUploadInTime sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private SnapshotUploadInTime() {
|
||||
}
|
||||
|
||||
public static SnapshotUploadInTime getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (SnapshotUploadInTime.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new SnapshotUploadInTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
MogoRTKLocation.getInstance().registerRTKLocationListener(this);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
MogoRTKLocation.getInstance().unregisterRTKLocationListener();
|
||||
MogoRTKLocation.getInstance().stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(List<CloudLocationInfo> cloudLocationInfos) {
|
||||
startSendCarLocationAndAdasRecognizedResult2Server(cloudLocationInfos);
|
||||
}
|
||||
|
||||
private CloudLocationInfo mLastInfo;
|
||||
|
||||
private void startSendCarLocationAndAdasRecognizedResult2Server(List<CloudLocationInfo> cloudLocationInfo) {
|
||||
CloudLocationInfo lastInfo = null;
|
||||
// 如果数组内容不为空,就用数组最后一个值
|
||||
if (cloudLocationInfo != null && !cloudLocationInfo.isEmpty()) {
|
||||
lastInfo = cloudLocationInfo.get(cloudLocationInfo.size() - 1);
|
||||
mLastInfo = lastInfo;
|
||||
}
|
||||
if (lastInfo == null) {
|
||||
lastInfo = mLastInfo;
|
||||
}
|
||||
LocationResult locationResult = null;
|
||||
if (lastInfo != null) {
|
||||
// 定位点预测纠偏
|
||||
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct(lastInfo);
|
||||
locationResult = new LocationResult();
|
||||
if (lastInfo != null) {
|
||||
locationResult.lastCoordinate = lastInfo;
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton(lastInfo.getLon(), lastInfo.getLat());
|
||||
}
|
||||
// locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
// if ( cloudLocationInfo == null ) {
|
||||
// locationResult.coordinates.addAll( new ArrayList<>() );
|
||||
// } else {
|
||||
// locationResult.coordinates.addAll( cloudLocationInfo );
|
||||
// }
|
||||
}
|
||||
List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
content.self = locationResult;
|
||||
content.adas = recognizedResults;
|
||||
|
||||
if (content.self == null &&
|
||||
(content.adas == null || content.adas.isEmpty())) {
|
||||
Log.d(TAG, "no information 2 sent");
|
||||
return;
|
||||
}
|
||||
|
||||
RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().sendMsg(content, new IMogoOnWebSocketMessageListener() {
|
||||
@Override
|
||||
public WebSocketMsgType getDownLinkType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketMsgType getUpLinkType() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* adas 识别物体参数
|
||||
*/
|
||||
class ADASRecognizedResult {
|
||||
|
||||
/**
|
||||
* 识别物体类型
|
||||
*/
|
||||
public int type;
|
||||
|
||||
/**
|
||||
* 识别物体唯一标识
|
||||
*/
|
||||
public String uuid;
|
||||
|
||||
/**
|
||||
* 红绿灯颜色
|
||||
*/
|
||||
public String color;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String carId;
|
||||
|
||||
/**
|
||||
* 识别物体的纬度
|
||||
*/
|
||||
public double lat;
|
||||
|
||||
/**
|
||||
* 识别物体的经度
|
||||
*/
|
||||
public double lon;
|
||||
|
||||
/**
|
||||
* 朝向
|
||||
*/
|
||||
public double heading;
|
||||
|
||||
/**
|
||||
* 系统时间
|
||||
*/
|
||||
public long systemTime;
|
||||
|
||||
/**
|
||||
* 定位卫星时间
|
||||
*/
|
||||
public long satelliteTime;
|
||||
|
||||
/**
|
||||
* 海拔
|
||||
*/
|
||||
public double alt;
|
||||
|
||||
/**
|
||||
* 速度
|
||||
*/
|
||||
public double speed;
|
||||
|
||||
/**
|
||||
* 莫顿码
|
||||
*/
|
||||
public long mortonCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 云端定位信息和自车定位信息
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class CloudLocationInfo implements Parcelable {
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double heading;
|
||||
private long systemTime;
|
||||
private long satelliteTime;
|
||||
private double alt;
|
||||
private double speed;
|
||||
|
||||
public CloudLocationInfo() {
|
||||
}
|
||||
|
||||
public CloudLocationInfo(CloudLocationInfo info ) {
|
||||
this.lat = info.getLat();
|
||||
this.lon = info.getLon();
|
||||
this.heading = info.getHeading();
|
||||
this.systemTime = System.currentTimeMillis();
|
||||
this.satelliteTime = System.currentTimeMillis();
|
||||
this.alt = info.alt;
|
||||
this.speed = info.speed;
|
||||
}
|
||||
|
||||
public void convertCoor2GCJ02(){
|
||||
double[] amapCoord = CoordinateUtils.transformFromWGSToGCJ( lat, lon );
|
||||
if ( amapCoord != null ) {
|
||||
this.lat = amapCoord[0];
|
||||
this.lon = amapCoord[1];
|
||||
}
|
||||
}
|
||||
|
||||
protected CloudLocationInfo(Parcel in ) {
|
||||
lat = in.readDouble();
|
||||
lon = in.readDouble();
|
||||
heading = in.readDouble();
|
||||
systemTime = in.readLong();
|
||||
satelliteTime = in.readLong();
|
||||
alt = in.readDouble();
|
||||
speed = in.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeDouble( lat );
|
||||
dest.writeDouble( lon );
|
||||
dest.writeDouble( heading );
|
||||
dest.writeLong( systemTime );
|
||||
dest.writeLong( satelliteTime );
|
||||
dest.writeDouble( alt );
|
||||
dest.writeDouble( speed );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator< CloudLocationInfo > CREATOR = new Creator< CloudLocationInfo >() {
|
||||
@Override
|
||||
public CloudLocationInfo createFromParcel( Parcel in ) {
|
||||
return new CloudLocationInfo( in );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudLocationInfo[] newArray( int size ) {
|
||||
return new CloudLocationInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat( double lat ) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon( double lon ) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading( double heading ) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public long getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public void setSystemTime( long systemTime ) {
|
||||
this.systemTime = systemTime;
|
||||
}
|
||||
|
||||
public long getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
public void setSatelliteTime( long satelliteTime ) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt( double alt ) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed( double speed ) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CloudLocationInfo{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", heading=" + heading +
|
||||
", systemTime=" + systemTime +
|
||||
", satelliteTime=" + satelliteTime +
|
||||
", alt=" + alt +
|
||||
", speed=" + speed +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String print() {
|
||||
return "CloudLocation{ lon: " + lon + " lat: " + lat + " heading: " + heading + " speed: "
|
||||
+ speed + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o ) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
CloudLocationInfo that = ( CloudLocationInfo ) o;
|
||||
return Double.compare( that.lat, lat ) == 0 &&
|
||||
Double.compare( that.lon, lon ) == 0;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( lat, lon );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mogo.realtime.location;
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* 自车定位信息
|
||||
*/
|
||||
class LocationResult {
|
||||
|
||||
/**
|
||||
* sn
|
||||
*/
|
||||
public String sn;
|
||||
|
||||
/**
|
||||
* 最后一个定位点的莫顿码
|
||||
*/
|
||||
public long mortonCode;
|
||||
|
||||
/**
|
||||
* 最后一个定位点
|
||||
*/
|
||||
public CloudLocationInfo lastCoordinate;
|
||||
|
||||
/**
|
||||
* 1s 内的连续定位点
|
||||
*/
|
||||
public List< CloudLocationInfo > coordinates;
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.mogo.realtime.location;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MogoRTKLocation {
|
||||
|
||||
private static final String TAG = "MogoRTKLocation";
|
||||
private static final int MSG_DATA_CHANGED = 0x100;
|
||||
private static final long MSG_DATA_INTERNAL = 500L;
|
||||
|
||||
private Handler mHandler;
|
||||
private LocationManager locationManager;
|
||||
private RTKLocationListener rtkLocationListener;
|
||||
private List<CloudLocationInfo> cacheList = new ArrayList<>();
|
||||
|
||||
public static MogoRTKLocation getInstance() {
|
||||
return RTKHolder.rtkLoc;
|
||||
}
|
||||
|
||||
private static class RTKHolder {
|
||||
private static final MogoRTKLocation rtkLoc = new MogoRTKLocation();
|
||||
}
|
||||
|
||||
private MogoRTKLocation() {
|
||||
mHandler = new Handler(WorkThreadHandler.newInstance(TAG).getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_DATA_CHANGED) {
|
||||
mHandler.sendEmptyMessageDelayed(MSG_DATA_CHANGED, uploadDelay);
|
||||
sendLocationData();
|
||||
|
||||
// Logger.d(TAG,"handleMessage开始发送消息");
|
||||
}
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessage(MSG_DATA_CHANGED);
|
||||
Logger.d(TAG, "构造方法开始发送消息");
|
||||
}
|
||||
|
||||
public interface RTKLocationListener {
|
||||
void onLocationChanged(List<CloudLocationInfo> cloudLocationInfos);
|
||||
}
|
||||
|
||||
private void sendLocationData() {
|
||||
|
||||
if (rtkLocationListener != null) {
|
||||
List<CloudLocationInfo> list = new ArrayList<>(cacheList);
|
||||
rtkLocationListener.onLocationChanged(list);
|
||||
}
|
||||
if (cacheList != null && cacheList.size() > 0) {
|
||||
cacheList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void registerRTKLocationListener(RTKLocationListener locationListener) {
|
||||
rtkLocationListener = locationListener;
|
||||
}
|
||||
|
||||
public void unregisterRTKLocationListener() {
|
||||
rtkLocationListener = null;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
locationManager = (LocationManager) MoGoAiCloudClient.getInstance().getContext().getSystemService(Context.LOCATION_SERVICE);
|
||||
String provider = locationManager.getBestProvider(getCriteria(), true);
|
||||
Logger.d(TAG, "init provider : " + provider);
|
||||
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
try {
|
||||
locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
if (location != null) {
|
||||
Logger.i(TAG, "location : " + location.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.d(TAG, "RTK LocationManager requestLocationUpdates has Exception : " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "RTK LocationManager Provider GPS_PROVIDER unable");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Criteria getCriteria() {
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE); //高精
|
||||
criteria.setAltitudeRequired(false);
|
||||
criteria.setBearingRequired(true);
|
||||
criteria.setSpeedRequired(true);
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
cloudLocationInfo.setAlt(location.getAltitude());
|
||||
cloudLocationInfo.setHeading(location.getBearing());
|
||||
cloudLocationInfo.setLat(location.getLatitude());
|
||||
cloudLocationInfo.setLon(location.getLongitude());
|
||||
cloudLocationInfo.setSpeed(location.getSpeed());
|
||||
cloudLocationInfo.setSatelliteTime(location.getTime());
|
||||
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
cacheList.add(cloudLocationInfo);
|
||||
} else {
|
||||
Logger.e(TAG, "location == null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||
Logger.d(TAG, "onStatusChanged status: " + status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {
|
||||
Logger.d(TAG, "onProviderEnabled");
|
||||
}
|
||||
};
|
||||
|
||||
public void stop() {
|
||||
Logger.d(TAG, "stop RTK Location");
|
||||
if (locationManager != null && locationListener != null) {
|
||||
locationManager.removeUpdates(locationListener);
|
||||
} else {
|
||||
Logger.d(TAG, "stop failed , reason : loc" + locationManager + " , or loc listener: " + locationListener + " is null");
|
||||
}
|
||||
}
|
||||
|
||||
private long uploadDelay = MSG_DATA_INTERNAL;
|
||||
|
||||
private FixUploadDelayReceiver fixUploadDelayReceiver = new FixUploadDelayReceiver();
|
||||
|
||||
private class FixUploadDelayReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
uploadDelay = intent.getIntExtra("fixTime", 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认保持{@link #uploadDelay}间隔进行位置上报,如遇服务端控制,进行上报间隔修改
|
||||
*
|
||||
* @param delay 上报间隔
|
||||
*/
|
||||
public void resetUploadDelay(long delay) {
|
||||
if (mHandler != null && mHandler.hasMessages(MSG_DATA_CHANGED)) {
|
||||
mHandler.removeMessages(MSG_DATA_CHANGED);
|
||||
mHandler.sendEmptyMessageDelayed(MSG_DATA_CHANGED, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.realtime.socket;
|
||||
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* 自车定位信息
|
||||
*/
|
||||
class LocationResult {
|
||||
|
||||
/**
|
||||
* sn
|
||||
*/
|
||||
public String sn;
|
||||
|
||||
/**
|
||||
* 最后一个定位点的莫顿码
|
||||
*/
|
||||
public long mortonCode;
|
||||
|
||||
/**
|
||||
* 最后一个定位点
|
||||
*/
|
||||
public CloudLocationInfo lastCoordinate;
|
||||
|
||||
/**
|
||||
* 1s 内的连续定位点
|
||||
*/
|
||||
public List< CloudLocationInfo > coordinates;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.realtime.socket;
|
||||
|
||||
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.location.LocationResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* 一秒一次的上行数据
|
||||
*/
|
||||
class OnePerSecondSendContent {
|
||||
|
||||
/**
|
||||
* 自车定位点
|
||||
*/
|
||||
public LocationResult self;
|
||||
|
||||
/**
|
||||
* adas 识别物体:1s 识别到的最后帧
|
||||
*/
|
||||
public List<ADASRecognizedResult> adas;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.mogo.realtime.util;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 经纬度
|
||||
*/
|
||||
public class MogoLatLng implements Parcelable {
|
||||
|
||||
public final double lat;
|
||||
@Deprecated
|
||||
public final double lng;
|
||||
public final double lon;
|
||||
|
||||
public MogoLatLng(double lat, double lon ) {
|
||||
this.lat = lat;
|
||||
this.lng = lon;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated, use {@link #getLon()} instead.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o ) {
|
||||
if ( this == o ) return true;
|
||||
if ( o == null || getClass() != o.getClass() ) return false;
|
||||
MogoLatLng latLng = ( MogoLatLng ) o;
|
||||
return Double.compare( latLng.lat, lat ) == 0 &&
|
||||
Double.compare( latLng.lon, lon ) == 0;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( lat, lng, lon );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MogoLatLng{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.lng );
|
||||
dest.writeDouble( this.lon );
|
||||
}
|
||||
|
||||
protected MogoLatLng(Parcel in ) {
|
||||
this.lat = in.readDouble();
|
||||
this.lng = in.readDouble();
|
||||
this.lon = in.readDouble();
|
||||
}
|
||||
|
||||
public static final Creator< MogoLatLng > CREATOR = new Creator< MogoLatLng >() {
|
||||
@Override
|
||||
public MogoLatLng createFromParcel( Parcel source ) {
|
||||
return new MogoLatLng( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng[] newArray( int size ) {
|
||||
return new MogoLatLng[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.mogo.realtime.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* 莫顿编码
|
||||
*
|
||||
* @author linyang
|
||||
* @since 2020.07.09
|
||||
*/
|
||||
public class MortonCode {
|
||||
|
||||
/**
|
||||
* morton 转 经纬度 时的中间常量
|
||||
*/
|
||||
private static final long NDS_180_DEGREES = 0x7fffffff;
|
||||
|
||||
/**
|
||||
* morton 转 经纬度 时的中间常量
|
||||
*/
|
||||
private static final long NDS_360_DEGREES = 4294967295L;
|
||||
|
||||
/**
|
||||
* morton 转 经纬度 时的中间常量
|
||||
*/
|
||||
private static final long NDS_90_DEGREES = 0x3fffffff;
|
||||
|
||||
/**
|
||||
* 经纬度转 morton 时的中间常量
|
||||
*/
|
||||
private static final double RULE_MORTON = Math.pow( 2, 32 ) / 360;
|
||||
|
||||
/**
|
||||
* morton 转 经纬度 时的中间常量
|
||||
*/
|
||||
private static final double RULE_MORTON_TO_LONLAT = 360.0 / Math.pow( 2, 32 );
|
||||
|
||||
/**
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
public static long wrapEncodeMorton( Double lon, Double lat ) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat( "#.######" );
|
||||
return encodeMorton( Double.valueOf( decimalFormat.format( lon ) ),
|
||||
Double.valueOf( decimalFormat.format( lat ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码 morton code
|
||||
*
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
*/
|
||||
public static long encodeMorton( Double lon, Double lat ) {
|
||||
|
||||
Long bit = 1L;
|
||||
long mortonCode = 0L;
|
||||
long x = ( long ) ( lon * RULE_MORTON );
|
||||
long y = ( long ) ( lat * RULE_MORTON );
|
||||
|
||||
if ( y < 0 ) {
|
||||
y += 0x7FFFFFFF;
|
||||
}
|
||||
y = y << 1;
|
||||
for ( int i = 0; i < 32; i++ ) {
|
||||
// x-part
|
||||
mortonCode = mortonCode | ( x & bit );
|
||||
x = x << 1;
|
||||
bit = bit << 1;
|
||||
// y-part
|
||||
mortonCode = mortonCode | ( y & bit );
|
||||
y = y << 1;
|
||||
bit = bit << 1;
|
||||
}
|
||||
|
||||
return mortonCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将莫顿码解码为坐标
|
||||
*
|
||||
* @param mortonCode
|
||||
* @return
|
||||
*/
|
||||
public static double[] decodeMorton( long mortonCode ) {
|
||||
long[] midPoint = mortonCodeToCoord( mortonCode );
|
||||
normalizeCoord( midPoint );
|
||||
double[] point = new double[2];
|
||||
|
||||
// 将经纬度长整数转化为 浮点类型
|
||||
point[0] = midPoint[0] * RULE_MORTON_TO_LONLAT;
|
||||
point[1] = midPoint[1] * RULE_MORTON_TO_LONLAT;
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* 莫顿码分别拆解为 编码后的经纬度长整数
|
||||
*
|
||||
* @param mortonCode
|
||||
* @return
|
||||
*/
|
||||
private static long[] mortonCodeToCoord( long mortonCode ) {
|
||||
long bit = 1L;
|
||||
long[] longPoint = new long[2];
|
||||
|
||||
for ( int i = 0; i < 32; i++ ) {
|
||||
longPoint[0] |= mortonCode & bit;
|
||||
mortonCode >>= 1;
|
||||
longPoint[1] |= mortonCode & bit;
|
||||
bit <<= 1;
|
||||
}
|
||||
return longPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对编码后的经纬度长整数进行解码
|
||||
*
|
||||
* @param midPoint
|
||||
*/
|
||||
private static void normalizeCoord( long[] midPoint ) {
|
||||
// if x > 180 degrees, then subtract 360 degrees
|
||||
if ( midPoint[0] > NDS_180_DEGREES ) {
|
||||
midPoint[0] -=
|
||||
NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
|
||||
} else if ( midPoint[0] < -NDS_180_DEGREES ) // if x < 180 , x += 360
|
||||
{
|
||||
midPoint[0] +=
|
||||
NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
|
||||
}
|
||||
|
||||
// if y > 90 degrees, then subtract 180 degrees
|
||||
if ( midPoint[1] > NDS_90_DEGREES ) {
|
||||
midPoint[1] -=
|
||||
NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
|
||||
} else if ( midPoint[1] < -NDS_90_DEGREES ) // if y < 90, y += 180
|
||||
{
|
||||
midPoint[1] +=
|
||||
NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public static void main( String[] args ) {
|
||||
System.out.println( encodeMorton( 116.39584, 39.98152 ) );
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 30
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
@@ -29,15 +28,15 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
|
||||
implementation rootProject.ext.dependencies.retrofit
|
||||
implementation rootProject.ext.dependencies.retrofitconvertergson
|
||||
implementation rootProject.ext.dependencies.gson
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation project(path: ':foudations:mogo-commons')
|
||||
|
||||
}
|
||||
4
modules/mogo-tanlu/gradle.properties
Normal file
4
modules/mogo-tanlu/gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
GROUP=com.mogo.cloud
|
||||
POM_ARTIFACT_ID=tanlu
|
||||
VERSION_CODE=1
|
||||
VERSION_NAME=1.0.0
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.mogo.tanlu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.mogo.tanlu.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.tanlu">
|
||||
package="com.mogo.cloud.tanlu">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.mogo.cloud.tanlu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.commons.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.tanlu.api.IRoadInfoSearchCallback;
|
||||
import com.mogo.cloud.tanlu.api.ITanluUploadCallback;
|
||||
import com.mogo.cloud.tanlu.bean.InformationBody;
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfoRequest;
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
||||
import com.mogo.cloud.tanlu.bean.UploadResult;
|
||||
import com.mogo.cloud.tanlu.bean.location.Location;
|
||||
import com.mogo.cloud.tanlu.bean.location.MogoLocation;
|
||||
import com.mogo.cloud.tanlu.net.TanluApiService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.RequestOptions;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/21
|
||||
*/
|
||||
public class UploadManager {
|
||||
private static final String TAG = "UploadManager";
|
||||
private static UploadManager sInstance;
|
||||
private Context mContext;
|
||||
private TanluApiService apiService;
|
||||
|
||||
|
||||
private UploadManager (Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static UploadManager getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
synchronized (UploadManager.class) {
|
||||
sInstance = new UploadManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param informationBody
|
||||
* @param callback
|
||||
*
|
||||
*/
|
||||
public void loadUpload(InformationBody informationBody, ITanluUploadCallback callback) {
|
||||
apiService = RetrofitFactory.INSTANCE.getInstance("http://dzt-test.zhidaozhixing.com")
|
||||
.create(TanluApiService.class);
|
||||
|
||||
Gson gson = new Gson();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
// map.put("sn", MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn()); //TODO
|
||||
// map.put("data", gson.toJson(informationBody));
|
||||
|
||||
map.put("sn", "F803EB2046PZD00228");
|
||||
map.put("data", "{\"addr\":\"北京市东城区小黄庄北街2号靠近中国银行(北京安贞桥支行)\",\"areaCode\":\"110101\",\"areaName\":\"东城区\",\"cityCode\":\"010\",\"cityName\":\"北京市\",\"data\":\"[{\\\"thumbnail\\\":\\\"http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/com.zhidao.roadcondition/F803EB2046PZD00228/F803EB2046PZD00228_20210121165329/Thumbnail1611219200669.jpg\\\",\\\"url\\\":\\\"http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/com.zhidao.roadcondition/F803EB2046PZD00228/F803EB2046PZD00228_20210121165329/compress_video_20210121165307.mp4\\\"}]\",\"direction\":0.0,\"fromType\":\"2\",\"generateTime\":1611219213616,\"infoTimeout\":240,\"infoType\":1,\"isShare\":false,\"lat\":39.968317,\"lon\":116.410892,\"mainInfoId\":0,\"poiType\":\"10008\",\"provinceName\":\"北京市\",\"sn\":\"F803EB2046PZD00228\",\"speed\":0.0,\"street\":\"小黄庄北街\",\"trafficInfoType\":\"\",\"type\":1,\"uid\":0}");
|
||||
|
||||
Log.d(TAG, "sn = " + MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn());
|
||||
apiService.uploadInformation(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<UploadResult>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.d(TAG, "onSubscribe -----> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UploadResult result) {
|
||||
Log.d(TAG, "onNext -----> ");
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e(TAG, "onError -----> e " + e);
|
||||
callback.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.d(TAG, "onComplete -----> ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过经纬度信息查询 TanluModelData
|
||||
* @param roadInfoRequest
|
||||
* @param callback
|
||||
*/
|
||||
public void queryRoadInfoByLocationInfo(RoadInfoRequest roadInfoRequest, IRoadInfoSearchCallback callback) {
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", "F803EB2046PZD00228");
|
||||
map.put("data", GsonUtil.jsonFromObject(roadInfoRequest));
|
||||
|
||||
apiService.queryRoadInfos(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoadInfos>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.d(TAG, "queryRoadInfos onSubscribe ----");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull RoadInfos roadInfos) {
|
||||
Log.d(TAG, "queryRoadInfos onNext roadInfos----" + roadInfos.getData());
|
||||
callback.onSuccess(roadInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.d(TAG, "queryRoadInfos onError ----");
|
||||
callback.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.d(TAG, "queryRoadInfos onComplete ----");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public void queryRoadInfoByCity(InformationBody informationBody, ITanluUploadCallback callback) {
|
||||
//
|
||||
// if (voiceCmdData.isHere()) { //TanluModelData
|
||||
// // 搜索附近路况,只需要拿到当前位置信息,就可以请求服务端
|
||||
// MogoLocation l = TanluServiceManager.getServiceApis().getMapServiceApi().getSingletonLocationClient(mContext).getLastKnowLocation();
|
||||
// Location location = new Location(l.getLatitude(), l.getLongitude());
|
||||
// RoadInfoRequest request;
|
||||
// if (voiceCmdData.getObj().equals(TYPE_NAME_BLOCK)) {
|
||||
// // 拥堵和路况同时查
|
||||
// request = new RoadInfoRequest(location, new String[]{TANLU_ROAD_CONGESTION_COMPAT, TANLU_ROAD_CURRENT}, false, false);
|
||||
// }else{
|
||||
// request = new RoadInfoRequest(location, new String[]{voiceCmdData.getType()}, false, false);
|
||||
// }
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("sn", "F803EB2046PZD00228");
|
||||
// map.put("data", "GsonUtil.jsonFromObject(request)");
|
||||
//
|
||||
// apiService.queryRoadInfos(map)
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new Observer<RoadInfos>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.d(TAG, "queryRoadInfos onSubscribe ----");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull RoadInfos roadInfos) {
|
||||
// Log.d(TAG, "queryRoadInfos onNext roadInfos----" + roadInfos.getData());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.d(TAG, "queryRoadInfos onError ----");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.d(TAG, "queryRoadInfos onComplete ----");
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// // 查询的不是附近的信息,所以需要查询一下目标地址的经纬度,然后再请求服务端
|
||||
// Observable.create(new ObservableOnSubscribe<MogoPoiResult>() {
|
||||
// @Override
|
||||
// public void subscribe(ObservableEmitter<MogoPoiResult> emitter) throws Exception {
|
||||
// // 根据传入的地址,转成经纬度
|
||||
// IMogoMapService mapService = TanluServiceManager.getServiceApis().getMapServiceApi();
|
||||
// String cityCode = mapService.getSingletonLocationClient(mContext).getLastKnowLocation().getCityCode();
|
||||
// MogoPoiSearchQuery poiSearchQuery = new MogoPoiSearchQuery(voiceCmdData.getLocation(), "", cityCode);
|
||||
// IMogoPoiSearch poiSearch = mapService.getPoiSearch(mContext, poiSearchQuery);
|
||||
// MogoPoiResult result = poiSearch.searchPOI();
|
||||
// if (result != null && result.getPois() != null && result.getPois().size() > 0) {
|
||||
// emitter.onNext(result);
|
||||
// } else {
|
||||
// emitter.onError(new IllegalArgumentException("没有根据地址查询到对应的经纬度"));
|
||||
// }
|
||||
// }
|
||||
// }).subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
||||
// .flatMap(new Function<MogoPoiResult, Observable<BaseDataCompat<RoadInfos>>>() {
|
||||
// @Override
|
||||
// public Observable<BaseDataCompat<RoadInfos>> apply(MogoPoiResult mogoPoiResult) throws Exception {
|
||||
// // 转成经纬度后,整理参数,进行接口请求
|
||||
// Logger.d(TAG, "查询目标地址经纬度成功===" + Thread.currentThread().getName());
|
||||
// MogoPoiItem poiItem = mogoPoiResult.getPois().get(0);
|
||||
// Location location = new Location(poiItem.getPoint().lat, poiItem.getPoint().lon);
|
||||
// callback.onLocatSuccess(location.getLat(), location.getLon());
|
||||
// RoadInfoRequest request;
|
||||
// if (voiceCmdData.getObj().equals(TYPE_NAME_BLOCK)) {
|
||||
// // 拥堵和路况同时查
|
||||
// request = new RoadInfoRequest(location, new String[]{TANLU_ROAD_CONGESTION_COMPAT, TANLU_ROAD_CURRENT}, false, false);
|
||||
// }else{
|
||||
// request = new RoadInfoRequest(location, new String[]{voiceCmdData.getType()}, false, false);
|
||||
// }
|
||||
//
|
||||
// Map<String, Object> params = new ParamsProvider.Builder(mContext)
|
||||
// .append("sn", Utils.getSn())
|
||||
// .append("data", GsonUtil.jsonFromObject(request))
|
||||
// .build();
|
||||
// return mShareApiService.queryRoadInfos(params);
|
||||
// }
|
||||
// }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe(new SubscribeImpl<BaseDataCompat<RoadInfos>>(RequestOptions.create(mContext)) {
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// super.onError(e);
|
||||
// callback.onQueryRoadInfoFail(e.getMessage(), -1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(BaseDataCompat<RoadInfos> o) {
|
||||
// super.onSuccess(o);
|
||||
// Logger.d(TAG, "当前线程为"+Thread.currentThread().getName()+" 搜索目标地址路况信息成功: " + o);
|
||||
// callback.onQueryRoadInfoSuccess(o.getResult().getData());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(String message, int code) {
|
||||
// super.onError(message, code);
|
||||
// callback.onQueryRoadInfoFail(message, code);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.cloud.tanlu.api;
|
||||
|
||||
|
||||
import com.mogo.cloud.tanlu.bean.InformationBody;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public interface ILoadUpload {
|
||||
void loadUpload(String sn, InformationBody informationBody, ITanluUploadCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.cloud.tanlu.api;
|
||||
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public interface IRoadInfoSearchCallback {
|
||||
void onSuccess(RoadInfos result);
|
||||
void onFailure(int code);
|
||||
void onError(Throwable e);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.cloud.tanlu.api;
|
||||
|
||||
import com.mogo.cloud.tanlu.bean.UploadResult;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public interface ITanluUploadCallback {
|
||||
void onSuccess(UploadResult result);
|
||||
void onFailure(int code);
|
||||
void onError(Throwable e);
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class InformationBody implements Serializable {
|
||||
private String data;
|
||||
private String addr;
|
||||
private String areaCode;
|
||||
private String areaName;
|
||||
private String cityCode;
|
||||
private String cityName;
|
||||
private long generateTime;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private String provinceName;
|
||||
private String sn;
|
||||
private String street;
|
||||
private int type;
|
||||
private int uid;
|
||||
private int infoType;
|
||||
private int infoTimeout;
|
||||
private String trafficInfoType; // 上报情报类型
|
||||
private boolean isShare; // 是否分享给附近车机
|
||||
private float direction;
|
||||
private String poiType; //类型分类
|
||||
private long mainInfoId; //事件id
|
||||
private float speed; //车速
|
||||
private String fromType; //上报触发来源
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public String getAreaCode() {
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
public void setAreaCode(String areaCode) {
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
|
||||
public String getAreaName() {
|
||||
return areaName;
|
||||
}
|
||||
|
||||
public void setAreaName(String areaName) {
|
||||
this.areaName = areaName;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode(String cityCode) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
public long getGenerateTime() {
|
||||
return generateTime;
|
||||
}
|
||||
|
||||
public void setGenerateTime(long generateTime) {
|
||||
this.generateTime = generateTime;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getProvinceName() {
|
||||
return provinceName;
|
||||
}
|
||||
|
||||
public void setProvinceName(String provinceName) {
|
||||
this.provinceName = provinceName;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getInfoType() {
|
||||
return infoType;
|
||||
}
|
||||
|
||||
public void setInfoType(int infoType) {
|
||||
this.infoType = infoType;
|
||||
}
|
||||
|
||||
public int getInfoTimeout() {
|
||||
return infoTimeout;
|
||||
}
|
||||
|
||||
public void setInfoTimeout(int infoTimeout) {
|
||||
this.infoTimeout = infoTimeout;
|
||||
}
|
||||
|
||||
public String getTrafficInfoType() {
|
||||
return trafficInfoType;
|
||||
}
|
||||
|
||||
public void setTrafficInfoType(String trafficInfoType) {
|
||||
this.trafficInfoType = trafficInfoType;
|
||||
}
|
||||
|
||||
public boolean isShare() {
|
||||
return isShare;
|
||||
}
|
||||
|
||||
public void setShare(boolean share) {
|
||||
isShare = share;
|
||||
}
|
||||
|
||||
public float getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(float direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public String getPoiType() {
|
||||
return poiType;
|
||||
}
|
||||
|
||||
public void setPoiType(String poiType) {
|
||||
this.poiType = poiType;
|
||||
}
|
||||
|
||||
public long getMainInfoId() {
|
||||
return mainInfoId;
|
||||
}
|
||||
|
||||
public void setMainInfoId(long mainInfoId) {
|
||||
this.mainInfoId = mainInfoId;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getFromType() {
|
||||
return fromType;
|
||||
}
|
||||
|
||||
public void setFromType(String fromType) {
|
||||
this.fromType = fromType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InformationBody{" +
|
||||
"data='" + data + '\'' +
|
||||
", addr='" + addr + '\'' +
|
||||
", areaCode='" + areaCode + '\'' +
|
||||
", areaName='" + areaName + '\'' +
|
||||
", cityCode='" + cityCode + '\'' +
|
||||
", cityName='" + cityName + '\'' +
|
||||
", generateTime=" + generateTime +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", provinceName='" + provinceName + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", street='" + street + '\'' +
|
||||
", type=" + type +
|
||||
", uid=" + uid +
|
||||
", infoType=" + infoType +
|
||||
", infoTimeout=" + infoTimeout +
|
||||
", trafficInfoType='" + trafficInfoType + '\'' +
|
||||
", isShare=" + isShare +
|
||||
", direction=" + direction +
|
||||
", poiType='" + poiType + '\'' +
|
||||
", mainInfoId=" + mainInfoId +
|
||||
", speed=" + speed +
|
||||
", fromType='" + fromType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.cloud.tanlu.bean.location.MarkerLocation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class MarkerExploreWay implements Serializable {
|
||||
private String infoId;
|
||||
private String type;//卡片类型,
|
||||
|
||||
private String poiType;
|
||||
private String sn;
|
||||
private MarkerLocation location;//位置信息
|
||||
private int direction;//方位角度
|
||||
private boolean canLive;//是否可直播(1为可直播,0不可直播)
|
||||
private int fileType;//是图片还是视频(1视频,0图片)
|
||||
private String addr;//北京市朝阳区三里屯街道108号
|
||||
private long generateTime;//时间戳
|
||||
private String cityName;//:"城市名称",
|
||||
private double distance;//距离
|
||||
private MarkerUserInfo userInfo;//用户信息
|
||||
private List<MarkerExploreWayItem> items;//视频地址和图片地址
|
||||
//上报类型:1-用户上报,2-后台上报 3-三方上报
|
||||
private String uploadType;
|
||||
|
||||
private boolean fabulous;
|
||||
|
||||
// http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42321443
|
||||
// 1 需要用户判断是否拥堵 进行UGC问答
|
||||
private int infoCheckNode;
|
||||
|
||||
public String getAddr() {
|
||||
if (TextUtils.isEmpty(addr)) {
|
||||
return "未知道路";
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public boolean getCanLive() {
|
||||
return canLive;
|
||||
}
|
||||
|
||||
public void setCanLive(boolean canLive) {
|
||||
this.canLive = canLive;
|
||||
}
|
||||
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
public float getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public double getFileType() {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
public void setFileType(int fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
public Long getGenerateTime() {
|
||||
return generateTime;
|
||||
}
|
||||
|
||||
public void setGenerateTime(Long generateTime) {
|
||||
this.generateTime = generateTime;
|
||||
}
|
||||
|
||||
public List<MarkerExploreWayItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<MarkerExploreWayItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public MarkerLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(MarkerLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public MarkerUserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(MarkerUserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
public String getInfoId() {
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public int getInfoIdInt() {
|
||||
try {
|
||||
return Integer.parseInt(infoId);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setInfoId(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
||||
public String getPoiType() {
|
||||
if (TextUtils.isEmpty(poiType)) {
|
||||
return "10007"; //拥堵
|
||||
}
|
||||
return poiType;
|
||||
}
|
||||
|
||||
public void setPoiType(String poiType) {
|
||||
this.poiType = poiType;
|
||||
}
|
||||
|
||||
public String getUploadType() {
|
||||
return uploadType;
|
||||
}
|
||||
|
||||
public void setUploadType(String uploadType) {
|
||||
this.uploadType = uploadType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MarkerExploreWay that = (MarkerExploreWay) o;
|
||||
return Objects.equals(infoId, that.infoId) &&
|
||||
Objects.equals(type, that.type) &&
|
||||
Objects.equals(poiType, that.poiType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(infoId, type, poiType);
|
||||
}
|
||||
|
||||
public boolean isCanLive() {
|
||||
return canLive;
|
||||
}
|
||||
|
||||
public void setGenerateTime(long generateTime) {
|
||||
this.generateTime = generateTime;
|
||||
}
|
||||
|
||||
public int getInfoCheckNode() {
|
||||
return infoCheckNode;
|
||||
}
|
||||
|
||||
public void setInfoCheckNode(int infoCheckNode) {
|
||||
this.infoCheckNode = infoCheckNode;
|
||||
}
|
||||
|
||||
public boolean isFabulous() {
|
||||
return fabulous;
|
||||
}
|
||||
|
||||
public void setFabulous(boolean fabulous) {
|
||||
this.fabulous = fabulous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerExploreWay{" +
|
||||
"infoId='" + infoId + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", poiType='" + poiType + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", location=" + location +
|
||||
", direction=" + direction +
|
||||
", canLive=" + canLive +
|
||||
", fileType=" + fileType +
|
||||
", addr='" + addr + '\'' +
|
||||
", generateTime=" + generateTime +
|
||||
", cityName='" + cityName + '\'' +
|
||||
", distance=" + distance +
|
||||
", userInfo=" + userInfo +
|
||||
", items=" + items +
|
||||
", uploadType='" + uploadType + '\'' +
|
||||
", fabulous=" + fabulous +
|
||||
", infoCheckNode=" + infoCheckNode +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class MarkerExploreWayItem implements Serializable {
|
||||
private String thumbnail;
|
||||
private String url;
|
||||
private String content;
|
||||
private double illegalCount;
|
||||
|
||||
public String getThumbnail() {
|
||||
if (TextUtils.isEmpty(thumbnail)) {
|
||||
return "";
|
||||
}
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public void setThumbnail(String thumbnail) {
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return "";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public double getIllegalCount() {
|
||||
return illegalCount;
|
||||
}
|
||||
|
||||
public void setIllegalCount(double illegalCount) {
|
||||
this.illegalCount = illegalCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerExploreWayItem{" +
|
||||
"thumbnail='" + thumbnail + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", illegalCount='" + illegalCount + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class MarkerUserInfo implements Serializable {
|
||||
private String sn;
|
||||
private long userId;
|
||||
private String userName;//用户昵称
|
||||
private String userHead;//用户头像
|
||||
private String gender;//gender": "男|女|无(也可以0|1|2根据实际库存返回即可)
|
||||
private Integer age;// 年龄段,可以为空,与车聊聊一致
|
||||
|
||||
// TODO V2X临时字段,接口出好后进行修改
|
||||
private String lastActiveweekAvgscore;//末次活跃周驾驶行为平均得分
|
||||
private String safeLabel;//车辆安全标签
|
||||
private int safeLabelType;//1老司机 2安全驾驶 3危险驾驶
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public int getAgeNumber() {
|
||||
if (age != null) {
|
||||
return age;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getAge() {
|
||||
try {
|
||||
if (getAgeNumber() >= 0) {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
|
||||
//2020-30=1990
|
||||
double ageDiffer = year - getAgeNumber();
|
||||
String ageStr = "" + ageDiffer;
|
||||
char[] ageChars = ageStr.toCharArray();
|
||||
|
||||
//1990
|
||||
char ageChar = ageChars[2];
|
||||
|
||||
String ageString = "未设置";
|
||||
|
||||
switch (ageChar) {
|
||||
case '0':
|
||||
ageString = "00后";
|
||||
break;
|
||||
case '1':
|
||||
ageString = "10后";
|
||||
break;
|
||||
case '2':
|
||||
ageString = "20后";
|
||||
break;
|
||||
case '3':
|
||||
ageString = "30后";
|
||||
break;
|
||||
case '4':
|
||||
ageString = "40后";
|
||||
break;
|
||||
case '5':
|
||||
ageString = "50后";
|
||||
break;
|
||||
case '6':
|
||||
ageString = "60后";
|
||||
break;
|
||||
case '7':
|
||||
ageString = "70后";
|
||||
break;
|
||||
case '8':
|
||||
ageString = "80后";
|
||||
break;
|
||||
case '9':
|
||||
ageString = "90后";
|
||||
break;
|
||||
}
|
||||
|
||||
return ageString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public int getGenderValue() {
|
||||
if (!TextUtils.isEmpty(gender)) {
|
||||
if ("男".equals(gender)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
if (TextUtils.isEmpty(gender)) {
|
||||
return "未设置";
|
||||
}
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public void setGender(int gender) {
|
||||
if (gender == 0) {
|
||||
this.gender = "男";
|
||||
} else {
|
||||
this.gender = "女";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
if (TextUtils.isEmpty(sn)) {
|
||||
return "";
|
||||
}
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getUserHead() {
|
||||
if (TextUtils.isEmpty(userHead)) {
|
||||
return "";
|
||||
}
|
||||
return userHead;
|
||||
}
|
||||
|
||||
public void setUserHead(String userHead) {
|
||||
this.userHead = userHead;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
if (TextUtils.isEmpty(userName)) {
|
||||
return "用户未设置昵称";
|
||||
}
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getLastActiveweekAvgscore() {
|
||||
return lastActiveweekAvgscore;
|
||||
}
|
||||
|
||||
public void setLastActiveweekAvgscore(String lastActiveweekAvgscore) {
|
||||
this.lastActiveweekAvgscore = lastActiveweekAvgscore;
|
||||
}
|
||||
|
||||
public String getSafeLabel() {
|
||||
return safeLabel;
|
||||
}
|
||||
|
||||
public void setSafeLabel(String safeLabel) {
|
||||
this.safeLabel = safeLabel;
|
||||
}
|
||||
|
||||
public int getSafeLabelType() {
|
||||
return safeLabelType;
|
||||
}
|
||||
|
||||
public void setSafeLabelType(int safeLabelType) {
|
||||
this.safeLabelType = safeLabelType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerUserInfo{" +
|
||||
"sn='" + sn + '\'' +
|
||||
", userId=" + userId +
|
||||
", userName='" + userName + '\'' +
|
||||
", userHead='" + userHead + '\'' +
|
||||
", gender='" + gender + '\'' +
|
||||
", age=" + age +
|
||||
", lastActiveweekAvgscore='" + lastActiveweekAvgscore + '\'' +
|
||||
", safeLabel='" + safeLabel + '\'' +
|
||||
", safeLabelType=" + safeLabelType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import com.mogo.cloud.tanlu.bean.location.Location;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class RoadInfoRequest {
|
||||
|
||||
private Location location;
|
||||
private ArrayList<String> poiTypes;
|
||||
private boolean onlyFocus;
|
||||
private boolean onlySameCity;
|
||||
|
||||
public RoadInfoRequest(Location location, ArrayList<String> poiTypes, boolean onlyFocus, boolean onlySameCity) {
|
||||
this.location = location;
|
||||
this.poiTypes = poiTypes;
|
||||
this.onlyFocus = onlyFocus;
|
||||
this.onlySameCity = onlySameCity;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public ArrayList<String> getPoiTypes() {
|
||||
return poiTypes;
|
||||
}
|
||||
|
||||
public void setPoiTypes(ArrayList<String> poiTypes) {
|
||||
this.poiTypes = poiTypes;
|
||||
}
|
||||
|
||||
public boolean isOnlyFocus() {
|
||||
return onlyFocus;
|
||||
}
|
||||
|
||||
public void setOnlyFocus(boolean onlyFocus) {
|
||||
this.onlyFocus = onlyFocus;
|
||||
}
|
||||
|
||||
public boolean isOnlySameCity() {
|
||||
return onlySameCity;
|
||||
}
|
||||
|
||||
public void setOnlySameCity(boolean onlySameCity) {
|
||||
this.onlySameCity = onlySameCity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoadInfoRequest{" +
|
||||
"location=" + location +
|
||||
", poiTypes=" + poiTypes +
|
||||
", onlyFocus=" + onlyFocus +
|
||||
", onlySameCity=" + onlySameCity +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class RoadInfos{
|
||||
|
||||
private List<MarkerExploreWay> data;
|
||||
|
||||
public List<MarkerExploreWay> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<MarkerExploreWay> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.tanlu.bean;
|
||||
package com.mogo.cloud.tanlu.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.cloud.tanlu.bean.location;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class Location implements Serializable {
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.mogo.cloud.tanlu.bean.location;
|
||||
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description
|
||||
*
|
||||
* @author lixiaopeng
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class MarkerLocation implements Serializable {
|
||||
private double lat;//纬度
|
||||
private double lon;//经度
|
||||
private double angle;//车头角度,可以没有
|
||||
private String address;//具体的位置信息
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void setAngle(double angle) {
|
||||
this.angle = angle;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
if (TextUtils.isEmpty(address)) {
|
||||
return "";
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerLocation{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", angle=" + angle +
|
||||
", address='" + address + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
package com.mogo.cloud.tanlu.bean.location;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class MogoLocation implements Cloneable, Parcelable {
|
||||
private int locType = 0;
|
||||
private double latitude = 0;
|
||||
private double longitude = 0;
|
||||
private double altitude = 0;
|
||||
private long time = 0;
|
||||
private float bearing = 0;
|
||||
private float accuracy = 0;
|
||||
private float speed = 0;
|
||||
private String cityName = "";
|
||||
private String cityCode = "";
|
||||
private String provider = "";
|
||||
private String address = "";
|
||||
private String district = "";
|
||||
private String province = "";
|
||||
private String adCode = "";
|
||||
private String locationDetail = "";
|
||||
private String poiName = "";
|
||||
private String aoiName = "";
|
||||
private int errCode = 0;
|
||||
private String errInfo = "";
|
||||
private String street = "";
|
||||
private String streetNum = "";
|
||||
private String description = "";
|
||||
private String buildingId = "";
|
||||
private String floor = "";
|
||||
private int gpsAccuracyStatus = 0;
|
||||
private int satellite = 0;
|
||||
|
||||
public float getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
public void setBearing( float bearing ) {
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public float getAccuracy() {
|
||||
return accuracy;
|
||||
}
|
||||
|
||||
public void setAccuracy( float accuracy ) {
|
||||
this.accuracy = accuracy;
|
||||
}
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public void setProvider( String provider ) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed( float speed ) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getLocationDetail() {
|
||||
return locationDetail;
|
||||
}
|
||||
|
||||
public void setLocationDetail( String locationDetail ) {
|
||||
this.locationDetail = locationDetail;
|
||||
}
|
||||
|
||||
public String getPoiName() {
|
||||
return poiName;
|
||||
}
|
||||
|
||||
public void setPoiName( String poiName ) {
|
||||
this.poiName = poiName;
|
||||
}
|
||||
|
||||
public String getAoiName() {
|
||||
return aoiName;
|
||||
}
|
||||
|
||||
public void setAoiName( String aoiName ) {
|
||||
this.aoiName = aoiName;
|
||||
}
|
||||
|
||||
public int getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
public void setErrCode( int errCode ) {
|
||||
this.errCode = errCode;
|
||||
}
|
||||
|
||||
public String getErrInfo() {
|
||||
return errInfo;
|
||||
}
|
||||
|
||||
public void setErrInfo( String errInfo ) {
|
||||
this.errInfo = errInfo;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getStreetNum() {
|
||||
return streetNum;
|
||||
}
|
||||
|
||||
public void setStreetNum( String streetNum ) {
|
||||
this.streetNum = streetNum;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription( String description ) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getBuildingId() {
|
||||
return buildingId;
|
||||
}
|
||||
|
||||
public void setBuildingId( String buildingId ) {
|
||||
this.buildingId = buildingId;
|
||||
}
|
||||
|
||||
public String getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
public void setFloor( String floor ) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
public int getGpsAccuracyStatus() {
|
||||
return gpsAccuracyStatus;
|
||||
}
|
||||
|
||||
public void setGpsAccuracyStatus( int gpsAccuracyStatus ) {
|
||||
this.gpsAccuracyStatus = gpsAccuracyStatus;
|
||||
}
|
||||
|
||||
public int getSatellite() {
|
||||
return satellite;
|
||||
}
|
||||
|
||||
public void setSatellite( int satellite ) {
|
||||
this.satellite = satellite;
|
||||
}
|
||||
|
||||
public MogoLocation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MogoLocation{" +
|
||||
"locType=" + locType +
|
||||
", latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", altitude=" + altitude +
|
||||
", time=" + time +
|
||||
", bearing=" + bearing +
|
||||
", accuracy=" + accuracy +
|
||||
", speed=" + speed +
|
||||
", cityName='" + cityName + '\'' +
|
||||
", cityCode='" + cityCode + '\'' +
|
||||
", provider='" + provider + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
", district='" + district + '\'' +
|
||||
", province='" + province + '\'' +
|
||||
", adCode='" + adCode + '\'' +
|
||||
", locationDetail='" + locationDetail + '\'' +
|
||||
", poiName='" + poiName + '\'' +
|
||||
", aoiName='" + aoiName + '\'' +
|
||||
", errCode=" + errCode +
|
||||
", errInfo='" + errInfo + '\'' +
|
||||
", street='" + street + '\'' +
|
||||
", streetNum='" + streetNum + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", buildingId='" + buildingId + '\'' +
|
||||
", floor='" + floor + '\'' +
|
||||
", gpsAccuracyStatus=" + gpsAccuracyStatus +
|
||||
", satellite=" + satellite +
|
||||
'}';
|
||||
}
|
||||
|
||||
public double getAltitude() {
|
||||
return altitude;
|
||||
}
|
||||
|
||||
public void setAltitude( double altitude ) {
|
||||
this.altitude = altitude;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress( String address ) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict( String district ) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince( String province ) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getAdCode() {
|
||||
return adCode;
|
||||
}
|
||||
|
||||
public void setAdCode( String adCode ) {
|
||||
this.adCode = adCode;
|
||||
}
|
||||
|
||||
public int getLocType() {
|
||||
return locType;
|
||||
}
|
||||
|
||||
public void setLocType( int locType ) {
|
||||
this.locType = locType;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude( double latitude ) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude( double longitude ) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime( long time ) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getCityCode() {
|
||||
return cityCode;
|
||||
}
|
||||
|
||||
public void setCityCode( String cityCode ) {
|
||||
this.cityCode = cityCode;
|
||||
}
|
||||
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public void setCityName( String cityName ) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLocation clone() {
|
||||
try {
|
||||
return ( MogoLocation ) super.clone();
|
||||
} catch ( CloneNotSupportedException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags ) {
|
||||
dest.writeInt( this.locType );
|
||||
dest.writeDouble( this.latitude );
|
||||
dest.writeDouble( this.longitude );
|
||||
dest.writeDouble( this.altitude );
|
||||
dest.writeLong( this.time );
|
||||
dest.writeFloat( this.bearing );
|
||||
dest.writeFloat( this.accuracy );
|
||||
dest.writeFloat( this.speed );
|
||||
dest.writeString( this.cityName );
|
||||
dest.writeString( this.cityCode );
|
||||
dest.writeString( this.provider );
|
||||
dest.writeString( this.address );
|
||||
dest.writeString( this.district );
|
||||
dest.writeString( this.province );
|
||||
dest.writeString( this.adCode );
|
||||
dest.writeString( this.locationDetail );
|
||||
dest.writeString( this.poiName );
|
||||
dest.writeString( this.aoiName );
|
||||
dest.writeInt( this.errCode );
|
||||
dest.writeString( this.errInfo );
|
||||
dest.writeString( this.street );
|
||||
dest.writeString( this.streetNum );
|
||||
dest.writeString( this.description );
|
||||
dest.writeString( this.buildingId );
|
||||
dest.writeString( this.floor );
|
||||
dest.writeInt( this.gpsAccuracyStatus );
|
||||
dest.writeInt( this.satellite );
|
||||
}
|
||||
|
||||
protected MogoLocation( Parcel in ) {
|
||||
this.locType = in.readInt();
|
||||
this.latitude = in.readDouble();
|
||||
this.longitude = in.readDouble();
|
||||
this.altitude = in.readDouble();
|
||||
this.time = in.readLong();
|
||||
this.bearing = in.readFloat();
|
||||
this.accuracy = in.readFloat();
|
||||
this.speed = in.readFloat();
|
||||
this.cityName = in.readString();
|
||||
this.cityCode = in.readString();
|
||||
this.provider = in.readString();
|
||||
this.address = in.readString();
|
||||
this.district = in.readString();
|
||||
this.province = in.readString();
|
||||
this.adCode = in.readString();
|
||||
this.locationDetail = in.readString();
|
||||
this.poiName = in.readString();
|
||||
this.aoiName = in.readString();
|
||||
this.errCode = in.readInt();
|
||||
this.errInfo = in.readString();
|
||||
this.street = in.readString();
|
||||
this.streetNum = in.readString();
|
||||
this.description = in.readString();
|
||||
this.buildingId = in.readString();
|
||||
this.floor = in.readString();
|
||||
this.gpsAccuracyStatus = in.readInt();
|
||||
this.satellite = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< MogoLocation > CREATOR = new Parcelable.Creator< MogoLocation >() {
|
||||
@Override
|
||||
public MogoLocation createFromParcel( Parcel source ) {
|
||||
return new MogoLocation( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLocation[] newArray( int size ) {
|
||||
return new MogoLocation[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.tanlu.constant;
|
||||
package com.mogo.cloud.tanlu.constant;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mogo.tanlu.net;
|
||||
package com.mogo.cloud.tanlu.net;
|
||||
|
||||
import com.mogo.tanlu.bean.RoadInfos;
|
||||
import com.mogo.tanlu.bean.UploadResult;
|
||||
import com.mogo.cloud.tanlu.bean.RoadInfos;
|
||||
import com.mogo.cloud.tanlu.bean.UploadResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.mogo.tanlu.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class RoadInfos {
|
||||
|
||||
private List<TanluMarkerExploreWay> data;
|
||||
|
||||
public List<TanluMarkerExploreWay> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<TanluMarkerExploreWay> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.mogo.tanlu.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2021/1/20
|
||||
*/
|
||||
public class TanluMarkerExploreWay implements Serializable {
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.mogo.tanlu;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user