| Crates.io | polyline-ffi |
| lib.rs | polyline-ffi |
| version | 0.6.5 |
| created_at | 2016-07-25 13:40:46.508007+00 |
| updated_at | 2024-04-27 10:16:22.102367+00 |
| description | FFI bindings for the polyline crate |
| homepage | https://crates.io/crates/polyline-ffi |
| repository | https://github.com/urschrei/polyline-ffi |
| max_upload_size | |
| id | 5782 |
| size | 45,997 |
A Python implementation using these bindings is available at pypolyline
This crate uses Coordinate and LineString types from the geo-types crate, which encodes coordinates in (x, y) order. The Polyline algorithm and first-party documentation assumes the opposite coordinate order. It is thus advisable to pay careful attention to the order of the coordinates you use for encoding and decoding.
decode_polyline_ffiConvert a Polyline into an array of coordinates.
Callers must pass two arguments:
NUL-terminated character array (char*)int for precision (5 for Google Polylines, 6 for OSRM and Valhalla Polylines)Returns an Array struct with two fields:
data, a void pointer to a nested double-precision float array: e.g. [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]len, an integer of type size_t, denoting the array length, e.g. 3Callers must then call drop_float_array to free the memory allocated by this function.
drop_float_arrayFree memory pointed to by Array, which Rust has allocated across the FFI boundary.
Callers must pass the same Array struct that was received from decode_polyline_ffi.
encode_coordinates_ffiConvert coordinates into a Polyline.
Callers must pass a struct, with two members:
data, a void pointer to a nested double-precision float array: e.g. [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]len, the array length, e.g. 3Returns a pointer to a C character array (char*).
Callers must then call drop_cstring to free the memory allocated by this function.
drop_cstringFree memory pointed to by char*, which Rust has allocated across the FFI boundary.
Callers must pass the same char* they receive from encode_coordinates_ffi.
Compressed binaries are available for Linux (64-bit), OSX (64-bit), and Windows (32-bit and 64-bit), from the releases page.
The Linux binary has been built using the manylinux1 (CentOS 5.11) Docker image, and is widely compatible.
Both Linux and OSX binaries have been built with rpath support.