Skip to content

Commit

Permalink
Merge pull request #103 from Hypfer/patch-2
Browse files Browse the repository at this point in the history
Allow for rendering of maps with compressed pixels
  • Loading branch information
TheLastProject authored Dec 5, 2021
2 parents 6633502 + 9ad817a commit 4065f4b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions valetudo-map-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,25 @@ class ValetudoMapCard extends HTMLElement {
if (attributes.__class === 'ValetudoMap') {
canDrawMap = true;
}

if (attributes.metaData?.version === 2 && Array.isArray(attributes.layers)) {
attributes.layers.forEach(layer => {
if(layer.pixels.length === 0 && layer.compressedPixels.length !== 0) {
for (let i = 0; i < layer.compressedPixels.length; i = i + 3) {
const xStart = layer.compressedPixels[i];
const y = layer.compressedPixels[i+1]
const count = layer.compressedPixels[i+2]

for(let j = 0; j < count; j++) {
layer.pixels.push(
xStart + j,
y
);
}
}
}
})
}

if (!infoEntity || infoEntity['state'] === 'unavailable' || !infoEntity.attributes) {
canDrawControls = false;
Expand Down

0 comments on commit 4065f4b

Please sign in to comment.