Function ostn02_phf::get_shifts_ffi [] [src]

#[no_mangle]
pub extern "C" fn get_shifts_ffi(gr: GridRefs) -> Adjustment

FFI function returning a 3-tuple of Easting, Northing, and height adjustments, for use in transforming ETRS89 Eastings and Northings to OSGB36 Eastings, Northings.
The argument is a Struct containing kilometer-grid references of the ETRS89 Northings and Eastings you wish to convert

Examples

# Python example using ctypes
import sys, ctypes
from ctypes import c_int32, c_double, Structure
 
 
class GridRefs(Structure):
    _fields_ = [("eastings", c_int32),
                ("northings", c_int32)]
 
    def __str__(self):
        return "({},{})".format(self.eastings, self.northings)
 
 
class Shifts(Structure):
    _fields_ = [("x_shift", c_double),
                ("y_shift", c_double),
                ("z_shift", c_double)]
 
    def __str__(self):
        return "({}, {}, {})".format(self.x_shift, self.y_shift, self.z_shift)
 
 
prefix = {'win32': ''}.get(sys.platform, 'lib')
extension = {'darwin': '.dylib', 'win32': '.dll'}.get(sys.platform, '.so')
lib = ctypes.cdll.LoadLibrary(prefix + "ostn02_phf" + extension)
 
lib.get_shifts_ffi.argtypes = (GridRefs,)
lib.get_shifts_ffi.restype = Shifts
 
tup = GridRefs(651, 313)
 
# Should return (102.775, -78.244, 44.252)
print lib.get_shifts_ffi(tup)