mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 05:24:06 +08:00
nav: add polyline helpers (#26816)
* nav: add polyline helpers
* Update selfdrive/navd/map_renderer.py
old-commit-hash: d3a3d74830
This commit is contained in:
4
poetry.lock
generated
4
poetry.lock
generated
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f001cc546693d59937130ed9cd49da4bd092d5ec7d1bf96b0419d76ab0271cf7
|
||||
size 562441
|
||||
oid sha256:f987ed9e1ad0fce8607e7884e389143189ef741be636a4d976437dafbd606cc3
|
||||
size 563115
|
||||
|
||||
@@ -57,6 +57,7 @@ tqdm = "^4.64.0"
|
||||
urllib3 = "^1.26.10"
|
||||
utm = "^0.7.0"
|
||||
websocket_client = "^1.3.3"
|
||||
polyline = "^1.4.0"
|
||||
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
|
||||
@@ -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