Function polyline_ffi::encode_coordinates_ffi[][src]

#[no_mangle]
pub extern "C" fn encode_coordinates_ffi(
    coords: Array,
    precision: u32
) -> *mut c_char
Expand description

Convert an array of coordinates into a Polyline

Callers must pass two arguments:

  • a Struct with two fields:
    • data, a void pointer to an array of floating-point lat, lon coordinates: [[1.0, 2.0]]
    • len, the length of the array being passed. Its type must be size_t: 1
  • an unsigned 32-bit int for precision (5 for Google Polylines, 6 for OSRM and Valhalla Polylines)

A decoding failure will return one of the following:

  • a char* beginning with “Longitude error:” if invalid longitudes are passed
  • a char* beginning with “Latitude error:” if invalid latitudes are passed

Implementations calling this function must call drop_cstring with the returned c_char pointer, in order to free the memory it allocates.

Safety

This function is unsafe because it accesses a raw pointer which could contain arbitrary data