pull code of origin
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.mogo.realtime.Interface;
|
||||
package com.mogo.realtime.api;
|
||||
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.realtime.Interface;
|
||||
package com.mogo.realtime.api;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mogo.realtime.constant;
|
||||
|
||||
public class RealTimeConstant {
|
||||
|
||||
public static final String TAG = "MoGoAiCloud_RealTime";
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mogo.realtime.core;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import android.support.annotation.Keep;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.realtime.util.MogoLatLng;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -39,7 +39,9 @@ public class SimpleLocationCorrectStrategy {
|
||||
private final List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
|
||||
public CloudLocationInfo correct(CloudLocationInfo info) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
}
|
||||
if (isLocationValid(info)) {
|
||||
if (recordLocation()) {
|
||||
historyList.add(info);
|
||||
@@ -48,29 +50,36 @@ public class SimpleLocationCorrectStrategy {
|
||||
if (lastLocation == null) {
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
Logger.d(TAG, "第一条数据");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "第一条数据");
|
||||
}
|
||||
if (recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
if (lastLocation.equals(info)) {
|
||||
Logger.d(TAG, "相同坐标点==");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "相同坐标点==");
|
||||
}
|
||||
return info;
|
||||
}
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
|
||||
Logger.d(TAG,
|
||||
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
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 (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "在范围内,为有效点");
|
||||
}
|
||||
if (recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
@@ -86,7 +95,9 @@ public class SimpleLocationCorrectStrategy {
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "出错次数超限,异常点变有效点");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "出错次数超限,异常点变有效点");
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
@@ -102,7 +113,9 @@ public class SimpleLocationCorrectStrategy {
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
}
|
||||
if (recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
@@ -110,11 +123,15 @@ public class SimpleLocationCorrectStrategy {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "定位点异常");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "定位点异常");
|
||||
}
|
||||
if (lastLocation == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -122,8 +139,10 @@ public class SimpleLocationCorrectStrategy {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = CoordinateUtils.calculateLineDistance(lastLocation.getLon(), lastLocation.getLat(), info.getLon(), info.getLat());
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
}
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
@@ -137,13 +156,17 @@ public class SimpleLocationCorrectStrategy {
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
}
|
||||
if (recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
return nextInfo;
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
if (MoGoAiCloudClient.getInstance().getAiCloudClientConfig().isShowDebugLog()) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ import com.mogo.realtime.socket.SocketHandler;
|
||||
*/
|
||||
public class SnapshotUploadInTime implements UploadInTimeHandler.IUploadInTimeListener {
|
||||
|
||||
private static final String TAG = "SnapshotUploadInTime";
|
||||
private static volatile SnapshotUploadInTime sInstance;
|
||||
//是否使用外部定位数据
|
||||
private boolean isUseExternalLocation = false;
|
||||
private final boolean isUseExternalLocation;
|
||||
|
||||
private SnapshotUploadInTime() {
|
||||
isUseExternalLocation = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getIsUseExternalLocation();
|
||||
|
||||
@@ -2,17 +2,17 @@ package com.mogo.realtime.core;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import android.support.annotation.Keep;
|
||||
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
/**
|
||||
* AI云 实时上报数据频率处理类
|
||||
*/
|
||||
public class UploadInTimeHandler {
|
||||
|
||||
private static final String TAG = "UploadInTimeHandler";
|
||||
private static final int MSG_DATA_CHANGED = 0x100;
|
||||
private static final long MSG_DATA_INTERNAL = 500L;
|
||||
private final long uploadDelay = MSG_DATA_INTERNAL;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mogo.realtime.entity;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
|
||||
|
||||
@@ -14,15 +14,16 @@ import com.mogo.utils.logger.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
/**
|
||||
* AI云SDK内部定位服务
|
||||
*/
|
||||
public class MogoRTKLocation {
|
||||
|
||||
private static final String TAG = "MogoRTKLocation";
|
||||
|
||||
private LocationManager locationManager;
|
||||
private final List<CloudLocationInfo> cacheList = new ArrayList<>();
|
||||
private CloudLocationInfo locInfo;
|
||||
|
||||
public static MogoRTKLocation getInstance() {
|
||||
return RTKHolder.rtkLoc;
|
||||
@@ -38,7 +39,14 @@ public class MogoRTKLocation {
|
||||
|
||||
public List<CloudLocationInfo> sendLocationData() {
|
||||
List<CloudLocationInfo> list = new ArrayList<>(cacheList);
|
||||
if (cacheList != null && cacheList.size() > 0) {
|
||||
if (cacheList.size() == 0) {
|
||||
if (locInfo != null) {
|
||||
cacheList.add(locInfo);
|
||||
} else {
|
||||
Logger.e(TAG, "暂无定位数据");
|
||||
return list;
|
||||
}
|
||||
} else {
|
||||
cacheList.clear();
|
||||
}
|
||||
return list;
|
||||
@@ -78,7 +86,7 @@ public class MogoRTKLocation {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private LocationListener locationListener = new LocationListener() {
|
||||
private final LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
@@ -91,6 +99,7 @@ public class MogoRTKLocation {
|
||||
cloudLocationInfo.setSatelliteTime(location.getTime());
|
||||
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
locInfo = cloudLocationInfo;
|
||||
cacheList.add(cloudLocationInfo);
|
||||
} else {
|
||||
Logger.e(TAG, "location == null");
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.realtime.socket;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener;
|
||||
@@ -17,7 +16,9 @@ import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.entity.OnePerSecondSendContent;
|
||||
import com.mogo.realtime.spi.RealTimeProviderImp;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.GsonUtil;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,15 +26,19 @@ import java.util.List;
|
||||
import static com.mogo.cloud.socket.WebSocketMsgType.MSG_TYPE_ACK;
|
||||
import static com.mogo.cloud.socket.WebSocketMsgType.MSG_TYPE_DOWNLINK_CAR_DATA;
|
||||
import static com.mogo.cloud.socket.WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
import static com.mogo.realtime.constant.RealTimeConstant.TAG;
|
||||
|
||||
/**
|
||||
* Socket长链 业务服务处理类
|
||||
*/
|
||||
public class SocketHandler {
|
||||
|
||||
private static final String TAG = "SocketHandler";
|
||||
private static volatile SocketHandler mInstance;
|
||||
private static final int HEADER_TYPE = MogoConnsvr.MsgType.mogoMsgTypeCollectSvrNoRspReq.getNumber();
|
||||
private static final int HIGH_FREQUENCY_CHANNEL_ID = 0x040002; //高频数据
|
||||
private static final int LOW_FREQUENCY_CHANNEL_ID = 0x040003; //低频数据
|
||||
|
||||
private String mAppId;
|
||||
private long serverTime = 0;
|
||||
private long receiveMsgTime = 0;
|
||||
private CloudLocationInfo mLastInfo;
|
||||
@@ -58,12 +63,10 @@ public class SocketHandler {
|
||||
* @param appId 外部传入
|
||||
*/
|
||||
public void initSocket(Context context, String appId) {
|
||||
SocketManager.getInstance().init(context, appId);
|
||||
int msgType = 0x040003;
|
||||
Log.i(TAG,"msgType : " + msgType);
|
||||
Log.i(TAG,"msgType integer : " + (Integer)msgType);
|
||||
SocketManager.getInstance().registerOnMessageListener(0x040002, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(0x040003, onMessageListener);
|
||||
mAppId = appId;
|
||||
SocketManager.getInstance().init(context);
|
||||
SocketManager.getInstance().registerOnMessageListener(HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
}
|
||||
|
||||
public void registerOnMsgListener(IMogoCloudOnMsgListener onMsgListener) {
|
||||
@@ -99,11 +102,9 @@ public class SocketHandler {
|
||||
receiveMsgTime = SystemClock.elapsedRealtime();
|
||||
if (webSocketData.getUpUtcTime() > 0) {
|
||||
long nextDelay = webSocketData.getUpUtcTime() - serverTime;
|
||||
if (!MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getIsUseExternalLocation()) {
|
||||
for (IMogoCloudOnAckListener ackListener : onAckListenerList) {
|
||||
if (ackListener != null) {
|
||||
ackListener.onAck(nextDelay);
|
||||
}
|
||||
for (IMogoCloudOnAckListener ackListener : onAckListenerList) {
|
||||
if (ackListener != null) {
|
||||
ackListener.onAck(nextDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ public class SocketHandler {
|
||||
if (msgType == MSG_TYPE_DOWNLINK_CAR_DATA.getMsgType()) {
|
||||
MogoSnapshotSetData data = GsonUtil.objectFromJson(webSocketData.getData(), MogoSnapshotSetData.class);
|
||||
if (data == null) {
|
||||
Log.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
|
||||
Logger.e(TAG, "onMsgReceived MogoSnapshotSetData == null ");
|
||||
return;
|
||||
}
|
||||
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
|
||||
@@ -126,11 +127,12 @@ public class SocketHandler {
|
||||
|
||||
/**
|
||||
* 发送自车和ADAS数据
|
||||
*
|
||||
* @param cloudLocationInfo 自车定位信息
|
||||
*/
|
||||
public void sendMsg(List<CloudLocationInfo> cloudLocationInfo) {
|
||||
if (cloudLocationInfo == null) {
|
||||
Log.e(TAG, "请检查传入数组对象为Null");
|
||||
Logger.e(TAG, "请检查传入数组对象为Null");
|
||||
return;
|
||||
}
|
||||
CloudLocationInfo lastInfo = null;
|
||||
@@ -162,7 +164,7 @@ public class SocketHandler {
|
||||
|
||||
if (content.self == null &&
|
||||
(content.adas == null || content.adas.isEmpty())) {
|
||||
Log.d(TAG, "no information to sent");
|
||||
Logger.d(TAG, "no information to sent");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,14 +175,14 @@ public class SocketHandler {
|
||||
webSocketData.setData(GsonUtil.jsonFromObject(content));
|
||||
String msg = GsonUtil.jsonFromObject(webSocketData);
|
||||
|
||||
int msgType = 0x040003; //低频数据
|
||||
int msgType = LOW_FREQUENCY_CHANNEL_ID;
|
||||
if (cloudLocationInfo.size() > 2) {
|
||||
msgType = 0x040002; //高频数据
|
||||
msgType = HIGH_FREQUENCY_CHANNEL_ID;
|
||||
}
|
||||
MsgBody msgBody = new MsgBody();
|
||||
msgBody.msgType(msgType);
|
||||
msgBody.content(msg);
|
||||
SocketManager.getInstance().sendMsg(msgBody, msgId -> {
|
||||
SocketManager.getInstance().sendMsg(mAppId, HEADER_TYPE, msgBody, msgId -> {
|
||||
for (IMogoCloudOnMsgListener listener : onMsgListenerList) {
|
||||
if (listener != null) {
|
||||
listener.onMsgSend(msgId);
|
||||
@@ -190,8 +192,8 @@ public class SocketHandler {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(0x040002, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(0x040003, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().release();
|
||||
onMsgListenerList.clear();
|
||||
onAckListenerList.clear();
|
||||
|
||||
@@ -3,8 +3,12 @@ package com.mogo.realtime.spi;
|
||||
|
||||
import com.elegant.spi.AbstractDelegateManager;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
<<<<<<< HEAD
|
||||
import com.mogo.realtime.Interface.IRealTimeProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
=======
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
>>>>>>> 17b3ed341e822ad073ace72a78b08f26214c0059
|
||||
|
||||
/**
|
||||
* 提供RealTime SPI接口实例对象管理类
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mogo.realtime.spi;
|
||||
|
||||
import com.mogo.realtime.Interface.IRealTimeProvider;
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.mogo.realtime.util;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
|
||||
/**
|
||||
* 定位数据类型转换工具
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class LocationParseUtil {
|
||||
/**
|
||||
* 从Location 转 CloudLocationInfo
|
||||
*
|
||||
* @param info 待转数据
|
||||
* @return 转后数据
|
||||
*/
|
||||
public static CloudLocationInfo locationToCloudLocation(Location info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
CloudLocationInfo cloud = new CloudLocationInfo();
|
||||
cloud.setLat(info.getLatitude());
|
||||
cloud.setLon(info.getLongitude());
|
||||
cloud.setAlt(info.getAltitude());
|
||||
cloud.setHeading(info.getBearing());
|
||||
cloud.setSpeed(info.getSpeed());
|
||||
cloud.setSatelliteTime(info.getTime());
|
||||
cloud.setSystemTime(System.currentTimeMillis());
|
||||
return cloud;
|
||||
}
|
||||
|
||||
public static MogoLatLng cloudLocationToMogoLatLng(CloudLocationInfo info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
return new MogoLatLng(info.getLat(), info.getLon());
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,7 @@ package com.mogo.realtime.util;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ public class MortonCode {
|
||||
private static final double RULE_MORTON_TO_LONLAT = 360.0 / Math.pow( 2, 32 );
|
||||
|
||||
/**
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return long 莫顿码
|
||||
*/
|
||||
public static long wrapEncodeMorton( Double lon, Double lat ) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat( "#.######" );
|
||||
@@ -46,13 +46,13 @@ public class MortonCode {
|
||||
/**
|
||||
* 编码 morton code
|
||||
*
|
||||
* @param lon
|
||||
* @param lat
|
||||
* @return
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return long 莫顿码
|
||||
*/
|
||||
public static long encodeMorton( Double lon, Double lat ) {
|
||||
|
||||
Long bit = 1L;
|
||||
long bit = 1L;
|
||||
long mortonCode = 0L;
|
||||
long x = ( long ) ( lon * RULE_MORTON );
|
||||
long y = ( long ) ( lat * RULE_MORTON );
|
||||
@@ -78,8 +78,8 @@ public class MortonCode {
|
||||
/**
|
||||
* 将莫顿码解码为坐标
|
||||
*
|
||||
* @param mortonCode
|
||||
* @return
|
||||
* @param mortonCode 莫顿码
|
||||
* @return 坐标
|
||||
*/
|
||||
public static double[] decodeMorton( long mortonCode ) {
|
||||
long[] midPoint = mortonCodeToCoord( mortonCode );
|
||||
@@ -95,8 +95,8 @@ public class MortonCode {
|
||||
/**
|
||||
* 莫顿码分别拆解为 编码后的经纬度长整数
|
||||
*
|
||||
* @param mortonCode
|
||||
* @return
|
||||
* @param mortonCode 莫顿码
|
||||
* @return 经纬度 长整数
|
||||
*/
|
||||
private static long[] mortonCodeToCoord( long mortonCode ) {
|
||||
long bit = 1L;
|
||||
@@ -114,7 +114,7 @@ public class MortonCode {
|
||||
/**
|
||||
* 对编码后的经纬度长整数进行解码
|
||||
*
|
||||
* @param midPoint
|
||||
* @param midPoint 经纬度 长整数
|
||||
*/
|
||||
private static void normalizeCoord( long[] midPoint ) {
|
||||
// if x > 180 degrees, then subtract 360 degrees
|
||||
@@ -136,7 +136,6 @@ public class MortonCode {
|
||||
midPoint[1] +=
|
||||
NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user