MCPcopy Create free account
hub / github.com/StevenLyt/mapf-visualizer / verifyMap

Method verifyMap

src/components/UploadMap.jsx:67–88  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

65 }
66
67 verifyMap(text) {
68 try {
69 const lines = text.trim().split(/\r?\n/);
70 if (lines[0].split(" ")[0] !== "type") return false;
71 if (lines[1].split(" ")[0] !== "height") return false;
72 const height = parseInt(lines[1].split(" ")[1]);
73 if (lines[2].split(" ")[0] !== "width") return false;
74 const width = parseInt(lines[2].split(" ")[1]);
75 if (lines[3].trim() !== "map") return false;
76 if (height !== lines.length - 4) return false;
77 for (let i = 4; i < lines.length; i++) {
78 var line = lines[i].trim();
79 if (line.length !== width) return false;
80 for (let char of line) {
81 if (char !== "." && char !== "@" && char !== "T") return false;
82 }
83 }
84 return true;
85 } catch (e) {
86 return false;
87 }
88 }
89
90 render() {
91 return (

Callers 1

parseMapMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected