-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tile-converter): add convertion status dump file
- Loading branch information
1 parent
fd58d91
commit 836675e
Showing
5 changed files
with
298 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const BROWSER_ERROR_MESSAGE = | ||
'Tile converter does not work in browser, only in node js environment'; | ||
export const DUMP_FILE_SUFFIX = '.dump.json'; |
23 changes: 23 additions & 0 deletions
23
modules/tile-converter/src/i3s-converter/helpers/dump-parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {isMap} from 'util/types'; | ||
|
||
/** | ||
* Convert dump map to object for stringifying to JSON | ||
* @param tilesConverted - Map of tilesConverted with conversion status | ||
* @returns tilesConverted Map converted to Object | ||
*/ | ||
export const dumpToObject = (tilesConverted: Map<string, any>) => { | ||
const object = {}; | ||
for (const [key, value] of tilesConverted) { | ||
if (value && value.nodes) { | ||
object[key] = {nodes: []}; | ||
for (const node of value.nodes) { | ||
if (isMap(node.done)) { | ||
object[key].nodes.push({nodeId: node.nodeId, done: Object.fromEntries(node.done)}); | ||
} else { | ||
object[key].nodes.push({nodeId: node.nodeId, done: node.done}); | ||
} | ||
} | ||
} | ||
} | ||
return object; | ||
}; |
Oops, something went wrong.