Esempio n. 1
0
    def __init__(self, definition):

        self._ctx = _lib.pj_ctx_alloc()
        self._proj = _lib.pj_init_plus_ctx(self._ctx, definition.encode('ascii'))
        
        errno = _lib.pj_ctx_get_errno(self._ctx)
        if errno != 0:
            raise RuntimeError(_lib.pj_strerrno(errno))
Esempio n. 2
0
def transform(proj1, proj2, x, y, z=None, radians=False):

    # Fixme: implement Numpy array

    if _lib.pj_is_latlong(proj1._proj) and not radians:
        x = math.radians(x)
        y = math.radians(y)
    x_ptr = _ffi.new('double []', [x])
    y_ptr = _ffi.new('double []', [y])
    z_ptr = _ffi.new('double []', [0])
    count = 1
    offset = 0
    
    errno = _lib.pj_transform(proj1._proj, proj2._proj, count, offset, x_ptr, y_ptr, z_ptr)
    if errno != 0:
        raise RuntimeError(_lib.pj_strerrno(errno))
    
    return x_ptr[0], y_ptr[0], z_ptr[0]