近期,写了一个坐标转换的DLL文件,那边调用的使用的是python语言进行调用的,现在提供调用的实现代码
# -*- coding:utf-8 -*-
#coding=utf-8
import ctypes
import sys
if __name__ == '__main__':
dll = ctypes.cdll.LoadLibrary
lib = dll("D:\Geoconvert.dll")
#计算x坐标
FunWGS84toBGCoord_x=lib.WGS84toBGCoord_x
FunWGS84toBGCoord_x.argtypes = [ctypes.c_double, ctypes.c_double]
FunWGS84toBGCoord_x.restype = ctypes.c_double
# 计算y坐标
FunWGS84toBGCoord_y = lib.WGS84toBGCoord_y
FunWGS84toBGCoord_y.argtypes = [ctypes.c_double, ctypes.c_double]
FunWGS84toBGCoord_y.restype = ctypes.c_double
# 第一个点
lng1 = ctypes.c_double(121.411119983333)
lat1 = ctypes.c_double(31.45847425)
geo_x1 = FunWGS84toBGCoord_x(lng1, lat1)
geo_y1 = FunWGS84toBGCoord_y(lng1, lat1)
s1="First Point"
print s1
print geo_x1
print geo_y1
# 第二个点
lng2 =ctypes.c_double(121.449828163888)
lat2=ctypes.c_double(31.4227804888888)
geo_x2 = FunWGS84toBGCoord_x(lng2, lat2)
geo_y2 = FunWGS84toBGCoord_y(lng2, lat2)
s2 = "Second Point"
print s2
print geo_x2
print geo_y2