Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

# Conflicts:
#	gradle.properties
This commit is contained in:
董宏宇
2021-03-04 20:44:18 +08:00
28 changed files with 1274 additions and 514 deletions

View File

@@ -150,11 +150,11 @@ class OCHTaxiFragment extends BaseOchFragment< OCHTaxiView, OCHTaxiPresenter > i
mOrderStatus.setText( R.string.module_och_taxi_waiting );
if ( MogoOCHTaxiModel.getInstance().isUserArriveAtStartStation() ) {
Logger.d( TAG, "乘客已上车" );
if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
slidePanelView.setVisibility( View.VISIBLE );
} else {
slidePanelView.setVisibility( View.GONE );
}
slidePanelView.setVisibility( View.VISIBLE );
// if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() == IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE ) {
// } else {
// slidePanelView.setVisibility( View.GONE );
// }
slidePanelView.setText( getString( R.string.module_och_taxi_arrive_at_start_station ) );
}
} else if ( MogoOCHTaxiModel.getInstance().checkCurrentOCHOrder() ) {

View File

@@ -161,7 +161,7 @@ MOGO_PASSPORT_VERSION=1.0.51
# 常链接
MOGO_SOCKET_VERSION=1.0.51
# 数据采集
MOGO_REALTIME_VERSION=1.0.51
MOGO_REALTIME_VERSION=1.0.52
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.0.51
# 直播推流

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

@@ -15,6 +15,7 @@ import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.TextView;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoMapView;
@@ -23,6 +24,7 @@ import com.mogo.map.impl.custom.location.GpsTester;
import com.mogo.map.impl.custom.navi.NaviClient;
import com.mogo.map.impl.custom.utils.MogoMapUtils;
import com.mogo.map.impl.custom.utils.ObjectUtils;
import com.mogo.map.impl.custom.utils.PointInterpolatorUtil;
import com.mogo.map.listener.MogoMapListenerHandler;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.uicontroller.CarCursorOption;
@@ -44,13 +46,18 @@ import com.zhidaoauto.map.sdk.open.abs.OnMapTouchListener;
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory;
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle;
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.poyline.PolylineOptions;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import com.zhidaoauto.map.sdk.open.tools.MapTools;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
@@ -1014,4 +1021,44 @@ public class AMapViewWrapper implements IMogoMapView,
e.printStackTrace();
}
}
private float lastRoadId;
@Override
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean 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( wgs[0], wgs[1], singlePointRoadInfo.getCoords() );
// return CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
double[] trans = CoordinateUtils.transformWgsToGcj(matchedPoint[1], matchedPoint[0]);
matchedPoint[0] = trans[0];
matchedPoint[1] = trans[1];
// MarkerOptions options
// = 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 );
// if(lastRoadId != singlePointRoadInfo.getRoadId()) {
// lastRoadId = singlePointRoadInfo.getRoadId();
// PolylineOptions lineOptions = new PolylineOptions();
// lineOptions.setGps(true)
// .lonLatPoints(singlePointRoadInfo.getCoords())
// .color(Color.RED)
// .lineWidth(10);
// mMapView.getMapAutoViewHelper().drawLine(lineOptions);
// }
return matchedPoint;
}
return null;
}
}

View File

@@ -93,7 +93,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
@Override
public IMogoMapView getMapView( Context context ) {
NavAutoApi.INSTANCE.init( context, MapParams.Companion.init()
.setDebugMode( false )
.setDebugMode( true )
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
.setZoom( 20 )

View File

@@ -2,7 +2,6 @@ package com.mogo.map.impl.custom.marker;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;
@@ -23,7 +22,6 @@ import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.MarkerScaleAnimation;
import com.zhidaoauto.map.sdk.open.marker.MarkerTranslateAnimation;
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import com.zhidaoauto.map.sdk.open.tools.MapTools;
@@ -481,8 +479,8 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
return;
}
// mMarker.startSmooth( newPoints, ( int ) duration );
mMarker.addDynamicAnchorPostion( newPoints.get( newPoints.size() - 1 ), ( int ) duration );
mMarker.startSmooth( newPoints, ( int ) duration );
// mMarker.addDynamicAnchorPostion( newPoints.get( newPoints.size() - 1 ), ( int ) duration );
}
@Override
@@ -542,4 +540,15 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
e.printStackTrace();
}
}
@Override
public String getMarkerResName() {
if ( mMarker != null ) {
try {
return mMarker.getMarkeOptions().getMarkerIconName();
} catch ( Exception e ) {
}
}
return "";
}
}

View File

@@ -313,4 +313,12 @@ public class AMapUIController implements IMogoMapUIController {
mClient.openVrMode( zoomGestureEnable );
}
}
@Override
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
if ( mClient != null ) {
return mClient.matchRoad( lon, lat, angle, isGpsLocation, isRTK );
}
return null;
}
}

View File

