Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk
# Conflicts: # modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
package com.mogo.map.impl.custom;
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 道路数据缓存
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class RoadCacheWrapper {
|
||||
private List<LonLatPoint> road;
|
||||
private double lastDistanceDiff;
|
||||
private int roadLength = -1;
|
||||
|
||||
public RoadCacheWrapper(List<LonLatPoint> road) {
|
||||
setRoad(road);
|
||||
}
|
||||
|
||||
public List<LonLatPoint> getRoad() {
|
||||
return road;
|
||||
}
|
||||
|
||||
public void setRoad(List<LonLatPoint> road) {
|
||||
this.road = road;
|
||||
if(road!=null) {
|
||||
roadLength = road.size();
|
||||
}
|
||||
}
|
||||
|
||||
public double getLastDistanceDiff() {
|
||||
return lastDistanceDiff;
|
||||
}
|
||||
|
||||
public void setLastDistanceDiff(double lastDistanceDiff) {
|
||||
this.lastDistanceDiff = lastDistanceDiff;
|
||||
}
|
||||
|
||||
public double getLastLat(){
|
||||
if (roadLength != -1) {
|
||||
return road.get(roadLength - 1).getLatitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getLastLon(){
|
||||
if (roadLength != -1) {
|
||||
return road.get(roadLength - 1).getLongitude();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean inCache(double lon, double lat) {
|
||||
if (roadLength > 0) {
|
||||
LonLatPoint start = road.get(0);
|
||||
LonLatPoint end = road.get(roadLength - 1);
|
||||
boolean latInRoad = false;
|
||||
boolean lonInRoad = false;
|
||||
if (start.getLatitude() > end.getLatitude()) {
|
||||
latInRoad = lat <= start.getLatitude() && lat >= end.getLatitude();
|
||||
}else{
|
||||
latInRoad = lat >= start.getLatitude() && lat <= end.getLatitude();
|
||||
}
|
||||
|
||||
if (start.getLongitude() > end.getLongitude()) {
|
||||
lonInRoad = lon <= start.getLongitude() && lon >= end.getLongitude();
|
||||
}else{
|
||||
lonInRoad = lon >= start.getLongitude() && lon <= end.getLongitude();
|
||||
}
|
||||
|
||||
return latInRoad && lonInRoad;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -315,9 +315,9 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
public double[] matchRoad( String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
if ( mClient != null ) {
|
||||
return mClient.matchRoad( lon, lat, angle, isGpsLocation, isRTK );
|
||||
return mClient.matchRoad( id, lon, lat, angle, isGpsLocation, isRTK );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -61,13 +61,15 @@ public class PointInterpolatorUtil {
|
||||
getCloseTwoPoint( lon, lat, road );
|
||||
LonLatPoint start = road.get( closeStart );
|
||||
LonLatPoint end = road.get( closeEnd );
|
||||
Logger.d( TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd );
|
||||
// Logger.d( TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd );
|
||||
// return getMid(start, end);
|
||||
double[] foot = getFoot( lon, lat, start, end );
|
||||
// double[] foot = getFoot( lon, lat, start, end );
|
||||
|
||||
float d = CoordinateUtils.calculateLineDistance( foot[0], foot[1], lon, lat );
|
||||
Logger.d( TAG, "distance to mid line==" + d );
|
||||
return new double[]{foot[0], foot[1], d};
|
||||
// float d = CoordinateUtils.calculateLineDistance( foot[0], foot[1], lon, lat );
|
||||
// Logger.d( TAG, "distance to mid line==" + d );
|
||||
// return new double[]{foot[0], foot[1], d};
|
||||
|
||||
return getFootAndMinDistance(lon, lat, start.getLongitude(), start.getLatitude(), end.getLongitude(), end.getLatitude());
|
||||
}
|
||||
|
||||
private static int closeStart = 0;
|
||||
@@ -99,6 +101,57 @@ public class PointInterpolatorUtil {
|
||||
return new double[]{beginPt.getLongitude() + u * dy, beginPt.getLatitude() + u * dx};
|
||||
}
|
||||
|
||||
|
||||
// un minDistance(x: Double, y: Double, x1: Double, y1: Double, x2: Double, y2: Double): Double {
|
||||
// val cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1)
|
||||
// println("1.cross:$cross")
|
||||
// if (cross <= 0) {
|
||||
// return Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))
|
||||
// }
|
||||
// val d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
|
||||
// println("2.d2:$cross")
|
||||
// if (cross > d2) {
|
||||
// return Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2))
|
||||
// }
|
||||
// val r = cross / d2
|
||||
// val px = x1 + (x2 - x1) * r
|
||||
// val py = y1 + (y2 - y1) * r
|
||||
// println("3.r:$r,px:$px,py:$py")
|
||||
// return Math.sqrt((x - px) * (x - px) + (py - y) * (py - y))
|
||||
// }
|
||||
|
||||
/**
|
||||
* 计算垂足以及最短距离
|
||||
*
|
||||
* @param x target point lon
|
||||
* @param y target point lat
|
||||
* @param x1 start point lon
|
||||
* @param y1 start point lat
|
||||
* @param x2 end point lon
|
||||
* @param y2 end point lat
|
||||
* @return double[]{footLon,footLat,minDistance} if(footLon == -1) => no foot or foot not in line
|
||||
*/
|
||||
private static double[] getFootAndMinDistance(double x, double y, double x1, double y1, double x2, double y2) {
|
||||
double[] result = new double[]{-1, -1, -1};
|
||||
double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);
|
||||
if (cross < 0) {
|
||||
// 垂足没有在线段内,所以也无需计算最短距离
|
||||
// result[2] = Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
|
||||
return result;
|
||||
}
|
||||
double d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
|
||||
if (cross > d2) {
|
||||
// 垂足没有在线段内,所以也无需计算最短距离
|
||||
// result[2] = Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
|
||||
return result;
|
||||
}
|
||||
double r = cross / d2;
|
||||
result[0] = x1 + (x2 - x1) * r;
|
||||
result[1] = y1 + (y2 - y1) * r;
|
||||
result[2] = Math.sqrt((x - result[0]) * (x - result[0]) + (result[1] - y) * (result[1] - y));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static double[] getMid( LonLatPoint start, LonLatPoint end ) {
|
||||
return new double[]{( start.getLongitude() + end.getLongitude() ) / 2, ( start.getLatitude() + end.getLatitude() ) / 2};
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public interface IMogoMapUIController {
|
||||
* @param isRTK
|
||||
* @return
|
||||
*/
|
||||
default double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
default double[] matchRoad(String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,10 +355,10 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
public double[] matchRoad( String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
initDelegate();
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.matchRoad( lon, lat, angle, isGpsLocation, isRTK );
|
||||
return mDelegate.matchRoad( id, lon, lat, angle, isGpsLocation, isRTK );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -188,8 +188,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.lon,
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.uuid, recognizedListResult.lon,
|
||||
recognizedListResult.lat,
|
||||
recognizedListResult.heading,
|
||||
true
|
||||
|
||||
@@ -208,14 +208,14 @@ class BaseDrawer {
|
||||
* @param isRtk
|
||||
* @return
|
||||
*/
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isRtk ) {
|
||||
public double[] matchRoad( String id, double lon, double lat, double angle, boolean isRtk ) {
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchRoad = MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( lon, lat, angle, true, isRtk );
|
||||
Log.i( "timer-matchRoad", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
.matchRoad( id, lon, lat, angle, true, isRtk );
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,8 @@ public class SimpleHandlerThreadPool {
|
||||
}
|
||||
}
|
||||
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( cloudRoadData.getWgslon(),
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( cloudRoadData.getUniqueKey(),
|
||||
cloudRoadData.getWgslon(),
|
||||
cloudRoadData.getWgslat(),
|
||||
cloudRoadData.getHeading(),
|
||||
true
|
||||
|
||||
Reference in New Issue
Block a user