using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace WSGPSGateway.BLL
{
public class LocationLogic
{
public LocationLogic() { }
private static volatile LocationLogic _LocationLogic = new LocationLogic();
/// <summary>
///
/// </summary>
/// <returns></returns>
public static LocationLogic GetInstance()
{
if (_LocationLogic == null)
{
lock (typeof(LocationLogic))
{
if (_LocationLogic == null)
{
_LocationLogic = new LocationLogic();
}
}
}
return _LocationLogic;
}
/// <summary>
///
/// </summary>
/// <param name="lat"></param>
/// <param name="lng"></param>
/// <returns></returns>
public decimal[] GetLatLng(decimal lat, decimal lng)
{
int PX, PY;
decimal? PX1, PY1;
decimal? OX;
decimal? OY;
decimal[] LatLng = new decimal[] { lat, lng };
// , ,
try
{
DAL.DeviceinfoDataSetTableAdapters.deviceinfoAdapter da = new DAL.DeviceinfoDataSetTableAdapters.deviceinfoAdapter();
da.P_GETLATLNG(lat, lng, out OX, out OY);
OX = Convert.ToDecimal(OX);
OY = Convert.ToDecimal(OY);
if (OX != 0 && OY != 0)
{
Map.LatLongToPixelXY(Convert.ToDouble(lat), Convert.ToDouble(lng), 18, out PX, out PY);
PX1 = PX + OX;
PY1 = PY + OY;
LatLng[0] = Convert.ToDecimal(Map.PixelYToLat(Convert.ToDouble(PY1), 18));
LatLng[1] = Convert.ToDecimal(Map.PixelXToLng(Convert.ToDouble(PX1), 18));
}
}
catch (Exception ex)
{
DAL.Log.Write(" ! \0 :" + ex + "\r
");
DAL.Log.Write("-----------------------------------------------------------\r
");
}
return LatLng;
}
}
}