zoukankan      html  css  js  c++  java
  • C# 调用c库

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;

    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;

    /// <summary>坐标</summary>
    /// <param name="lat">维度</param>
    /// <param name="lng">经度</param>
    public coord(double lat, double lng)
    {
    this.lat = lat;
    this.lng = lng;
    }
    }

    class Program
    {
    //取值为如下:
    //1:GPS设备获取的角度坐标,wgs84坐标;
    //3:google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标,国测局坐标(GCJ02);
    //5:百度地图采用的经纬度坐标(bd09ll);

    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);

    if (result == 0)
    Console.WriteLine("convert ok! lat[{0}], lng[{1}]", output.lat, output.lng);
    else
    Console.WriteLine("convert fail!");
    }
    }
    }

  • 相关阅读:
    Centos6.4 cobbler安装要点
    zabbix oracle监控插件orabbix部署安装
    CPP
    基于curl 的zabbix API调用
    oracle 存储过程
    sqlplus乱码
    Intent之对象传递(Parcelable传递对象和对象集合)
    IOS压缩解压缩
    深入浅出java静态代理和动态代理
    c语言用rand() 函数,实现random(int m)
  • 原文地址:https://www.cnblogs.com/netact/p/5346082.html
Copyright © 2011-2022 走看看