Skip to content

Commit

Permalink
feat(tile-converter): add convertion status dump file
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkuznetsov-actionengine committed Jan 17, 2024
1 parent fd58d91 commit 836675e
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 21 deletions.
1 change: 1 addition & 0 deletions modules/tile-converter/src/constants.ts
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 modules/tile-converter/src/i3s-converter/helpers/dump-parser.ts
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;
};
Loading

0 comments on commit 836675e

Please sign in to comment.