代码优化

This commit is contained in:
wangcongtao
2021-03-03 11:12:31 +08:00
parent b37ee31e65
commit 2069bae645
7 changed files with 39 additions and 30 deletions

View File

@@ -67,7 +67,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.1.7'
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.1.8'
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
}

View File

@@ -54,6 +54,7 @@ import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.MultiPointOverlayOptions;
import com.zhidaoauto.map.sdk.open.marker.OnInfoWindowClickListener;
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
@@ -1022,20 +1023,29 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) lon ), ( ( float ) lat ), ( ( float ) angle ), isGpsLocation, isRTK );
double wgs[] = CoordinateUtils.transformGcj02toWgs84( lat, lon );
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) wgs[0] ), ( ( float ) wgs[1] ), ( ( float ) angle ), isGpsLocation, isRTK );
if ( singlePointRoadInfo != null
&& singlePointRoadInfo.getCoords() != null
&& !singlePointRoadInfo.getCoords().isEmpty() ) {
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( lon, lat, singlePointRoadInfo.getCoords() );
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( wgs[0], wgs[1], singlePointRoadInfo.getCoords() );
// return CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
matchedPoint = CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
MarkerOptions options
= new MarkerOptions( );
options.markerIcon( R.drawable.marker_blue )
.position( new LonLatPoint( matchedPoint[0],matchedPoint[1] ) )
= new MarkerOptions();
options.markerIcon( R.drawable.red )
.position( new LonLatPoint( matchedPoint[0], matchedPoint[1] ) )
.setGps( false );
mMapView.getMapAutoViewHelper().addMarker( options );
MarkerOptions options2
= new MarkerOptions();
options2.markerIcon( R.drawable.blue )
.position( new LonLatPoint( lon, lat ) )
.setGps( true );
mMapView.getMapAutoViewHelper().addMarker( options2 );
return matchedPoint;
}
return null;

View File

@@ -93,16 +93,16 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
}
final long start = System.currentTimeMillis();
double[] matchedPoint = matchRoad( recognizedListResult.lon,
recognizedListResult.lat,
recognizedListResult.heading,
recognizedListResult.dataAccuracy == 1
);
Log.i("match-road-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
if ( matchedPoint != null ) {
recognizedListResult.lon = matchedPoint[0];
recognizedListResult.lat = matchedPoint[1];
}
// double[] matchedPoint = matchRoad( recognizedListResult.lon,
// recognizedListResult.lat,
// recognizedListResult.heading,
// recognizedListResult.dataAccuracy == 1
// );
// Log.i("match-road-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
// if ( matchedPoint != null ) {
// recognizedListResult.lon = matchedPoint[0];
// recognizedListResult.lat = matchedPoint[1];
// }
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );

View File

@@ -190,11 +190,10 @@ class BaseDrawer {
* @return
*/
protected double[] matchRoad( double lon, double lat, double angle, boolean isRtk ) {
double wgs[] = CoordinateUtils.transformGcj02toWgs84( lat, lon );
return MogoApisHandler.getInstance()
.getApis()
.getMapServiceApi()
.getMapUIController()
.matchRoad( wgs[0], wgs[1], angle, true, isRtk );
.matchRoad( lon, lat, angle, true, isRtk );
}
}

View File

@@ -160,15 +160,15 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
continue;
}
double[] matchedPoint = matchRoad( cloudRoadData.getLon(),
cloudRoadData.getLat(),
cloudRoadData.getHeading(),
true
);
if ( matchedPoint != null ) {
cloudRoadData.setLon( matchedPoint[0] );
cloudRoadData.setLat( matchedPoint[1] );
}
// double[] matchedPoint = matchRoad( cloudRoadData.getLon(),
// cloudRoadData.getLat(),
// cloudRoadData.getHeading(),
// true
// );
// if ( matchedPoint != null ) {
// cloudRoadData.setLon( matchedPoint[0] );
// cloudRoadData.setLat( matchedPoint[1] );
// }
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );

File diff suppressed because one or more lines are too long

View File

@@ -558,7 +558,7 @@ public class MockIntentHandler implements IntentHandler {
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 200L );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 300L );
break;
}
}
@@ -697,7 +697,7 @@ public class MockIntentHandler implements IntentHandler {
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 3, 200L );
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
return true;
}