Skip to content

Commit 34b2f04

Browse files
authored
Split point functions into own module (#1214)
1 parent 7f132fc commit 34b2f04

6 files changed

Lines changed: 453 additions & 400 deletions

File tree

deebot_client/map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ def reset_changed(self) -> None:
205205

206206
def add_trace_points(self, value: str) -> None:
207207
"""Add trace points to the map data."""
208-
self._data.add_trace_points(value)
208+
self._data.trace_points.add(value)
209209
self._on_change()
210210

211211
def clear_trace_points(self) -> None:
212212
"""Clear trace points."""
213-
self._data.clear_trace_points()
213+
self._data.trace_points.clear()
214214
self._on_change()
215215

216216
def update_positions(self, value: list[Position]) -> None:

deebot_client/rs/map.pyi

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ class BackgroundImage:
1212
def map_piece_crc32_indicates_update(self, index: int, crc32: int) -> bool:
1313
"""Return True if update is required."""
1414

15+
class TracePoints:
16+
"""Trace points in rust."""
17+
18+
def add(self, value: str) -> None:
19+
"""Add trace points to the trace points object."""
20+
21+
def clear(self) -> None:
22+
"""Clear all trace points."""
23+
1524
class MapData:
1625
"""Map data in rust."""
1726

@@ -22,11 +31,9 @@ class MapData:
2231
def background_image(self) -> BackgroundImage:
2332
"""Return background image."""
2433

25-
def add_trace_points(self, value: str) -> None:
26-
"""Add trace points to the map data."""
27-
28-
def clear_trace_points(self) -> None:
29-
"""Clear trace points."""
34+
@property
35+
def trace_points(self) -> TracePoints:
36+
"""Return trace points."""
3037

3138
def generate_svg(
3239
self,

src/map/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pub(super) fn round(value: f32, digits: usize) -> f32 {
2+
let factor = 10f32.powi(digits as i32);
3+
(value * factor).round() / factor
4+
}

0 commit comments

Comments
 (0)