opt
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.mogo.map;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/17
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MogoCoordinatesTransformer implements CoordinatesTransformer {
|
||||
|
||||
private CoordinatesTransformer mDelegate;
|
||||
|
||||
private static volatile MogoCoordinatesTransformer sInstance;
|
||||
|
||||
private MogoCoordinatesTransformer(){
|
||||
mDelegate = MogoMapDelegateFactory.getCoordinatesTransformer();
|
||||
}
|
||||
|
||||
public static MogoCoordinatesTransformer getInstance(){
|
||||
if( sInstance == null ){
|
||||
synchronized( MogoCoordinatesTransformer.class ) {
|
||||
if( sInstance == null ){
|
||||
sInstance = new MogoCoordinatesTransformer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release(){
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] transform( double lat, double lon ) {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.transform( lat, lon );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -133,4 +133,8 @@ class MogoMapDelegateFactory {
|
||||
public static IMogoTrafficSearch getTrafficSearch() {
|
||||
return getApiBuilder().getTrafficSearch();
|
||||
}
|
||||
|
||||
public static CoordinatesTransformer getCoordinatesTransformer(){
|
||||
return getApiBuilder().getCoordinatesTransformer();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user