@@ -1,317 +0,0 @@
package com.mogo.module.common.map ;
import com.mogo.commons.debug.DebugConfig ;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger ;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler ;
import com.mogo.map.uicontroller.IMogoMapUIController ;
import com.mogo.module.common.MogoApisHandler ;
import java.util.HashMap ;
import java.util.Map ;
/**
* @author congtaowang
* @since 2020-04-10
* <p>
* 地图中心点策略
*/
public class MapCenterPointStrategy {
private static final String TAG = " MapCenterPointStrategy " ;
private static Map < Integer , Map < String , MapCenterPoint > > sCommonStrategies = new HashMap < > ( ) ;
private static Map < Integer , Map < String , MapCenterPoint > > sVrStrategies = new HashMap < > ( ) ;
public static final MapCenterPoint DEFAULT = new MapCenterPoint ( 0 . 677734D , 0 . 5733333D ) ;
public static void init ( ) {
{
// 选点场景,定位中心点
Map < String , MapCenterPoint > choosePoint = new HashMap < > ( ) ;
final MapCenterPoint point = new MapCenterPoint ( 0 . 5D , 0 . 5D ) ;
choosePoint . put ( " d80x " , point ) ;
choosePoint . put ( " em4 " , point ) ;
choosePoint . put ( " em3 " , point ) ;
choosePoint . put ( " e8xx " , point ) ;
choosePoint . put ( " f80x " , point ) ;
choosePoint . put ( " f8xx " , point ) ;
choosePoint . put ( " f8Amap " , point ) ;
sCommonStrategies . put ( Scene . CHOOSE_POINT , choosePoint ) ;
}
{
// 导航场景,定位视图右下角偏下
Map < String , MapCenterPoint > navi = new HashMap < > ( ) ;
final MapCenterPoint em4 = new MapCenterPoint ( 0 . 734375D , 0 . 573333333333D ) ;
navi . put ( " em4 " , em4 ) ;
navi . put ( " em3 " , em4 ) ;
navi . put ( " e8xx " , em4 ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 705208333D , 0 . 575D ) ;
navi . put ( " f80x " , f80x ) ;
navi . put ( " f8xx " , f80x ) ;
navi . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . NAVI , navi ) ;
}
{
// 导航场景 vs 道路事件展示场景,定位视图右下角偏下
Map < String , MapCenterPoint > naviWithRoadEvent = new HashMap < > ( ) ;
final MapCenterPoint em4 = new MapCenterPoint ( 0 . 734375D , 0 . 73936170212766D ) ;
naviWithRoadEvent . put ( " em4 " , em4 ) ;
naviWithRoadEvent . put ( " em3 " , em4 ) ;
naviWithRoadEvent . put ( " e8xx " , em4 ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 705208333D , 0 . 683333333333D ) ;
naviWithRoadEvent . put ( " f80x " , f80x ) ;
naviWithRoadEvent . put ( " f8xx " , f80x ) ;
naviWithRoadEvent . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . NAVI_WITH_ROAD_EVENT , naviWithRoadEvent ) ;
}
{
// 巡航场景
Map < String , MapCenterPoint > aimless = new HashMap < > ( ) ;
final MapCenterPoint em4 = new MapCenterPoint ( 0 . 734375D , 0 . 5D ) ;
aimless . put ( " em4 " , em4 ) ;
aimless . put ( " em3 " , em4 ) ;
aimless . put ( " e8xx " , em4 ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 705208333D , 0 . 5D ) ;
aimless . put ( " f80x " , f80x ) ;
aimless . put ( " f8xx " , f80x ) ;
aimless . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . AIMLESS , aimless ) ;
}
{
// 巡航场景 vs 道路事件展示场景
Map < String , MapCenterPoint > aimlessWithRoadEvent = new HashMap < > ( ) ;
final MapCenterPoint em4 = new MapCenterPoint ( 0 . 734375D , 0 . 68617 ) ;
aimlessWithRoadEvent . put ( " em4 " , em4 ) ;
aimlessWithRoadEvent . put ( " em3 " , em4 ) ;
aimlessWithRoadEvent . put ( " e8xx " , em4 ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 705208333D , 0 . 599074074D ) ;
aimlessWithRoadEvent . put ( " f80x " , f80x ) ;
aimlessWithRoadEvent . put ( " f8xx " , f80x ) ;
aimlessWithRoadEvent . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . AIMLESS_WITH_ROAD_EVENT , aimlessWithRoadEvent ) ;
}
{
// 规划路线,定位视图右边
Map < String , MapCenterPoint > calculatePath = new HashMap < > ( ) ;
final MapCenterPoint d80x = new MapCenterPoint ( 0 . 733398D , 0 . 610833D ) ;
calculatePath . put ( " d80x " , d80x ) ;
calculatePath . put ( " em4 " , d80x ) ;
calculatePath . put ( " em3 " , d80x ) ;
calculatePath . put ( " e8xx " , d80x ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 703125D , 0 . 6083333D ) ;
calculatePath . put ( " f80x " , f80x ) ;
calculatePath . put ( " f8xx " , f80x ) ;
calculatePath . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . CALCULATE_PATH , calculatePath ) ;
}
{
// 分类搜索,定位视图右边
Map < String , MapCenterPoint > categorySearch = new HashMap < > ( ) ;
final MapCenterPoint d80x = new MapCenterPoint ( 0 . 733398D , 0 . 5D ) ;
categorySearch . put ( " d80x " , d80x ) ;
categorySearch . put ( " em4 " , d80x ) ;
categorySearch . put ( " em3 " , d80x ) ;
categorySearch . put ( " e8xx " , d80x ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 733594D , 0 . 5D ) ;
categorySearch . put ( " f80x " , f80x ) ;
categorySearch . put ( " f8xx " , f80x ) ;
categorySearch . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . CATEGORY_SEARCH , categorySearch ) ;
}
{
// V2X, 场景视图右边
Map < String , MapCenterPoint > categoryV2XEvent = new HashMap < > ( ) ;
categoryV2XEvent . put ( " d80x " , new MapCenterPoint ( 0 . 669444444444444 , 0 . 7D ) ) ;
final MapCenterPoint em4 = new MapCenterPoint ( 0 . 677734375D , 0 . 7D ) ;
categoryV2XEvent . put ( " em4 " , em4 ) ;
categoryV2XEvent . put ( " em3 " , em4 ) ;
categoryV2XEvent . put ( " e8xx " , em4 ) ;
final MapCenterPoint f80x = new MapCenterPoint ( 0 . 6963541D , 0 . 65D ) ;
categoryV2XEvent . put ( " f80x " , f80x ) ;
categoryV2XEvent . put ( " f8xx " , f80x ) ;
categoryV2XEvent . put ( " f8Amap " , f80x ) ;
sCommonStrategies . put ( Scene . CATEGORY_V2X_EVENT , categoryV2XEvent ) ;
}
// --vr mode
{
// 选点场景,定位中心点
Map < String , MapCenterPoint > choosePoint = new HashMap < > ( ) ;
MapCenterPoint point = new MapCenterPoint ( 0 . 5D , 0 . 5D ) ;
choosePoint . put ( " d80x " , point ) ;
choosePoint . put ( " em4 " , point ) ;
choosePoint . put ( " e8xx " , point ) ;
choosePoint . put ( " f80x " , point ) ;
choosePoint . put ( " f8xx " , point ) ;
choosePoint . put ( " f8Amap " , point ) ;
sVrStrategies . put ( Scene . CHOOSE_POINT , choosePoint ) ;
}
{
// 导航场景,定位视图右下角偏下
Map < String , MapCenterPoint > navi = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5D , 0 . 573333333333D ) ;
navi . put ( " d80x " , point1 ) ;
navi . put ( " em4 " , point1 ) ;
navi . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5D , 0 . 575D ) ;
navi . put ( " f80x " , point2 ) ;
navi . put ( " f8xx " , point2 ) ;
navi . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . NAVI , navi ) ;
}
{
// 导航场景 vs 道路事件展示场景,定位视图右下角偏下
Map < String , MapCenterPoint > naviWithRoadEvent = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5D , 0 . 73936170212766D ) ;
naviWithRoadEvent . put ( " d80x " , point1 ) ;
naviWithRoadEvent . put ( " em4 " , point1 ) ;
naviWithRoadEvent . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5D , 0 . 683333333333D ) ;
naviWithRoadEvent . put ( " f80x " , point2 ) ;
naviWithRoadEvent . put ( " f8xx " , point2 ) ;
naviWithRoadEvent . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . NAVI_WITH_ROAD_EVENT , naviWithRoadEvent ) ;
}
{
// 巡航场景
Map < String , MapCenterPoint > aimless = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5D , 0 . 575D ) ;
aimless . put ( " d80x " , point1 ) ;
aimless . put ( " em4 " , point1 ) ;
aimless . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5D , 0 . 8D ) ;
aimless . put ( " f80x " , point2 ) ;
aimless . put ( " f8xx " , point2 ) ;
aimless . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . AIMLESS , aimless ) ;
}
{
// 巡航场景 vs 道路事件展示场景
Map < String , MapCenterPoint > aimlessWithRoadEvent = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5D , 0 . 68617 ) ;
aimlessWithRoadEvent . put ( " d80x " , point1 ) ;
aimlessWithRoadEvent . put ( " em4 " , point1 ) ;
aimlessWithRoadEvent . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5D , 0 . 599074074D ) ;
aimlessWithRoadEvent . put ( " f80x " , point2 ) ;
aimlessWithRoadEvent . put ( " f8xx " , point2 ) ;
aimlessWithRoadEvent . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . AIMLESS_WITH_ROAD_EVENT , aimlessWithRoadEvent ) ;
}
{
// 规划路线,定位视图右边
Map < String , MapCenterPoint > calculatePath = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5D , 0 . 610833D ) ;
calculatePath . put ( " d80x " , point1 ) ;
calculatePath . put ( " em4 " , point1 ) ;
calculatePath . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5D , 0 . 6083333D ) ;
calculatePath . put ( " f80x " , point2 ) ;
calculatePath . put ( " f8xx " , point2 ) ;
calculatePath . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . CALCULATE_PATH , calculatePath ) ;
}
{
// 分类搜索,定位视图右边
Map < String , MapCenterPoint > categorySearch = new HashMap < > ( ) ;
MapCenterPoint point = new MapCenterPoint ( 0 . 5D , 0 . 5D ) ;
categorySearch . put ( " d80x " , point ) ;
categorySearch . put ( " em4 " , point ) ;
categorySearch . put ( " e8xx " , point ) ;
categorySearch . put ( " f80x " , point ) ;
categorySearch . put ( " f8xx " , point ) ;
categorySearch . put ( " f8Amap " , point ) ;
sVrStrategies . put ( Scene . CATEGORY_SEARCH , categorySearch ) ;
}
{
// V2X, 场景视图右边
Map < String , MapCenterPoint > categoryV2XEvent = new HashMap < > ( ) ;
MapCenterPoint point1 = new MapCenterPoint ( 0 . 5 , 0 . 7D ) ;
categoryV2XEvent . put ( " d80x " , point1 ) ;
categoryV2XEvent . put ( " em4 " , point1 ) ;
categoryV2XEvent . put ( " e8xx " , point1 ) ;
MapCenterPoint point2 = new MapCenterPoint ( 0 . 5 , 0 . 65D ) ;
categoryV2XEvent . put ( " f80x " , point2 ) ;
categoryV2XEvent . put ( " f8xx " , point2 ) ;
categoryV2XEvent . put ( " f8Amap " , point2 ) ;
sVrStrategies . put ( Scene . CATEGORY_V2X_EVENT , categoryV2XEvent ) ;
}
}
public static void resetByChangeMode ( ) {
setMapCenterPointByScene ( MogoApisHandler . getInstance ( ) . getApis ( ) . getMapServiceApi ( ) . getMapUIController ( ) , Scene . AIMLESS ) ;
}
/**
* 根据场景触发地图视图改变
*
* @param controller
* @param scene
*/
public static void setMapCenterPointByScene ( IMogoMapUIController controller , int scene ) {
if ( controller = = null ) {
return ;
}
if ( MogoApisHandler . getInstance ( ) . getApis ( ) . getStatusManagerApi ( ) . isVrMode ( ) ) {
//Logger.w( TAG, "vr 模式下忽略该设置" );
return ;
}
Map < Integer , Map < String , MapCenterPoint > > strategies = sCommonStrategies ;
if ( MogoApisHandler . getInstance ( ) . getApis ( ) . getStatusManagerApi ( ) . isVrMode ( ) ) {
strategies = sVrStrategies ;
}
if ( ! strategies . containsKey ( scene ) ) {
Logger . w ( TAG , " no strategy for scene: %s, use DEFAULT " , scene ) ;
controller . setPointToCenter ( DEFAULT . x , DEFAULT . y ) ;
return ;
}
Map < String , MapCenterPoint > points = strategies . get ( scene ) ;
String car = DebugConfig . getProductFlavor ( ) ;
if ( ! points . containsKey ( car ) ) {
Logger . w ( TAG , " no strategy for series: %s, use DEFAULT " , scene ) ;
controller . setPointToCenter ( DEFAULT . x , DEFAULT . y ) ;
return ;
}
MapCenterPoint point = points . get ( car ) ;
if ( point = = null ) {
Logger . w ( TAG , " no strategy config for series: %s, use DEFAULT " , scene ) ;
controller . setPointToCenter ( DEFAULT . x , DEFAULT . y ) ;
return ;
}
controller . setPointToCenter ( point . x , point . y ) ;
}
/**
* 根据场景触发地图视图改变
*
* @param controller
* @param scene
*/
public static void setMapCenterPointBySceneAndDelay ( final IMogoMapUIController controller , final int scene , long delay , final Interrupter interrupter ) {
UiThreadHandler . postDelayed ( ( ) - > {
if ( interrupter ! = null ) {
if ( interrupter . interrupt ( ) ) {
return ;
}
}
setMapCenterPointByScene ( controller , scene ) ;
} , delay ) ;
}
}