Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/module.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node src/main.js"
},
"author": "Lukasz Cepowski <lukasz@cepowski.com> (https://loskoderos.com)",
"license": "MIT",
Expand Down
3 changes: 3 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Usage: georender [options] \n \
-i, --in <input file>, --in ... - Path to input file (.geojson, .gpx, .kml, .kmz)\n \
-o, --out <output file> - Path to output file (.png or .jpg)\n \
-t, --tile <name> - Name of the tile source [osm, otm, esri]\n \
--timeout <timeout> - Timeout in seconds before aborting\n \
';

const options = {
Expand All @@ -16,6 +17,7 @@ const options = {
'in': { type: 'string', short: 'i', multiple: true },
'out': { type: 'string', short: 'o' },
'tile': { type: 'string', short: 't', default: 'osm' },
'timeout': { type: 'string', default: '30' },
};

export class Application {
Expand Down Expand Up @@ -60,6 +62,7 @@ export class Application {
in: args.values.in,
out: args.values.out,
tile: args.values.tile,
timeout: args.values.timeout,
});

return 0;
Expand Down
3 changes: 1 addition & 2 deletions src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ export const defaults = {
})
})
],
padding: [50, 50, 50, 50],
timeout: 30
padding: [50, 50, 50, 50]
};
8 changes: 6 additions & 2 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ export class Renderer {
const inputFiles = options.in || [];
const outputFile = options.out || "out.png";
const tile = defaults.tile[options.tile || 'osm'];
const timeoutInSecs = parseInt(options.timeout, 10);
const style = defaults.style;
const padding = defaults.padding;

console.log(' width:', width);
console.log(' height:', height);
console.log(' input files:', inputFiles);
console.log(' output file:', outputFile);
console.log(' tile:', options.tile || 'osm');
console.log(' timeout (in seconds):', timeoutInSecs);

const timeout = setTimeout(reject, defaults.timeout * 1000);
const timeout = setTimeout(() => reject(new Error(`Timeout after ${timeoutInSecs}s`)),
timeoutInSecs * 1000);

const element = document.createElement('div');
element.style.width = `${width}px`;
Expand Down Expand Up @@ -74,7 +78,7 @@ export class Renderer {
}
})
.then(() => console.log("Done!"))
.catch(err => console.error(err instanceof Error ? err.message : "\nTimeout!"))
.catch(err => console.error(err))
;
}

Expand Down