@@ -53,95 +53,100 @@ import java.util.List;
*/
public class ObjectUtils {
public static MarkerOptions fromMogo(MogoMarkerOptions opt) {
public static MarkerOptions fromMogo( MogoMarkerOptions opt ) {
if (opt == null) {
if ( opt == null ) {
return null;
}
ArrayList<BitmapDescriptor> descriptors = new ArrayList<>();
final ArrayList<Bitmap> icons = opt.getIcons();
if (icons != null && !icons.isEmpty()) {
for (Bitmap icon : icons) {
if (icon == null || icon.isRecycled()) {
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
final ArrayList< Bitmap > icons = opt.getIcons();
if ( icons != null && !icons.isEmpty() ) {
for ( Bitmap icon : icons ) {
if ( icon == null || icon.isRecycled() ) {
continue;
}
descriptors.add(new BitmapDescriptor(icon));
descriptors.add( new BitmapDescriptor( icon ) );
}
}
MarkerOptions markerOptions = new MarkerOptions()
.position(new LonLatPoint(opt.getLongitude(), opt.getLatitude()))
.anchor(opt.getU(), opt.getV())
.position( new LonLatPoint( opt.getLongitude(), opt.getLatitude() ) )
.anchor( opt.getU(), opt.getV() )
.icons( descriptors )
.period( opt.getPeriod() )
.controlAngle( opt.isControlAngle() )
.rotateAngle(opt.getRotate())
.setFlat(opt.isFlat())
.visible(opt.isVisible())
.infoWindowEnable(opt.isInifoWindowEnable())
.alpha(opt.getAlpha())
.setGps(opt.isGps())
.rotateAngle( opt.getRotate() )
.setFlat( opt.isFlat() )
.visible( opt.isVisible() )
.infoWindowEnable( opt.isInifoWindowEnable() )
.alpha( opt.getAlpha() )
.setGps( opt.isGps() )
// .draggable( opt.isDraggable() )
.setInfoWindowOffset(opt.getOffsetX(), opt.getOffsetY())
.zIndex(opt.getzIndex());
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt);
if (descriptor != null) {
markerOptions.markerIcon(descriptor);
}
if (opt.getIcon3DRes() != 0) {
markerOptions.marker3DIcon(opt.getIcon3DRes());
try {
Color.parseColor(opt.getAnchorColor());
markerOptions.anchorColor( opt.getAnchorColor() );
} catch ( Exception e ) {
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
.zIndex( opt.getzIndex() );
if ( !TextUtils.isEmpty( opt.getResName() )) {
markerOptions.setMarkerIconName( opt.getResName() );
markerOptions.vrEnable( opt.is3DMode() );
} else {
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
if ( descriptor != null ) {
markerOptions.markerIcon( descriptor );
}
if ( opt.getIcon3DRes() != 0 ) {
markerOptions.marker3DIcon( opt.getIcon3DRes() );
try {
Color.parseColor( opt.getAnchorColor() );
markerOptions.anchorColor( opt.getAnchorColor() );
} catch ( Exception e ) {
}
}
}
if (!TextUtils.isEmpty(opt.getTitle())) {
markerOptions.title(opt.getTitle());
if ( !TextUtils.isEmpty( opt.getTitle() ) ) {
markerOptions.title( opt.getTitle() );
}
if (!TextUtils.isEmpty(opt.getSnippet())) {
markerOptions.snippet(opt.getSnippet());
if ( !TextUtils.isEmpty( opt.getSnippet() ) ) {
markerOptions.snippet( opt.getSnippet() );
}
return markerOptions;
}
private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) {
if (options == null) {
private static BitmapDescriptor getBitmapDescriptorFromMogo( MogoMarkerOptions options ) {
if ( options == null ) {
return null;
}
Bitmap icon = options.getIcon();
if (icon != null) {
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
if ( icon != null ) {
return BitmapDescriptorFactory.INSTANCE.fromBitmap( icon );
}
View view = options.getIconView();
if (view != null) {
return BitmapDescriptorFactory.INSTANCE.fromView(view);
if ( view != null ) {
return BitmapDescriptorFactory.INSTANCE.fromView( view );
}
return null;
}
public static MogoLocation fromLocation(com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation) {
if (aLocation == null) {
public static MogoLocation fromLocation( com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation ) {
if ( aLocation == null ) {
return null;
}
MogoLocation location = new MogoLocation();
// location.setLocType( aLocation.getLocationType() );
location.setSpeed(aLocation.getSpeed());
location.setLatitude(aLocation.getLat());
location.setLongitude(aLocation.getLon());
location.setAltitude(aLocation.getAltitude());
location.setSpeed( aLocation.getSpeed() );
location.setLatitude( aLocation.getLat() );
location.setLongitude( aLocation.getLon() );
location.setAltitude( aLocation.getAltitude() );
// location.setTime( aLocation.getTime() );
location.setBearing(aLocation.getHeading());
location.setBearing( aLocation.getHeading() );
// location.setAccuracy( aLocation.getAccuracy() );
location.setCityCode(aLocation.getCityCode());
location.setCityName(aLocation.getCity());
location.setProvider(aLocation.getProvider());
location.setAddress(aLocation.getAddress());
location.setDistrict(aLocation.getDistrict());
location.setProvince(aLocation.getProvince());
location.setAdCode(aLocation.getAdCode());
location.setCityCode( aLocation.getCityCode() );
location.setCityName( aLocation.getCity() );
location.setProvider( aLocation.getProvider() );
location.setAddress( aLocation.getAddress() );
location.setDistrict( aLocation.getDistrict() );
location.setProvince( aLocation.getProvince() );
location.setAdCode( aLocation.getAdCode() );
// location.setLocationDetail( aLocation.getLocationDetail() );
// location.setPoiName( aLocation.getPoiName() );
// location.setAoiName( aLocation.getAoiName() );
@@ -156,11 +161,11 @@ public class ObjectUtils {
return location;
}
public static LonLatPoint fromMogo(MogoLatLng latLng) {
if (latLng == null) {
public static LonLatPoint fromMogo( MogoLatLng latLng ) {
if ( latLng == null ) {
return null;
}
return new LonLatPoint(latLng.lon, latLng.lat);
return new LonLatPoint( latLng.lon, latLng.lat );
}
// public static NaviLatLng fromMogoAsNavi( MogoLatLng latLng ) {
@@ -177,11 +182,11 @@ public class ObjectUtils {
// return new LatLng( latLng.lat, latLng.lng );
// }
public static MogoLatLng fromAMap(LonLatPoint point) {
if (point == null) {
public static MogoLatLng fromAMap( LonLatPoint point ) {
if ( point == null ) {
return null;
}
return new MogoLatLng(point.getLatitude(), point.getLongitude());
return new MogoLatLng( point.getLatitude(), point.getLongitude() );
}
// public static MogoLatLng CameraPositionfromAMap( LatLng point ) {
@@ -191,19 +196,19 @@ public class ObjectUtils {
// return new MogoLatLng( point.latitude, point.longitude );
// }
public static GeocodeQuery fromMogo(MogoGeocodeQuery query) {
if (query == null) {
public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
if ( query == null ) {
return null;
}
GeocodeQuery q = new GeocodeQuery(query.getLocationName(), query.getCity());
GeocodeQuery q = new GeocodeQuery( query.getLocationName(), query.getCity() );
return q;
}
public static RegeocodeQuery fromMogo(MogoRegeocodeQuery query) {
if (query == null) {
public static RegeocodeQuery fromMogo( MogoRegeocodeQuery query ) {
if ( query == null ) {
return null;
}
RegeocodeQuery q = new RegeocodeQuery(fromMogo(query.getPoint()), 1000);
RegeocodeQuery q = new RegeocodeQuery( fromMogo( query.getPoint() ), 1000 );
return q;
}
@@ -245,39 +250,39 @@ public class ObjectUtils {
// return mogoCrossroad;
// }
public static MogoGeocodeAddress fromAMap(GeocodeAddress address) {
if (address == null) {
public static MogoGeocodeAddress fromAMap( GeocodeAddress address ) {
if ( address == null ) {
return null;
}
MogoGeocodeAddress mogoGeocodeAddress = new MogoGeocodeAddress();
mogoGeocodeAddress.setAdcode(address.getAdcode());
mogoGeocodeAddress.setBuilding(address.getBuilding());
mogoGeocodeAddress.setCity(address.getCity());
mogoGeocodeAddress.setDistrict(address.getDistrict());
mogoGeocodeAddress.setFormatAddress(address.getFormatAddress());
mogoGeocodeAddress.setLatlng(fromAMap(address.getLonlat()));
mogoGeocodeAddress.setLevel(address.getLevel());
mogoGeocodeAddress.setNeighborhood(address.getNeighborhood());
mogoGeocodeAddress.setProvince(address.getProvince());
mogoGeocodeAddress.setTownship(address.getTownship());
mogoGeocodeAddress.setAdcode( address.getAdcode() );
mogoGeocodeAddress.setBuilding( address.getBuilding() );
mogoGeocodeAddress.setCity( address.getCity() );
mogoGeocodeAddress.setDistrict( address.getDistrict() );
mogoGeocodeAddress.setFormatAddress( address.getFormatAddress() );
mogoGeocodeAddress.setLatlng( fromAMap( address.getLonlat() ) );
mogoGeocodeAddress.setLevel( address.getLevel() );
mogoGeocodeAddress.setNeighborhood( address.getNeighborhood() );
mogoGeocodeAddress.setProvince( address.getProvince() );
mogoGeocodeAddress.setTownship( address.getTownship() );
return mogoGeocodeAddress;
}
public static MogoGeocodeResult fromAMap(GeocodeResult result) {
if (result == null || result.getGeocodeAddressList() == null) {
public static MogoGeocodeResult fromAMap( GeocodeResult result ) {
if ( result == null || result.getGeocodeAddressList() == null ) {
return null;
}
MogoGeocodeResult mogoGeocodeResult = new MogoGeocodeResult();
final List<MogoGeocodeAddress> addresses = new ArrayList<>();
List<GeocodeAddress> list = result.getGeocodeAddressList();
for (GeocodeAddress geocodeAddress : list) {
final MogoGeocodeAddress mogoGeocodeAddress = fromAMap(geocodeAddress);
if (mogoGeocodeAddress != null) {
addresses.add(mogoGeocodeAddress);
final List< MogoGeocodeAddress > addresses = new ArrayList<>();
List< GeocodeAddress > list = result.getGeocodeAddressList();
for ( GeocodeAddress geocodeAddress : list ) {
final MogoGeocodeAddress mogoGeocodeAddress = fromAMap( geocodeAddress );
if ( mogoGeocodeAddress != null ) {
addresses.add( mogoGeocodeAddress );
}
}
mogoGeocodeResult.setAddresses(addresses);
mogoGeocodeResult.setAddresses( addresses );
return mogoGeocodeResult;
}
@@ -353,23 +358,23 @@ public class ObjectUtils {
// return mogoSubPoiItem;
// }
public static MogoPoiItem fromAMap(PoiItem poiItem) {
if (poiItem == null) {
public static MogoPoiItem fromAMap( PoiItem poiItem ) {
if ( poiItem == null ) {
return null;
}
MogoPoiItem mogoPoiItem = new MogoPoiItem();
mogoPoiItem.setAdCode(poiItem.getAdCode());
mogoPoiItem.setAdName(poiItem.getAdName());
mogoPoiItem.setBusinessArea(poiItem.getBusinessArea());
mogoPoiItem.setCityCode(poiItem.getCityCode());
mogoPoiItem.setCityName(poiItem.getCityName());
mogoPoiItem.setDirection(poiItem.getDirection());
mogoPoiItem.setDistance(poiItem.getDistance());
mogoPoiItem.setEmail(poiItem.getEmail());
mogoPoiItem.setEnter(fromAMap(poiItem.getEnter()));
mogoPoiItem.setExit(fromAMap(poiItem.getExit()));
mogoPoiItem.setAdCode( poiItem.getAdCode() );
mogoPoiItem.setAdName( poiItem.getAdName() );
mogoPoiItem.setBusinessArea( poiItem.getBusinessArea() );
mogoPoiItem.setCityCode( poiItem.getCityCode() );
mogoPoiItem.setCityName( poiItem.getCityName() );
mogoPoiItem.setDirection( poiItem.getDirection() );
mogoPoiItem.setDistance( poiItem.getDistance() );
mogoPoiItem.setEmail( poiItem.getEmail() );
mogoPoiItem.setEnter( fromAMap( poiItem.getEnter() ) );
mogoPoiItem.setExit( fromAMap( poiItem.getExit() ) );
// mogoPoiItem.setIndoorData( fromAMap( poiItem.getIndoorData() ) );
mogoPoiItem.setParkingType(poiItem.getParkingType());
mogoPoiItem.setParkingType( poiItem.getParkingType() );
// mogoPoiItem.setIndoorMap( poiItem.isIndoorMap() );
// if ( poiItem.getPhotos() != null ) {
// List< MogoPhoto > mogoPhotos = new ArrayList<>();
@@ -382,13 +387,13 @@ public class ObjectUtils {
// mogoPoiItem.setPhotos( mogoPhotos );
// }
// mogoPoiItem.setPoiExtension( fromAMap( poiItem.getPoiExtension() ) );
mogoPoiItem.setPoiId(poiItem.getPoiId());
mogoPoiItem.setPoint(fromAMap(poiItem.getLonLatPoint()));
mogoPoiItem.setPostcode(poiItem.getPostcode());
mogoPoiItem.setProvinceCode(poiItem.getProvinceCode());
mogoPoiItem.setProvinceName(poiItem.getProvinceName());
mogoPoiItem.setShopID(poiItem.getShopID());
mogoPoiItem.setSnippet(poiItem.getSnippet());
mogoPoiItem.setPoiId( poiItem.getPoiId() );
mogoPoiItem.setPoint( fromAMap( poiItem.getLonLatPoint() ) );
mogoPoiItem.setPostcode( poiItem.getPostcode() );
mogoPoiItem.setProvinceCode( poiItem.getProvinceCode() );
mogoPoiItem.setProvinceName( poiItem.getProvinceName() );
mogoPoiItem.setShopID( poiItem.getShopID() );
mogoPoiItem.setSnippet( poiItem.getSnippet() );
// if ( poiItem.getSubPois() != null ) {
// List< MogoSubPoiItem > mogoSubPoiItems = new ArrayList<>();
// for ( SubPoiItem subPois : poiItem.getSubPois() ) {
@@ -399,20 +404,20 @@ public class ObjectUtils {
// }
// mogoPoiItem.setSubPois( mogoSubPoiItems );
// }
mogoPoiItem.setTel(poiItem.getTel());
mogoPoiItem.setTypeCode(poiItem.getTypeCode());
mogoPoiItem.setTitle(poiItem.getTitle());
mogoPoiItem.setTypeDes(poiItem.getTypeDes());
mogoPoiItem.setWebsite(poiItem.getWebsite());
mogoPoiItem.setTel( poiItem.getTel() );
mogoPoiItem.setTypeCode( poiItem.getTypeCode() );
mogoPoiItem.setTitle( poiItem.getTitle() );
mogoPoiItem.setTypeDes( poiItem.getTypeDes() );
mogoPoiItem.setWebsite( poiItem.getWebsite() );
return mogoPoiItem;
}
public static MogoRegeocodeAddress fromAMap(RegeocodeAddress regeocodeAddress) {
if (regeocodeAddress == null) {
public static MogoRegeocodeAddress fromAMap( RegeocodeAddress regeocodeAddress ) {
if ( regeocodeAddress == null ) {
return null;
}
MogoRegeocodeAddress mogoRegeocodeAddress = new MogoRegeocodeAddress();
mogoRegeocodeAddress.setAdCode(regeocodeAddress.getAdCode());
mogoRegeocodeAddress.setAdCode( regeocodeAddress.getAdCode() );
// if ( regeocodeAddress.getAois() != null ) {
// List< MogoAoiItem > items = new ArrayList<>();
// for ( AoiItem aois : regeocodeAddress.getAois() ) {
@@ -424,7 +429,7 @@ public class ObjectUtils {
// mogoRegeocodeAddress.setAois( items );
// }
mogoRegeocodeAddress.setBuilding(regeocodeAddress.getBuilding());
mogoRegeocodeAddress.setBuilding( regeocodeAddress.getBuilding() );
// if ( regeocodeAddress.getBusinessAreas() != null ) {
// List< MogoBusinessArea > mogoBusinessAreas = new ArrayList<>();
// for ( BusinessArea businessArea : regeocodeAddress.getBusinessAreas() ) {
@@ -436,9 +441,9 @@ public class ObjectUtils {
// mogoRegeocodeAddress.setBusinessAreas( mogoBusinessAreas );
// }
mogoRegeocodeAddress.setCity(regeocodeAddress.getCity());
mogoRegeocodeAddress.setCityCode(regeocodeAddress.getCityCode());
mogoRegeocodeAddress.setCountry(regeocodeAddress.getCountry());
mogoRegeocodeAddress.setCity( regeocodeAddress.getCity() );
mogoRegeocodeAddress.setCityCode( regeocodeAddress.getCityCode() );
mogoRegeocodeAddress.setCountry( regeocodeAddress.getCountry() );
// if ( regeocodeAddress.getCrossroads() != null ) {
// List< MogoCrossroad > mogoCrossroads = new ArrayList<>();
// for ( Crossroad crossroad : regeocodeAddress.getCrossroads() ) {
@@ -450,19 +455,19 @@ public class ObjectUtils {
// }
// mogoRegeocodeAddress.setCrossroads( mogoCrossroads );
// }
mogoRegeocodeAddress.setDistrict(regeocodeAddress.getDistrict());
mogoRegeocodeAddress.setFormatAddress(regeocodeAddress.getFormatAddress());
mogoRegeocodeAddress.setNeighborhood(regeocodeAddress.getNeighborhood());
if (regeocodeAddress.getPoiList() != null) {
List<MogoPoiItem> mogoPoiItems = new ArrayList<>();
List<PoiItem> list = regeocodeAddress.getPoiList();
for (PoiItem pois : list) {
MogoPoiItem mogoPoiItem = fromAMap(pois);
mogoPoiItems.add(mogoPoiItem);
mogoRegeocodeAddress.setDistrict( regeocodeAddress.getDistrict() );
mogoRegeocodeAddress.setFormatAddress( regeocodeAddress.getFormatAddress() );
mogoRegeocodeAddress.setNeighborhood( regeocodeAddress.getNeighborhood() );
if ( regeocodeAddress.getPoiList() != null ) {
List< MogoPoiItem > mogoPoiItems = new ArrayList<>();
List< PoiItem > list = regeocodeAddress.getPoiList();
for ( PoiItem pois : list ) {
MogoPoiItem mogoPoiItem = fromAMap( pois );
mogoPoiItems.add( mogoPoiItem );
}
mogoRegeocodeAddress.setPois(mogoPoiItems);
mogoRegeocodeAddress.setPois( mogoPoiItems );
}
mogoRegeocodeAddress.setProvince(regeocodeAddress.getProvince());
mogoRegeocodeAddress.setProvince( regeocodeAddress.getProvince() );
// if ( regeocodeAddress.getRoads() != null ) {
// List< MogoRegeocodeRoad > mogoRegeocodeRoads = new ArrayList<>();
// for ( RegeocodeRoad road : regeocodeAddress.getRoads() ) {
@@ -474,43 +479,43 @@ public class ObjectUtils {
// mogoRegeocodeAddress.setRoads( mogoRegeocodeRoads );
// }
// mogoRegeocodeAddress.setStreetNumber( fromAMap( regeocodeAddress.getStreetNumber() ) );
mogoRegeocodeAddress.setTowncode(regeocodeAddress.getTowncode());
mogoRegeocodeAddress.setTownship(regeocodeAddress.getTownship());
mogoRegeocodeAddress.setTowncode( regeocodeAddress.getTowncode() );
mogoRegeocodeAddress.setTownship( regeocodeAddress.getTownship() );
return mogoRegeocodeAddress;
}
public static MogoRegeocodeResult fromAMap(RegeocodeResult regeocodeResult) {
if (regeocodeResult == null) {
public static MogoRegeocodeResult fromAMap( RegeocodeResult regeocodeResult ) {
if ( regeocodeResult == null ) {
return null;
}
MogoRegeocodeResult mogoRegeocodeResult = new MogoRegeocodeResult();
mogoRegeocodeResult.setRegeocodeAddress(fromAMap(regeocodeResult.getRegeocodeAddress()));
mogoRegeocodeResult.setRegeocodeAddress( fromAMap( regeocodeResult.getRegeocodeAddress() ) );
return mogoRegeocodeResult;
}
public static InputtipsQuery fromMogo(MogoInputtipsQuery query) {
if (query == null) {
public static InputtipsQuery fromMogo( MogoInputtipsQuery query ) {
if ( query == null ) {
return null;
}
InputtipsQuery inputtipsQuery = new InputtipsQuery(query.getKeyword(), query.getCity());
inputtipsQuery.setCityLimit(query.isCityLimit());
inputtipsQuery.setLocation(fromMogo(query.getLocation()));
inputtipsQuery.setType(query.getType());
InputtipsQuery inputtipsQuery = new InputtipsQuery( query.getKeyword(), query.getCity() );
inputtipsQuery.setCityLimit( query.isCityLimit() );
inputtipsQuery.setLocation( fromMogo( query.getLocation() ) );
inputtipsQuery.setType( query.getType() );
return inputtipsQuery;
}
public static MogoTip fromAMap(Tip tip) {
if (tip == null) {
public static MogoTip fromAMap( Tip tip ) {
if ( tip == null ) {
return null;
}
MogoTip mogoTip = new MogoTip();
mogoTip.setAdCode(tip.getAdcode());
mogoTip.setAddress(tip.getAddress());
mogoTip.setDistrict(tip.getDistrict());
mogoTip.setName(tip.getName());
mogoTip.setPoiID(tip.getPoiID());
mogoTip.setPoint(fromAMap(tip.getLatPoint()));
mogoTip.setTypeCode(tip.getTypeCode());
mogoTip.setAdCode( tip.getAdcode() );
mogoTip.setAddress( tip.getAddress() );
mogoTip.setDistrict( tip.getDistrict() );
mogoTip.setName( tip.getName() );
mogoTip.setPoiID( tip.getPoiID() );
mogoTip.setPoint( fromAMap( tip.getLatPoint() ) );
mogoTip.setTypeCode( tip.getTypeCode() );
return mogoTip;
}
@@ -525,100 +530,100 @@ public class ObjectUtils {
// return mogoPoi;
// }
public static MogoPoiSearchQuery fromAMap(Query query) {
if (query == null) {
public static MogoPoiSearchQuery fromAMap( Query query ) {
if ( query == null ) {
return null;
}
MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery(query.getKeyword(), query.getCategory(), query.getCity());
MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery( query.getKeyword(), query.getCategory(), query.getCity() );
// mogoPoiSearchQuery.setBuilding( query.getBuilding() );
mogoPoiSearchQuery.setCityLimit(query.getCityLimit());
mogoPoiSearchQuery.setDistanceSort(query.getDistanceSort());
mogoPoiSearchQuery.setLocation(fromAMap(query.getLocation()));
mogoPoiSearchQuery.setPageNum(query.getPageNum());
mogoPoiSearchQuery.setPageSize(query.getPageSize());
mogoPoiSearchQuery.setCityLimit( query.getCityLimit() );
mogoPoiSearchQuery.setDistanceSort( query.getDistanceSort() );
mogoPoiSearchQuery.setLocation( fromAMap( query.getLocation() ) );
mogoPoiSearchQuery.setPageNum( query.getPageNum() );
mogoPoiSearchQuery.setPageSize( query.getPageSize() );
return mogoPoiSearchQuery;
}
public static Query fromMogo(MogoPoiSearchQuery query) {
if (query == null || query.getQuery() == null) {
public static Query fromMogo( MogoPoiSearchQuery query ) {
if ( query == null || query.getQuery() == null ) {
return null;
}
Query psq = new Query(query.getQuery(), "", "");
String category = getCategory(query.getQuery());
if (!category.equals(""))
psq = new Query("", "", getCategory(query.getQuery()));
Query psq = new Query( query.getQuery(), "", "" );
String category = getCategory( query.getQuery() );
if ( !category.equals( "" ) )
psq = new Query( "", "", getCategory( query.getQuery() ) );
// psq.setBuilding( query.getBuilding() );
psq.setCityLimit(query.isCityLimit());
psq.setDistanceSort(query.isDistanceSort());
psq.setLocation(fromMogo(query.getLocation()));
psq.setPageNum(query.getPageNum());
psq.setPageSize(query.getPageSize());
psq.setCityLimit( query.isCityLimit() );
psq.setDistanceSort( query.isDistanceSort() );
psq.setLocation( fromMogo( query.getLocation() ) );
psq.setPageNum( query.getPageNum() );
psq.setPageSize( query.getPageSize() );
return psq;
}
public static MogoSearchBound fromAMap(SearchBound bound) {
if (bound == null) {
public static MogoSearchBound fromAMap( SearchBound bound ) {
if ( bound == null ) {
return null;
}
if (bound.getShape() == SearchBound.BOUND_SHAPE) {
return new MogoSearchBound(fromAMap(bound.getCenter()), bound.getRange(), bound.isDistanceSort());
} else if (bound.getShape() == SearchBound.POLYGON_SHAPE) {
return new MogoSearchBound(fromAMap(bound.getPolyGonList()));
} else if (bound.getShape() == SearchBound.RECTANGLE_SHAPE) {
return new MogoSearchBound(fromAMap(bound.getLowerLeft()), fromAMap(bound.getUpperRight()));
if ( bound.getShape() == SearchBound.BOUND_SHAPE ) {
return new MogoSearchBound( fromAMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
} else if ( bound.getShape() == SearchBound.POLYGON_SHAPE ) {
return new MogoSearchBound( fromAMap( bound.getPolyGonList() ) );
} else if ( bound.getShape() == SearchBound.RECTANGLE_SHAPE ) {
return new MogoSearchBound( fromAMap( bound.getLowerLeft() ), fromAMap( bound.getUpperRight() ) );
}
return null;
}
public static List<MogoLatLng> fromAMap(List<LonLatPoint> latLngs) {
if (latLngs == null) {
public static List< MogoLatLng > fromAMap( List< LonLatPoint > latLngs ) {
if ( latLngs == null ) {
return null;
}
List<MogoLatLng> result = new ArrayList<>(latLngs.size());
for (LonLatPoint latLng : latLngs) {
result.add(fromAMap(latLng));
List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
for ( LonLatPoint latLng : latLngs ) {
result.add( fromAMap( latLng ) );
}
return result;
}
public static List<LonLatPoint> fromMogo(List<MogoLatLng> latLngs) {
if (latLngs == null) {
public static List< LonLatPoint > fromMogo( List< MogoLatLng > latLngs ) {
if ( latLngs == null ) {
return null;
}
List<LonLatPoint> result = new ArrayList<>(latLngs.size());
for (MogoLatLng latLng : latLngs) {
result.add(fromMogo(latLng));
List< LonLatPoint > result = new ArrayList<>( latLngs.size() );
for ( MogoLatLng latLng : latLngs ) {
result.add( fromMogo( latLng ) );
}
return result;
}
public static SearchBound fromMogo(MogoSearchBound bound) {
if (bound == null) {
public static SearchBound fromMogo( MogoSearchBound bound ) {
if ( bound == null ) {
return null;
}
if (bound.getShape() == MogoSearchBound.SHAPE_BOUND) {
return new SearchBound(fromMogo(bound.getCenterPoint()), bound.getRadiusInMeters(), bound.isDistanceSort());
} else if (bound.getShape() == MogoSearchBound.SHAPE_POLYGON) {
return new SearchBound(fromMogo(bound.getPolyGonList()));
} else if (bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE) {
return new SearchBound(fromMogo(bound.getLowerLeft()), fromMogo(bound.getUpperRight()));
if ( bound.getShape() == MogoSearchBound.SHAPE_BOUND ) {
return new SearchBound( fromMogo( bound.getCenterPoint() ), bound.getRadiusInMeters(), bound.isDistanceSort() );
} else if ( bound.getShape() == MogoSearchBound.SHAPE_POLYGON ) {
return new SearchBound( fromMogo( bound.getPolyGonList() ) );
} else if ( bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE ) {
return new SearchBound( fromMogo( bound.getLowerLeft() ), fromMogo( bound.getUpperRight() ) );
}
return null;
}
public static MogoPoiResult fromAMap(PoiSearchResult result) {
if (result == null) {
public static MogoPoiResult fromAMap( PoiSearchResult result ) {
if ( result == null ) {
return null;
}
MogoPoiResult mogoPoiResult = new MogoPoiResult();
if (result.getItems() != null) {
final List<PoiSearchItem> poiItems = result.getItems();
final ArrayList<MogoPoiItem> mogoPoiItems = new ArrayList<>(poiItems.size());
for (PoiSearchItem poiItem : poiItems) {
mogoPoiItems.add(fromAMap(poiItem.getPoi()));
if ( result.getItems() != null ) {
final List< PoiSearchItem > poiItems = result.getItems();
final ArrayList< MogoPoiItem > mogoPoiItems = new ArrayList<>( poiItems.size() );
for ( PoiSearchItem poiItem : poiItems ) {
mogoPoiItems.add( fromAMap( poiItem.getPoi() ) );
}
mogoPoiResult.setPois(mogoPoiItems);
mogoPoiResult.setPois( mogoPoiItems );
}
return mogoPoiResult;
}
@@ -697,27 +702,27 @@ public class ObjectUtils {
// return null;
// }
public static PolylineOptions fromMogo(MogoPolylineOptions options) {
if (options == null) {
public static PolylineOptions fromMogo( MogoPolylineOptions options ) {
if ( options == null ) {
return null;
}
PolylineOptions target = new PolylineOptions();
if (options.getPoints() != null) {
List<LonLatPoint> points = new ArrayList<>();
for (MogoLatLng point : options.getPoints()) {
points.add(fromMogo(point));
if ( options.getPoints() != null ) {
List< LonLatPoint > points = new ArrayList<>();
for ( MogoLatLng point : options.getPoints() ) {
points.add( fromMogo( point ) );
}
target.lonLatPoints(points);
target.lonLatPoints( points );
}
target.setLineWidth(options.getWidth());
target.setColor(options.getColor());
target.setLineWidth( options.getWidth() );
target.setColor( options.getColor() );
// target.zIndex( options.getWidth() );
// target.visible( options.isVisible() );
//// target.geodesic( options.isGeodesic() );
// target.setDottedLine( options.isDottedLine() );
target.useGradient(options.isGradient());
if (options.getColorValues() != null) {
target.colorValues(options.getColorValues());
target.useGradient( options.isGradient() );
if ( options.getColorValues() != null ) {
target.colorValues( options.getColorValues() );
}
// target.transparency( options.getTransparency() );
// target.aboveMaskLayer( options.isAboveMaskLayer() );
@@ -734,24 +739,24 @@ public class ObjectUtils {
// return new MogoLatLng( latLng.latitude, latLng.longitude );
// }
public static MapCameraPosition fromAMap(CameraPosition position) {
if (position == null) {
public static MapCameraPosition fromAMap( CameraPosition position ) {
if ( position == null ) {
return null;
}
return new MapCameraPosition(fromAMap(position.getTarget()), position.getBearing(), position.getTilt(), position.getZoom());
return new MapCameraPosition( fromAMap( position.getTarget() ), position.getBearing(), position.getTilt(), position.getZoom() );
}
private static String getCategory(String key) {
private static String getCategory( String key ) {
String category = "";
if (key.equals("加油站")) {
if ( key.equals( "加油站" ) ) {
category = "6";
} else if (key.equals("停车场")) {
} else if ( key.equals( "停车场" ) ) {
category = "12";
} else if (key.equals("餐馆")) {
} else if ( key.equals( "餐馆" ) ) {
category = "22";
} else if (key.equals("洗车")) {
} else if ( key.equals( "洗车" ) ) {
category = "8";
} else if (key.equals("厕所")) {
} else if ( key.equals( "厕所" ) ) {
}
return category;

View File

@@ -0,0 +1,104 @@
package com.mogo.map.impl.custom.utils;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.map.MogoLatLng;
import com.mogo.utils.logger.Logger;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import java.util.List;
/**
* 点之间插值工具类
*
* @author tongchenfei
*/
public class PointInterpolatorUtil {
private static final String TAG = "PointInterpolatorUtil";
private static final int DISTANCE_THRESHOLD = 2;
/**
* 在(x1,y1) (x2,y2)中间插入一些点,使每两个点之间距离<={@link #DISTANCE_THRESHOLD},利用如下公式进行计算
* xn = x1 + (x2 - x1)*n/a
* yn = y1 + (y2 - y1)*n/a
* a = (distance/{@link #DISTANCE_THRESHOLD}) +1
* n in 1 .. a-1
* n == 0 时xn = x1
* n == a 时xn = x2
* <p>
* 将xn依次插入x1到x2之间
*
* @param points 待插值点集
* @deprecated 这个方法有问题,并不能算出来想要的值
*/
@Deprecated
public static void interpolate(List<MogoLatLng> points) {
if (points.size() >= 2) {
// 插值
for (int i = 0; i < points.size() - 1; i++) {
MogoLatLng current = points.get(i);
MogoLatLng next = points.get(i + 1);
float distance = CoordinateUtils.calculateLineDistance(current.lon, current.lat, next.lon, next.lat);
Logger.d(TAG, i + ": " + distance);
if (distance > DISTANCE_THRESHOLD) {
int inter = (int) (distance / DISTANCE_THRESHOLD) + 1;
for (int j = 1; j < inter; j++) {
double newLat = current.lat + (next.lat - current.lat) * j / inter;
double newLon = current.lon + (next.lon - current.lon) * j / inter;
Logger.d(TAG, "distance: " + distance + ", j: " + j + ", nextLat: " + next.lat + ", nextLon: " + next.lon + ", newLat: " + newLat + ", newLon: " + newLon);
points.add(i + 1, new MogoLatLng(newLat, newLon));
current = points.get(++i);
}
}
}
}
}
public static double[] mergeToRoad(double lon, double lat, List<LonLatPoint> road) {
closeStart = 0;
closeEnd = road.size() - 1;
getCloseTwoPoint(lon, lat, road);
LonLatPoint start = road.get(closeStart);
LonLatPoint end = road.get(closeEnd);
Logger.d(TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd);
// return getMid(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};
}
private static int closeStart = 0;
private static int closeEnd = 0;
private static void getCloseTwoPoint(double lon, double lat, List<LonLatPoint> road) {
if (closeEnd - closeStart == 1) {
return;
}
LonLatPoint start = road.get(closeStart);
LonLatPoint end = road.get(closeEnd);
float startDistance = CoordinateUtils.calculateLineDistance(start.getLongitude(), start.getLatitude(), lon, lat);
float endDistance = CoordinateUtils.calculateLineDistance(end.getLongitude(), end.getLatitude(), lon, lat);
if (startDistance > endDistance) {
closeStart += (closeEnd - closeStart) / 2;
} else {
closeEnd -= (closeEnd - closeStart) / 2;
}
getCloseTwoPoint(lon, lat, road);
}
private static double[] getFoot(double lon, double lat, LonLatPoint beginPt, LonLatPoint endPt) {
double dx = beginPt.getLatitude() - endPt.getLatitude();
double dy = beginPt.getLongitude() - endPt.getLongitude();
double u = (lat - beginPt.getLatitude()) * (beginPt.getLatitude() - endPt.getLatitude()) +
(lon - beginPt.getLongitude()) * (beginPt.getLongitude() - endPt.getLongitude());
u = u / (dx * dx + dy * dy);
return new double[]{beginPt.getLongitude() + u * dy, beginPt.getLatitude() + u * dx};
}
private static double[] getMid(LonLatPoint start, LonLatPoint end) {
return new double[]{(start.getLongitude() + end.getLongitude()) / 2, (start.getLatitude() + end.getLatitude()) / 2};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

View File

@@ -364,11 +364,20 @@ public interface IMogoMarker {
}
default void setInfoWindowOffset(int offsetX, int offsetY){
default void setInfoWindowOffset( int offsetX, int offsetY ) {
}
default void addDynamicAnchorPosition(MogoLatLng latLng, long duration){
default void addDynamicAnchorPosition( MogoLatLng latLng, long duration ) {
}
/**
* 获取 marker 内部使用资源内容 md5
*
* @return
*/
default String getMarkerResName() {
return "";
}
}

View File

@@ -81,6 +81,20 @@ public class MogoMarkerOptions extends Observable {
private boolean mIsControlAngle = false;
/**
* 资源名称便于缓存重复使用和mIcon3DRes、mIconView、icon等冲突需要县设置
*/
private String mResName;
public MogoMarkerOptions resName( String resName ) {
this.mResName = resName;
return this;
}
public String getResName() {
return mResName;
}
public MogoMarkerOptions controlAngle( boolean controlAngle ) {
this.mIsControlAngle = controlAngle;
return this;

View File

@@ -274,4 +274,18 @@ public interface IMogoMapUIController {
default void openVrMode( boolean zoomGestureEnable ) {
}
/**
* 将一个点匹配到车道的中心点
*
* @param lon
* @param lat
* @param angle
* @param isGpsLocation 是否是 gps 坐标
* @param isRTK
* @return
*/
default double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
return null;
}
}

View File

@@ -353,4 +353,13 @@ public class MogoMapUIController implements IMogoMapUIController {
mDelegate.openVrMode( zoomGestureEnable );
}
}
@Override
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
initDelegate();
if ( mDelegate != null ) {
return mDelegate.matchRoad( lon, lat, angle, isGpsLocation, isRTK );
}
return null;
}
}

View File

@@ -1,6 +1,7 @@
package com.zhidao.roadcondition.service
import android.content.Intent
import android.os.Environment
import android.util.Log
import com.google.gson.Gson
import com.mogo.commons.AbsMogoApplication
@@ -11,10 +12,8 @@ import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO
import com.zhidao.roadcondition.util.CarNet_Cos_Upload
import com.zhidao.roadcondition.util.LocationUtil
import com.zhidao.roadcondition.util.deletePicFile
import com.zhidao.roadcondition.util.trackNormalEvent
import com.zhidao.roadcondition.util.*
import java.io.File
/**
* @description cos上传操作
@@ -44,6 +43,10 @@ class CosStatusController : CosStatusCallback {
private var mLongitude: Double = 0.0
private var mLatitude: Double = 0.0
private var mSpeed: Float = 0f
val moviesDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MOVIES + File.separator
)
//上传文件
fun uploadFile(picPath: MutableList<String?>?, entity: TakeEntity, type: String, mainInfoId: Long,
@@ -103,6 +106,7 @@ class CosStatusController : CosStatusCallback {
CosCallbackMapController.unregisterCallback(localPath)
InformationUploadController.release(entity.id)
// deletePicFile(localPath)
deleteCompressVideoFile(moviesDir.toString())
}
}
@@ -154,7 +158,8 @@ class CosStatusController : CosStatusCallback {
}
Log.d(TAG, "delete file: $localPath")
CosCallbackMapController.unregisterCallback(localPath)
deletePicFile(localPath)
// deletePicFile(localPath)
deleteCompressVideoFile(moviesDir.toString())
}
private fun sendInformation(type: Int, map: Map<String, String>) {

View File

@@ -107,6 +107,17 @@ fun bitmapToFile(bitmap: Bitmap?, filePath: String): Boolean {
return true
}
fun deleteCompressVideoFile(path: String?) {
val file = File(path)
val files = file.listFiles()
for (f in files) {
// /storage/emulated/0/Movies/compress_video_20210202121826.mp4
if (f.toString().contains("compress_video")) {
f.delete()
}
}
}
//获取压缩后的视频路径
fun getCompressVideoPath(): String {

View File

@@ -1,4 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
@@ -36,6 +38,10 @@ dependencies {
api rootProject.ext.dependencies.mogoaicloudrealtime
implementation rootProject.ext.dependencies.coroutinesandroid
implementation rootProject.ext.dependencies.coroutinescore
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
api "com.mogo.libs:hook:1.0"
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogomap

View File

@@ -2,18 +2,19 @@ package com.mogo.module.common.drawer;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.kt.ScopeManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -27,6 +28,8 @@ public
*/
class AdasRecognizedResultDrawer extends BaseDrawer {
private static final String TAG = "AdasRecognizedResultDrawer";
private static volatile AdasRecognizedResultDrawer sInstance;
private final Context mContext;
@@ -69,19 +72,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
* 渲染 adas 识别的数据
*
* @param resultList
* @param machineVision
* @param curSpeed
*/
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList,
boolean machineVision,
double curSpeed ) {
public void renderAdasRecognizedResult( List< ADASRecognizedResult > resultList ) {
if ( resultList == null || resultList.isEmpty() ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi()
.getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_ADAS );
mAdasRecognizedMarkersCaches.clear();
mLastPositions.clear();
clearOldMarker();
return;
}
@@ -90,85 +84,121 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
if ( recognizedListResult == null ) {
continue;
}
// 暂时只显示车辆
if ( !isCarType( recognizedListResult.type ) ) {
continue;
}
String uniqueKey = recognizedListResult.uuid;
if ( TextUtils.isEmpty( uniqueKey ) ) {
continue;
}
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
if ( marker == null || marker.isDestroyed() ) {
marker = drawAdasRecognizedDataMarker( recognizedListResult, machineVision, curSpeed );
if ( marker == null ) {
continue;
}
}
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
if ( lastPosition != null && !DebugConfig.isNotSmooth() ) {
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) );
points.add( endLatLon );
long interval = recognizedListResult.systemTime - lastPosition.systemTime;
if ( interval < 45 ) {
interval = 45;
}
interval -= 25;
marker.startSmoothInMs( points, interval );
} else {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
}
showSelfSpeed( mContext,
marker,
recognizedListResult.speed,
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
);
ScopeManager.INSTANCE.adasScope( () -> {
renderAdasOneFrame( recognizedListResult, newAdasRecognizedMarkersCaches );
} );
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
mAdasRecognizedMarkersCaches = newAdasRecognizedMarkersCaches;
ScopeManager.INSTANCE.adasScope( () -> {
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
mAdasRecognizedMarkersCaches = newAdasRecognizedMarkersCaches;
} );
}
private void renderAdasOneFrame( ADASRecognizedResult recognizedListResult, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
// 暂时只显示车辆
if ( !isCarType( recognizedListResult.type ) ) {
return;
}
String uniqueKey = recognizedListResult.uuid;
if ( TextUtils.isEmpty( uniqueKey ) ) {
return;
}
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];
}
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
if ( marker == null || marker.isDestroyed() ) {
marker = drawAdasRecognizedDataMarker( recognizedListResult );
if ( marker == null ) {
return;
}
}
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
if ( lastPosition != null ) {
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
marker.addDynamicAnchorPosition( endLatLon, interval );
Logger.d( TAG, "anim duration: %s", interval );
} else {
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
}
showSelfSpeed( mContext,
marker,
recognizedListResult.speed,
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
);
}
/**
* 绘制 marker
*
* @param recognizedListResult
* @param machineVision
* @param curSpeed
* @return
*/
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult,
boolean machineVision,
double curSpeed ) {
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedResult recognizedListResult ) {
if ( recognizedListResult == null ) {
return null;
}
String resIdVal = null;
int resId = getVrModelResId();
resIdVal = resId + "";
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.anchor( 0.5f, 0.5f )
.set3DMode( true )
.controlAngle( true )
.icon3DRes( getVrModel() )
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
.icon3DRes( resId )
.rotate( ( float ) recognizedListResult.heading )
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
cacheMarkerIconResMd5Val( resIdVal, marker );
return marker;
}
private int getVrModel() {
/**
* 获取 vr 模型资源 id
*
* @return
*/
private int getVrModelResId() {
return R.raw.cargrey;
}
/**
* vr 模式切换
*/
public void notifyVrModeChanged() {
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
mLastPositions.clear();
clearOldMarker();
}
/**
* 清除旧的 marker 数据
*/
private void clearOldMarker() {
if ( mAdasRecognizedMarkersCaches != null ) {
mAdasRecognizedMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS );
}
}

View File

@@ -5,18 +5,20 @@ import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mogo.map.CoordinatesTransformer;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.constants.CarModelType;
import com.mogo.module.common.constants.SafeType;
import com.mogo.utils.WorkThreadHandler;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public
@@ -28,20 +30,15 @@ public
*/
class BaseDrawer {
public static final int POS_LON = 1;
public static final int POS_LAT = 0;
public static final double BOUND_DISTANCE_DANGEROUS = 0.5;
public static final double BOUND_SPEED_DANGEROUS = 1.5;
public static final double BOUND_DISTANCE_WARM = 1;
public static final double BOUND_SPEED_WARM = 1.1;
// 移除过期的 marker
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
public static final int MSG_REMOVE_SNAPSHOT_MARKERS = 9991;
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
/**
* 地图内部资源md5缓存便于资源复用
*/
protected static final Map< String, String > mMarkerCachesResMd5Values = new HashMap<>();
public BaseDrawer() {
if ( mWorkThreadHandler == null ) {
initWorkThreadHandler();
@@ -64,6 +61,11 @@ class BaseDrawer {
if ( msg.what == MSG_REMOVE_DIRTY_MARKERS ) {
if ( msg.obj instanceof Map ) {
removeDirtyMarkers( ( ( Map ) msg.obj ) );
} else if ( msg.obj instanceof String ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi()
.getMarkerManager( AbsMogoApplication.getApp() )
.removeMarkers( ( ( String ) msg.obj ) );
}
}
}
@@ -76,7 +78,7 @@ class BaseDrawer {
* @param msg
* @param data
*/
protected void sendMessage( int msg, Object data ) {
public void sendMessage( int msg, Object data ) {
if ( mWorkThreadHandler == null ) {
initWorkThreadHandler();
}
@@ -87,67 +89,12 @@ class BaseDrawer {
}
/**
* 安全类型
* 判断是否是车辆
*
* @param distance
* @param speed
* @param curSpeed
* @param type
* @return
*/
protected SafeType getSafeType( double distance, double speed, double curSpeed ) {
if ( distance < BOUND_DISTANCE_DANGEROUS ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
return SafeType.SpeedDangerous;
}
if ( distance < BOUND_DISTANCE_WARM ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
return SafeType.DistanceWarm;
}
return SafeType.Normal;
}
protected SafeType getSafeType( double distanceX, double distanceY, double speed, double curSpeed ) {
if ( distanceX < BOUND_DISTANCE_DANGEROUS || distanceY < BOUND_DISTANCE_DANGEROUS ) {
return SafeType.DistanceDangerous;
}
if ( speed > curSpeed * BOUND_SPEED_DANGEROUS ) {
return SafeType.SpeedDangerous;
}
if ( distanceX < BOUND_DISTANCE_WARM || distanceY < BOUND_DISTANCE_WARM ) {
return SafeType.DistanceWarm;
}
if ( speed > curSpeed * BOUND_SPEED_WARM ) {
return SafeType.SpeedWarm;
}
return SafeType.Normal;
}
/**
* 车模
*
* @return
*/
protected CarModelType getCarModelType() {
// 根据车道、行驶方向等计算出选用哪个车模图片
return CarModelType.Other;
}
private CoordinatesTransformer mTransformer;
protected double[] transformGcj02ToFitMap( double lat, double lon ) {
if ( mTransformer == null ) {
mTransformer = MogoApisHandler.getInstance().getApis().getMapServiceApi().getCoordinatesTransformer();
}
return mTransformer.transform( lat, lon );
}
protected boolean isCarType( int type ) {
public boolean isCarType( int type ) {
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
if ( recognizedType == AdasRecognizedType.classIdCar
|| recognizedType == AdasRecognizedType.classIdTrafficBus
@@ -160,7 +107,15 @@ class BaseDrawer {
private TextView mSpeedView = null;
protected void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
/**
* 展示车辆速度
*
* @param context
* @param mogoMarker
* @param speed
* @param isVrMode
*/
public void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
return;
}
@@ -207,4 +162,57 @@ class BaseDrawer {
}
dirtyMarkers.clear();
}
/**
* 缓存绘制 marker 的 id 和 marker 资源缓存的 md5 的关系
*
* @param id
* @param marker
*/
protected static void cacheMarkerIconResMd5Val( String id, IMogoMarker marker ) {
if ( marker == null || marker.isDestroyed() ) {
return;
}
String md5 = marker.getMarkerResName();
if ( TextUtils.isEmpty( md5 ) || TextUtils.isEmpty( id ) ) {
return;
}
mMarkerCachesResMd5Values.put( id, md5 );
}
/**
* 道路匹配到车道中心点
*
* @param lon
* @param lat
* @param angle
* @param isRtk
* @return
*/
public double[] matchRoad( double lon, double lat, double angle, boolean isRtk ) {
return MogoApisHandler.getInstance()
.getApis()
.getMapServiceApi()
.getMapUIController()
.matchRoad( lon, lat, angle, true, isRtk );
}
/**
* 使用系统时间或卫星时间计算出动画的运动时间
*
* @param lastSystemTime
* @param curSystemTime
* @param lastSatelliteTime
* @param curSatelliteTime
* @return
*/
public long computeAnimDuration( long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime ) {
long systemTimeInterval = curSystemTime - lastSystemTime;
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
if ( interval < 45 ) {
interval = 45;
}
return interval;
}
}

View File

@@ -2,12 +2,12 @@ package com.mogo.module.common.drawer;
import android.content.Context;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
@@ -16,29 +16,29 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.module.common.kt.ScopeManager;
import com.mogo.module.common.utils.SimpleHandlerThreadPool;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.ICarsChattingProvider;
import com.zhidao.carchattingprovider.MogoDriverInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public
/*
* @author congtaowang
* @since 2020/10/28
*
* 云端数据绘制
*/
class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListener, IMogoStatusChangedListener {
/**
* @author congtaowang
* @since 2020/10/28
* <p>
* 云端数据绘制
*/
public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListener, IMogoStatusChangedListener {
private static final String TAG = "SnapshotSetDataDrawer";
@@ -80,6 +80,8 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
private final Map< String, CloudRoadData > mLastPositions = new ConcurrentHashMap<>();
private final Map< String, Long > mLastPositionExecutionTime = new HashMap<>();
private boolean mIsVrMode = false;
@Override
@@ -103,35 +105,40 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
private boolean clear( MogoSnapshotSetData data ) {
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched() ) {
if ( mCloudSnapshotMarkersCaches == null ) {
return true;
return false;
}
MogoApisHandler.getInstance().getApis()
.getMapServiceApi().getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
mCloudSnapshotMarkersCaches.clear();
mLastPositions.clear();
if ( mCloudSnapshotMarkersCaches != null ) {
mCloudSnapshotMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
return true;
}
if ( data == null || (
( data.getAllList() == null || data.getAllList().isEmpty() ) &&
( data.getNearList() == null || data.getNearList().isEmpty() ) ) ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi().getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
mCloudSnapshotMarkersCaches.clear();
mLastPositions.clear();
if ( mCloudSnapshotMarkersCaches != null ) {
mCloudSnapshotMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
return true;
}
return false;
}
Map<String,String> cloudKeyCache = new ArrayMap<>();
/**
* mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆
*
* @param data 自车周边数据
*/
public void renderSnapshotData( MogoSnapshotSetData data,
boolean machineVision ) {
public void renderSnapshotData( MogoSnapshotSetData data ) {
if ( clear( data ) ) {
return;
@@ -139,81 +146,84 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
List< CloudRoadData > allDatumsList = new ArrayList<>();
prepareData( data.getAllList(), allDatumsList );
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
Map< String, String > newMarkersCaches = new ArrayMap<>(allDatumsList.size());
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
for ( CloudRoadData cloudRoadData : allDatumsList ) {
if ( cloudRoadData == null ) {
continue;
}
// 暂时只显示车辆
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
if ( !isCarType( cloudRoadData.getType() ) ) {
continue;
}
}
String uniqueKey = cloudRoadData.getUniqueKey();
if ( TextUtils.isEmpty( uniqueKey )
// 本地过滤重复下发的adas识别车辆
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
continue;
}
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
if ( marker == null || marker.isDestroyed() ) {
marker = drawSnapshotDataMarker( cloudRoadData, machineVision, data.curSpeed );
if ( marker == null ) {
continue;
}
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
bindClickListener( marker );
}
}
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
if ( mChangeCarModeStatus ) {
mChangeCarModeStatus = false;
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
if ( mIsVrMode ) {
Logger.d( TAG, "3D模型-%s", uniqueKey );
marker.getMogoMarkerOptions().set3DMode( true );
marker.use3DResource( getVrModel( cloudRoadData ) );
} else {
Logger.d( TAG, "2D贴图-%s", uniqueKey );
marker.getMogoMarkerOptions().set3DMode( false );
marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) );
}
}
if ( ( lastPosition != null || lastPosition.equals( cloudRoadData ) ) && !DebugConfig.isNotSmooth() ) {
List< MogoLatLng > points = new ArrayList<>();
points.add( new MogoLatLng( lastPosition.getLat(), lastPosition.getLon() ) );
if ( cloudRoadData.getCoordinates() != null && !cloudRoadData.getCoordinates().isEmpty() ) {
for ( CloudLocationInfo coordinate : cloudRoadData.getCoordinates() ) {
points.add( new MogoLatLng( coordinate.getLat(), coordinate.getLon() ) );
}
} else {
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
}
long interval = cloudRoadData.getSystemTime() - lastPosition.getSystemTime();
long interval2 = cloudRoadData.getSatelliteTime() - lastPosition.getSatelliteTime();
interval2 = interval < interval2 || interval2 == 0 ? interval : interval2;
if ( interval2 < 45 ) {
interval2 = 45;
}
interval2 -= 25;
marker.startSmoothInMs( points, interval2 );
Logger.d( TAG, "平滑移动 - %s duration = %s", uniqueKey, interval2 );
} else {
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
}
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), mIsVrMode );
cloudKeyCache.remove(cloudRoadData.getUniqueKey());
newMarkersCaches.put(cloudRoadData.getUniqueKey(), cloudRoadData.getUniqueKey());
SimpleHandlerThreadPool.getInstance().post(cloudRoadData);
// ScopeManager.INSTANCE.mainScope( () -> {
// rendCarOneFrame( cloudRoadData, newAdasRecognizedMarkersCaches );
// } );
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
SimpleHandlerThreadPool.getInstance().removeDirtyMarker(cloudKeyCache.values());
cloudKeyCache = newMarkersCaches;
// ScopeManager.INSTANCE.mainScope( () -> {
// sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
// mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
// } );
}
public void rendCarOneFrame( CloudRoadData cloudRoadData, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
if ( cloudRoadData == null ) {
return;
}
// 暂时只显示车辆
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
if ( !isCarType( cloudRoadData.getType() ) ) {
return;
}
}
String uniqueKey = cloudRoadData.getUniqueKey();
if ( TextUtils.isEmpty( uniqueKey )
// 本地过滤重复下发的adas识别车辆
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
return;
}
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
if ( marker == null || marker.isDestroyed() ) {
marker = drawSnapshotDataMarker( cloudRoadData );
if ( marker == null ) {
return;
}
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
bindClickListener( marker );
}
}
if(newAdasRecognizedMarkersCaches != null) {
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
}
//
// if ( mChangeCarModeStatus ) {
// mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
// mChangeCarModeStatus = false;
// if ( mIsVrMode ) {
// marker.getMogoMarkerOptions().set3DMode( true );
// marker.use3DResource( getVrModelResId( cloudRoadData ) );
// } else {
// marker.getMogoMarkerOptions().set3DMode( false );
// marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData ) ) );
// }
// }
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
long interval = computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
interval = System.currentTimeMillis() - mLastPositionExecutionTime.get( uniqueKey );
marker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ), interval );
Logger.d( TAG, "anim duration: %s", interval );
} else {
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
Logger.d( TAG, "设置点位置" );
}
mLastPositionExecutionTime.put( uniqueKey, System.currentTimeMillis() );
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
}
@@ -254,7 +264,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
/**
* 绑定点击事件
*/
private void bindClickListener( IMogoMarker marker ) {
public void bindClickListener( IMogoMarker marker ) {
if ( marker == null || marker.isDestroyed() ) {
return;
}
@@ -265,16 +275,13 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
* 绘制 marker
*
* @param data
* @param machineVision
* @param curSpeed
* @return
*/
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data, boolean machineVision, double curSpeed ) {
public IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) {
if ( data == null ) {
return null;
}
Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() );
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
.anchor( 0.5f, 0.5f )
@@ -282,17 +289,23 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
.object( data )
.controlAngle( true )
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
String resIdVal = null;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
options.anchorColor( "#00FF00" );
Logger.d( TAG, "3D模型 - %s", data.getUniqueKey() );
options.icon3DRes( getVrModel( data ) );
int resId = getVrModelResId( data );
resIdVal = resId + "";
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
options.icon3DRes( resId );
} else {
options.set3DMode( false );
Logger.d( TAG, "2D贴图 - %s", data.getUniqueKey() );
options.icon( inflateView( data, machineVision, curSpeed ) );
View view = inflateView( data );
options.icon( view );
resIdVal = view.getId() + "";
}
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
cacheMarkerIconResMd5Val( resIdVal, marker );
return marker;
}
/**
@@ -301,7 +314,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
* @param data
* @return
*/
private int getVrModel( CloudRoadData data ) {
private int getVrModelResId( CloudRoadData data ) {
switch ( data.getFromType() ) {
case CloudRoadData.FROM_ADAS:
return R.raw.cargrey;
@@ -313,20 +326,18 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
}
}
private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) {
/**
* 生成 2d marker 资源
*
* @param data
* @return
*/
private View inflateView( CloudRoadData data ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
// SafeType safeType = getSafeType( data.getDistance(), data.getSpeed(), curSpeed );
// TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
// // 机器视觉展示速度,用户视觉展示安全类型
// tv.setText( machineVision ? String.valueOf( data.getSpeed() ) : safeType.getMsg() );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
// iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
// machineVision ? VisionMode.Machine : VisionMode.User,
// AdasRecognizedType.valueFrom( data.getType() ),
// getCarModelType(),
// safeType
// ) );
iv.setImageResource( get2DModel( data ) );
int viewIdLike = get2DModel( data );
iv.setImageResource( viewIdLike );
rootView.setId( viewIdLike );
return rootView;
}
@@ -339,9 +350,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
private int get2DModel( CloudRoadData data ) {
switch ( data.getFromType() ) {
case CloudRoadData.FROM_ADAS:
// return R.drawable.icon_map_marker_car_type_taxi;
case CloudRoadData.FROM_ROAD_UNIT:
// return R.drawable.icon_map_marker_car_type_bus;
case CloudRoadData.FROM_MY_LOCATION:
default:
return R.drawable.icon_map_marker_car_gray;

View File

@@ -0,0 +1,35 @@
package com.mogo.module.common.kt
import androidx.annotation.RestrictTo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
/**
* @author congtaowang
* @since 2021/3/3
*
* 描述
*/
object ScopeManager {
private var mScope = MainScope()
private var mAdasScope = MainScope()
private var mThreadScope: RestrictTo.Scope? = null
fun mainScope(runnable: Runnable?) {
mScope.launch(Dispatchers.Default) {
runnable?.apply {
run()
}
}
}
fun adasScope(runnable: Runnable?) {
mAdasScope.launch(Dispatchers.Default) {
runnable?.apply {
run()
}
}
}
}

View File

@@ -0,0 +1,206 @@
package com.mogo.module.common.utils;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.utils.logger.Logger;
import java.util.Collection;
import java.util.Map;
import static com.mogo.module.common.drawer.BaseDrawer.MSG_REMOVE_DIRTY_MARKERS;
/**
* 简单HandlerThread线程池实现
*
* @author tongchenfei
*/
public class SimpleHandlerThreadPool {
private static final String TAG = "SimpleHandlerThreadPool";
private HandlerThread renderThread = new HandlerThread("one-frame-render-thread");
private Handler renderHandler;
private SimpleHandlerThreadPool() {
renderThread.start();
renderHandler = new Handler(renderThread.getLooper());
}
private static final SimpleHandlerThreadPool INSTANCE = new SimpleHandlerThreadPool();
public static SimpleHandlerThreadPool getInstance() {
return INSTANCE;
}
/**
* 默认线程数量
*/
private static final int DEFAULT_THREAD_COUNT = 3;
private int threadCount = DEFAULT_THREAD_COUNT;
public void setThreadCount(int threadCount) {
this.threadCount = threadCount;
}
Map<String, WorkHandler> dataHandlerMap = new ArrayMap<>();
Map<Integer, WorkHandler> handlerPool = new ArrayMap<>();
private int lastUseThreadId = -1;
public void post(CloudRoadData cloudRoadData) {
String uuid = cloudRoadData.getUniqueKey();
Message msg;
if (dataHandlerMap.containsKey(uuid)) {
msg = dataHandlerMap.get(uuid).obtainMessage();
} else {
if (handlerPool.size() < threadCount) {
// 新开线程
lastUseThreadId = handlerPool.size();
HandlerThread thread = new HandlerThread("one-frame-work-thread-" + handlerPool.size());
thread.start();
WorkHandler handler = new WorkHandler(thread.getLooper());
handlerPool.put(handlerPool.size(), handler);
dataHandlerMap.put(uuid, handler);
msg = handler.obtainMessage();
} else {
// 复用线程
if (lastUseThreadId == threadCount - 1) {
lastUseThreadId = 0;
} else {
lastUseThreadId++;
}
WorkHandler handler = handlerPool.get(lastUseThreadId);
dataHandlerMap.put(uuid, handler);
msg = handler.obtainMessage();
}
}
msg.obj = cloudRoadData;
msg.sendToTarget();
}
public void removeDirtyMarker(Collection<String> keys) {
for (WorkHandler handler : handlerPool.values()) {
handler.removeDirtyMarker(keys);
}
}
class WorkHandler extends Handler {
public WorkHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
CloudRoadData cloudRoadData = (CloudRoadData) msg.obj;
rendCarOneFrame(cloudRoadData);
}
private final Map<String, IMogoMarker> markerCache = new ArrayMap<>();
private final Map<String, CloudRoadData> roadDataCache = new ArrayMap<>();
private final Map<String, Long> lastExecutionTimeCache = new ArrayMap<>();
private final Map<String, Boolean> isMatchStatusCache = new ArrayMap<>();
private void rendCarOneFrame(CloudRoadData cloudRoadData) {
if (cloudRoadData == null) {
return;
}
// 暂时只显示车辆
if (TextUtils.isEmpty(cloudRoadData.getSn())) {
if (!SnapshotSetDataDrawer.getInstance().isCarType(cloudRoadData.getType())) {
return;
}
}
String uniqueKey = cloudRoadData.getUniqueKey();
if (TextUtils.isEmpty(uniqueKey)
// 本地过滤重复下发的adas识别车辆
|| AdasRecognizedResultDrawer.getInstance().hasCached(uniqueKey)) {
return;
}
IMogoMarker marker = markerCache.get(uniqueKey);
CloudRoadData lastPosition = roadDataCache.put(uniqueKey, cloudRoadData);
if (marker == null || marker.isDestroyed()) {
marker = SnapshotSetDataDrawer.getInstance().drawSnapshotDataMarker(cloudRoadData);
if (marker == null) {
return;
}
markerCache.put(uniqueKey, marker);
if (!TextUtils.isEmpty(cloudRoadData.getSn())) {
SnapshotSetDataDrawer.getInstance().bindClickListener(marker);
}
}
// if (cloudRoadData.getFromType() != CloudRoadData.FROM_MY_LOCATION) {
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad(cloudRoadData.getLon(),
cloudRoadData.getLat(),
cloudRoadData.getHeading(),
true
);
Boolean isMathch = isMatchStatusCache.get(uniqueKey);
if (matchedPoint != null) {
if ((isMathch == null || !isMathch)) {
if (matchedPoint[2] < 0.5) {
isMathch = true;
}
} else {
if (matchedPoint[2] > 1) {
isMathch = false;
}
}
if (isMathch == null) {
isMathch = false;
}
isMatchStatusCache.put(uniqueKey, isMathch);
if (isMathch) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
}
}
// }
final IMogoMarker finalMarker = marker;
Logger.d(TAG, "work in " + Thread.currentThread().getName());
renderHandler.post(() -> {
// 由于地图现在不支持addDynamicAnchorPosition并发所以工作线程仅做相关计算真正绘制发送到另外一条绘制线程中做
if (lastPosition != null && !lastPosition.equals(cloudRoadData)) {
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get(uniqueKey);
finalMarker.addDynamicAnchorPosition(new MogoLatLng(cloudRoadData.getLat(), cloudRoadData.getLon()), interval);
Logger.d(TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName());
} else {
finalMarker.setRotateAngle((float) cloudRoadData.getHeading());
finalMarker.setPosition(cloudRoadData.getLat(), cloudRoadData.getLon());
Logger.d(TAG, "设置点位置 in thread: %s", Thread.currentThread().getName());
}
lastExecutionTimeCache.put(uniqueKey, SystemClock.uptimeMillis());
SnapshotSetDataDrawer.getInstance().showSelfSpeed(AbsMogoApplication.getApp(), finalMarker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
});
}
public void removeDirtyMarker(Collection<String> keys) {
Map<String, IMogoMarker> result = new ArrayMap<>(keys.size());
for (String key : keys) {
if (markerCache.containsKey(key)) {
result.put(key, markerCache.remove(key));
}
}
SnapshotSetDataDrawer.getInstance().sendMessage(MSG_REMOVE_DIRTY_MARKERS, result);
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,10 @@ import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -26,8 +29,13 @@ import com.mogo.map.search.geo.MogoRegeocodeResult;
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.ADASCarStateInfo;
import com.mogo.service.entrance.ButtonIndex;
@@ -40,9 +48,11 @@ import com.mogo.utils.storage.SharedPrefsMgr;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -541,6 +551,16 @@ public class MockIntentHandler implements IntentHandler {
.getMapUIController()
.openVrMode( false );
break;
case 46:
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 200L );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 300L );
break;
}
}
@@ -564,4 +584,182 @@ public class MockIntentHandler implements IntentHandler {
}
}
private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 1 ) {
try {
if ( !handleMockLocationIntent() ) {
br.close();
br = null;
}
} catch ( Exception e ) {
try {
br.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br = null;
}
} else if ( msg.what == 2 ) {
try {
handleMockSnapshotIntent();
} catch ( Exception e ) {
try {
br2.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br2 = null;
}
} else if( msg.what == 21 ) {
try {
handleMockSnapshotIntent2();
} catch (Exception e) {
try {
br4.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
};
private Handler mLocationMockHandler2 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread2" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 2 ) {
try {
handleMockSnapshotIntent();
} catch ( Exception e ) {
try {
br2.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br2 = null;
}
} else if ( msg.what == 3 ) {
try {
handleMockAdasIntent();
} catch ( Exception e ) {
try {
br3.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br3 = null;
}
}
}
};
private BufferedReader br;
private boolean handleMockLocationIntent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) );
}
final long start = System.currentTimeMillis();
String line = br.readLine();
if ( line == null ) {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
return true;
}
private BufferedReader br2;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
throw new Exception( "end of file 2." );
}
MogoSnapshotSetData data = new MogoSnapshotSetData();
List< CloudRoadData > allList = new ArrayList<>();
CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class );
if ( cloudRoadData == null ) {
return false;
}
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
cloudRoadData.setLon( coor[0] );
cloudRoadData.setLat( coor[1] );
allList.add( cloudRoadData );
data.setAllList( allList );
final long start = System.currentTimeMillis();
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
return true;
}
private BufferedReader br4;
private boolean handleMockSnapshotIntent2() throws Exception {
if ( br4 == null ) {
br4 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
}
String line = br4.readLine();
if ( line == null ) {
throw new Exception( "end of file 2." );
}
MogoSnapshotSetData data = new MogoSnapshotSetData();
List< CloudRoadData > allList = new ArrayList<>();
CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class );
if ( cloudRoadData == null ) {
return false;
}
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
cloudRoadData.setUuid("1_21");
cloudRoadData.setLon( coor[0] );
cloudRoadData.setLat( coor[1] );
allList.add( cloudRoadData );
data.setAllList( allList );
final long start = System.currentTimeMillis();
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 21, 100L );
return true;
}
private BufferedReader br3;
private boolean handleMockAdasIntent() throws Exception {
if ( br3 == null ) {
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas.txt" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
}
List< ADASRecognizedResult > allList = new ArrayList<>();
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return false;
}
double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
adasRecognizedResult.lon = coor[0];
adasRecognizedResult.lat = coor[1];
allList.add( adasRecognizedResult );
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler2.sendEmptyMessageDelayed( 3, 100L );
return true;
}
}

View File

@@ -134,7 +134,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
});
}
// 每隔一秒下发的数据
// 下发的数据
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
@Override
public void onMsgSend(long id) {
@@ -143,17 +143,13 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
@Override
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData, false);
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
}
});
// adas 每隔一秒传递的数据
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback(resultList -> {
double speed = 0.0;
if (MogoServices.getInstance().getLastCarLocation() != null) {
speed = MogoServices.getInstance().getLastCarLocation().getSpeed();
}
// 绘制近景识别到的车辆,每秒绘制一次
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList, false, speed);
// 绘制近景识别到的车辆
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(resultList);
});
}
@@ -252,6 +248,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
}
/**
* 根据点击 marker 更新用户信息面板内容
* @param marker
*/
private void updateCarUserInfoWindow(IMogoMarker marker) {
if (marker != null && !marker.isDestroyed()) {
try {
@@ -299,6 +299,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
}
/**
* 获取特殊车辆类型
* @param marker
* @return
*/
private int getCarVehicleType(IMogoMarker marker) {
try {
return ((MarkerOnlineCar)
@@ -475,6 +480,10 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
});
}
/**
* 同步绘制大而全的数据 marker
* @param response
*/
public void onSyncMarkerResponse(MarkerResponse response) {
if (ignoreDrawRequest()) {
return;
@@ -484,10 +493,19 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
});
}
/**
* 当前地图中心点坐标
* @param lon
* @param lat
*/
public void syncLocation(double lon, double lat) {
mCarLatLng = new MogoLatLng(lat, lon);
}
/**
* 根据经纬度请求数据
* @param latlng
*/
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
UiThreadHandler.removeCallbacks(runnable);
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
@@ -516,6 +534,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
};
/**
* 移除绘制
*/
public void stopAutoRefresh() {
UiThreadHandler.removeCallbacks(runnable);
}
@@ -622,11 +643,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
return ignoreDrawRequest();
}
/**
* 移除在线车辆 marker
*/
private void removeCarMarkers() {
MarkerServiceHandler.getMarkerManager().removeMarkers(ModuleNames.CARD_TYPE_USER_DATA);
}
/**
* 以下条件,不绘制 marker
* @return
*/
private boolean ignoreDrawRequest() {
return MarkerServiceHandler.getMogoStatusManager().isSearchUIShow()
|| MarkerServiceHandler.getMogoStatusManager().isV2XShow()
@@ -668,14 +695,14 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
switch (mapUI) {
case Type_Light:
case Type_Night:
// if ( !AppUtils.isAppForeground( mContext ) ) {
// return;
// }
redrawMarkerByStyleChanged();
break;
}
}
/**
* 重绘内容
*/
public void redrawMarkerByStyleChanged() {
if (mLastDataResult != null) {
runOnTargetThread(() -> {
@@ -686,6 +713,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
}
}
/**
* 关闭当前点击过的 marker
*/
public void onCloseCurrentSelectedMarker() {
if (mLastCheckMarker != null && !mLastCheckMarker.isDestroyed()) {
closeMarker(mLastCheckMarker);