using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;this
namespace test
{
public class CoordTrans
{
//
[DllImport("coord_trans.dll", EntryPoint = "convert", CallingConvention = CallingConvention.Cdecl)]
public static extern int convert(int from, int to, ref coord input, ref coord output);
}
public struct coord
{
/// <summary>維度</summary>
public double lat;
/// <summary>經度</summary>
public double lng;google
/// <summary>座標</summary>
/// <param name="lat">維度</param>
/// <param name="lng">經度</param>
public coord(double lat, double lng)
{
this.lat = lat;
this.lng = lng;
}
}spa
class Program
{
//取值爲以下:
//1:GPS設備獲取的角度座標,wgs84座標;
//3:google地圖、soso地圖、aliyun地圖、mapabc地圖和amap地圖所用座標,國測局座標(GCJ02);
//5:百度地圖採用的經緯度座標(bd09ll);input
static void Main(string[] args)
{
coord input = new coord(31.221816, 121.350051);
coord output = new coord(0.0, 0.0);
int result = CoordTrans.convert(1, 5, ref input, ref output);string
if (result == 0)
Console.WriteLine("convert ok! lat[{0}], lng[{1}]", output.lat, output.lng);
else
Console.WriteLine("convert fail!");
}
}
}it