mirror of
https://github.com/luzifer-docker/phantom-firemap.git
synced 2024-12-20 12:51:18 +00:00
initial version
This commit is contained in:
commit
706651c178
3 changed files with 67 additions and 0 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM nolimitid/node-phantom
|
||||
|
||||
RUN set -ex \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y imagemagick
|
||||
|
||||
VOLUME ["/data"]
|
||||
ENTRYPOINT ["/usr/local/bin/run.sh"]
|
||||
CMD []
|
||||
|
||||
ADD index.js /src/index.js
|
||||
ADD run.sh /usr/local/bin/run.sh
|
37
index.js
Normal file
37
index.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
var page = require('webpage').create(),
|
||||
system = require('system');
|
||||
|
||||
browser_width = 2560
|
||||
browser_height = browser_width / 297 * 210
|
||||
|
||||
page.viewportSize = { width: browser_width, height: browser_height };
|
||||
page.settings.webSecurityEnabled = false
|
||||
page.settings.resourceTimeout = 5000
|
||||
page.settings.localToRemoteUrlAccessEnabled = true
|
||||
|
||||
if (system.args.length !== 4) {
|
||||
console.log('Usage: '+system.args[0]+' <zoom> <lat> <lon>');
|
||||
phantom.exit();
|
||||
}
|
||||
|
||||
var url = [
|
||||
'http://openfiremap.org/',
|
||||
'?zoom=', system.args[1],
|
||||
'&lat=', system.args[2],
|
||||
'&lon=', system.args[3],
|
||||
'&layers=B0000TF',
|
||||
].join('');
|
||||
|
||||
console.log("Fetching URL " + url);
|
||||
|
||||
page.open(url, function(status) {
|
||||
if (status !== 'success') {
|
||||
console.log('Unable to load the address!');
|
||||
phantom.exit();
|
||||
} else {
|
||||
window.setTimeout(function () {
|
||||
page.render('/data/shot.png');
|
||||
phantom.exit();
|
||||
}, 5000); // Change timeout as required to allow sufficient time
|
||||
}
|
||||
});
|
18
run.sh
Executable file
18
run.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
DPI=150
|
||||
W=1754 # 150 x 11.69
|
||||
H=1241 # 150 x 8.27
|
||||
|
||||
/usr/bin/phantomjs /src/index.js "$@"
|
||||
|
||||
TARGET="map_$(date +%Y-%m-%d_%H-%M)"
|
||||
mv /data/shot.png /data/${TARGET}.png
|
||||
|
||||
#exec convert /data/${TARGET}.png -compress jpeg -quality 90 \
|
||||
# -resize ${W}x${H} -density ${DPI} \
|
||||
# -repage ${W}x${H} /data/${TARGET}.pdf
|
||||
exec convert /data/${TARGET}.png -compress jpeg -quality 90 \
|
||||
-resize ${W}x${H} -gravity center -extent ${W}x${H} \
|
||||
-units PixelsPerInch -set density ${DPI} \
|
||||
-repage ${W}x${H} /data/${TARGET}.pdf
|
Loading…
Reference in a new issue