mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
nav: add polyline helpers (#26816)
* nav: add polyline helpers * Update selfdrive/navd/map_renderer.py old-commit-hash: d3a3d74830efb33eff6a9f9057a8d552e355bfd7
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import os
|
||||
import time
|
||||
import numpy as np
|
||||
import polyline
|
||||
from cffi import FFI
|
||||
|
||||
from common.ffi_wrapper import suffix
|
||||
@@ -50,6 +51,22 @@ def get_image(lib, renderer):
|
||||
return r.reshape((WIDTH, HEIGHT))
|
||||
|
||||
|
||||
def navRoute_to_polyline(nr):
|
||||
coords = [(m.latitude, m.longitude) for m in nr.navRoute.coordinates]
|
||||
return coords_to_polyline(coords)
|
||||
|
||||
|
||||
def coords_to_polyline(coords):
|
||||
# TODO: where does this factor of 10 come from?
|
||||
return polyline.encode([(lat * 10., lon * 10.) for lat, lon in coords])
|
||||
|
||||
|
||||
def polyline_to_coords(p):
|
||||
coords = polyline.decode(p)
|
||||
return [(lat / 10., lon / 10.) for lat, lon in coords]
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user