48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Reflection;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Plane.Maps.ChinaOffset
|
|||
|
{
|
|||
|
public sealed class ChinaMapOffsetResolver
|
|||
|
{
|
|||
|
private static ChinaMapOffsetResolver _Instance;
|
|||
|
public static ChinaMapOffsetResolver Instance
|
|||
|
{
|
|||
|
get { return _Instance ?? (_Instance = new ChinaMapOffsetResolver()); }
|
|||
|
}
|
|||
|
|
|||
|
private ChinaMapOffsetResolver() { }
|
|||
|
|
|||
|
private ChinaOffsetMap _CM;
|
|||
|
private ChinaOffsetMap CM { get { return _CM ?? (_CM = new ChinaOffsetMap(LoadResource("chinaoffset"))); } }
|
|||
|
|
|||
|
private ChinaOffsetMap _Acm;
|
|||
|
private ChinaOffsetMap Acm { get { return _Acm ?? (_Acm = new ChinaOffsetMap(LoadResource("antichinaoffset"))); } }
|
|||
|
|
|||
|
public LatLng StandardToChinaMap(double lat, double lng)
|
|||
|
{
|
|||
|
var dxyRetLngLat = new double[2];
|
|||
|
this.CM.GetLonLatAfterOffset(lng, lat, dxyRetLngLat);
|
|||
|
return new LatLng(dxyRetLngLat[1], dxyRetLngLat[0]);
|
|||
|
}
|
|||
|
|
|||
|
public LatLng ChinaMapToStandard(double lat, double lng)
|
|||
|
{
|
|||
|
var dxyRetLngLat = new double[2];
|
|||
|
this.Acm.GetLonLatAfterOffset(lng, lat, dxyRetLngLat);
|
|||
|
return new LatLng(dxyRetLngLat[1], dxyRetLngLat[0]);
|
|||
|
}
|
|||
|
|
|||
|
private Stream LoadResource(string simpleName)
|
|||
|
{
|
|||
|
String resourceName = this.GetType().Namespace + ".Resources." + simpleName + ".dat";
|
|||
|
return typeof(ChinaMapOffsetResolver).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|