Skip to content

Commit

Permalink
fix(vendor.dreame): Fix virtual restriction coordinates being not sor…
Browse files Browse the repository at this point in the history
…ted properly
  • Loading branch information
Hypfer committed Oct 12, 2021
1 parent f992e5a commit 17cc303
Show file tree
Hide file tree
Showing 6 changed files with 62,269 additions and 123 deletions.
19 changes: 15 additions & 4 deletions backend/lib/robots/dreame/DreameMapParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,25 @@ class DreameMapParser {
static PARSE_AREAS(parsedHeader, areas, type) {
return areas.map(a => {
const pA = DreameMapParser.CONVERT_TO_VALETUDO_COORDINATES(a[0], a[1]);
const pB = DreameMapParser.CONVERT_TO_VALETUDO_COORDINATES(a[0], a[3]);
const pC = DreameMapParser.CONVERT_TO_VALETUDO_COORDINATES(a[2], a[3]);
const pD = DreameMapParser.CONVERT_TO_VALETUDO_COORDINATES(a[2], a[1]);
const pB = DreameMapParser.CONVERT_TO_VALETUDO_COORDINATES(a[2], a[3]);

//I'm way too lazy to figure out which dreame model uses which order of coordinates
const xCoords = [pA.x, pB.x].sort((a, b) => {
return a-b;
});
const yCoords = [pA.y, pB.y].sort((a, b) => {
return a-b;
});


return new Map.PolygonMapEntity({
type: type,
points: [pA.x, pA.y,pB.x, pB.y,pC.x, pC.y,pD.x, pD.y]
points: [
xCoords[0], yCoords[0],
xCoords[1], yCoords[0],
xCoords[1], yCoords[1],
xCoords[0], yCoords[1]
]
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"y": 6554
},
"pixelSize": 5,
"layers": [{
"layers": [
{
"__class": "MapLayer",
"metaData": {
"area": 11225
Expand Down Expand Up @@ -23629,7 +23630,8 @@
}
}
],
"entities": [{
"entities": [
{
"__class": "PointMapEntity",
"metaData": {
"angle": 90
Expand All @@ -23655,13 +23657,13 @@
"__class": "PolygonMapEntity",
"metaData": {},
"points": [
3245,
3136,
3245,
3070,
3308,
3070,
3308,
3136,
3245,
3136
],
"type": "no_go_area"
Expand Down Expand Up @@ -23707,4 +23709,4 @@
"type": "path"
}
]
}
}
Loading

0 comments on commit 17cc303

Please sign in to comment.