[Feat]新增高精地图缓存功能

This commit is contained in:
chenfufeng
2023-02-10 19:32:22 +08:00
parent 8d6bee790a
commit 30cf22ab6c
23 changed files with 539 additions and 14 deletions

View File

@@ -26,6 +26,7 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import com.mogo.commons.constants.SharedPrefsConstants;
@@ -46,7 +47,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.hdcache.IHdCacheListener;
import com.mogo.map.listener.MogoMapListenerHandler;
import com.mogo.map.location.GDLocationClient;
import com.mogo.map.navi.MogoCarLocationChangedListenerRegister;
import com.mogo.map.uicontroller.CarCursorOption;
import com.mogo.map.uicontroller.EnumMapUI;
@@ -54,6 +57,7 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.map.uicontroller.MapCameraPosition;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.map.uicontroller.VisualAngleMode;
import com.mogo.map.utils.HDMapUtils;
import com.mogo.map.utils.MogoMapUtils;
import com.mogo.map.utils.ObjectUtils;
import com.mogo.map.utils.ResIdCache;
@@ -70,6 +74,7 @@ import com.zhidaoauto.map.sdk.open.abs.log.ILog;
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.CityInfo;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
@@ -126,6 +131,7 @@ public class AMapViewWrapper implements IMogoMapView,
private boolean mIsDelayed = false;
private final LocationListener mGpsLocationListener = location -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(ObjectUtils.fromLocation(location), 0, true);
private IHdCacheListener hdCacheListener;
public AMapViewWrapper(MapAutoView mMapView) {
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--AMapViewWrapper: init");
@@ -1169,4 +1175,47 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.getMapAutoViewHelper().setAllGesturesEnabled(isEnable);
}
}
@Override
public void cacheHDDataByCity(IHdCacheListener listener) {
if (mMapView.getMapAutoViewHelper() != null) {
String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode();
Integer id = HDMapUtils.getHDCityCode(gdCityCode);
if (id != null) {
hdCacheListener = listener;
mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, (cityId, progress) -> {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
if (hdCacheListener != null) {
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
}
} else {
UiThreadHandler.post(() -> {
if (hdCacheListener != null) {
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
}
});
}
});
}
}
}
@Override
public boolean isCityDataCached() {
if (mMapView.getMapAutoViewHelper() != null) {
String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode();
Integer id = HDMapUtils.getHDCityCode(gdCityCode);
if (id != null) {
List<CityInfo> cityInfoList = mMapView.getMapAutoViewHelper().getAllCityCode();
if (cityInfoList != null) {
for (CityInfo cityInfo : cityInfoList) {
if (id == cityInfo.getCityCode()) {
return cityInfo.isCache;
}
}
}
}
}
return true;
}
}