From 67e69707959bce1486c1b2dc03b936b3166f3f2b Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 7 Mar 2021 17:07:47 +0000 Subject: [PATCH] add more mapserver info to readme and bump for weblink PR --- CHANGELOG.md | 2 ++ README.md | 28 +++++++++++++++++++++++----- package.json | 7 +++++-- worldmap.js | 7 +++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c58d4..ea9a7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### Change Log for Node-RED Worldmap + - v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers. + - v2.8.9 - Only load cgi module if we have a local mapserv file - v2.8.8 - Change length of speed leader to show where you will be in 1 min if speed in m/s - v2.8.7 - Delay start of ui widget. - v2.8.6 - Better checking of type property before guessing it's geojson. Issue #153 diff --git a/README.md b/README.md index e147618..aaca1e9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ map web page for plotting "things" on. ### Updates -- v2.8.8 - Change length of speed leader to show where you will be in 1 min if speed in m/s +- v2.9.0 - Let weblinks be an array of links. Add more info to readme about Mapservers. +- v2.8.9 - Only load cgi module if we have a local mapserv file. +- v2.8.8 - Change length of speed leader to show where you will be in 1 min if speed in m/s. - v2.8.7 - Delay start of ui widget. - v2.8.6 - Better checking of type property before guessing it's geojson. Issue #153 - v2.8.4 - Add addToForm(n,v) option and $form - to make contextmenu form submission easier. @@ -629,13 +631,29 @@ You can then add a new WMS Base layer by injecting a message like "wms": true // set to true for WMS type mapserver }}} -Optionally set `"wms":"grey"` to set the layer to greyscale which may make your markers more visible. -**Hint**: if can use a docker container like https://hub.docker.com/r/geodata/mapserver/ then assuming you have the mapfile 'my-app.map' in the current working directory, you could mount it as: +#### Using a Docker Map Server + +You can use a docker continaer like https://hub.docker.com/r/camptocamp/mapserver, then assuming you have the mapfile 'my-app.map' in the current working directory, you could mount it as: ``` -docker run -d --name mapserver -v $(pwd):/maps:ro -p 1881:80 geodata/mapserver +docker run -d --name camptocamp -v $(pwd):/etc/mapserver/:ro -p 1881:80 camptocamp/mapserver ``` -then the url should be of the form `"url": "http://localhost:1881/?map=/maps/my-app.map",` where *my-app.map* is the name of your map file. A quick test of the server would be to browse to http://localhost:1881/?map=/maps/my-app.map&mode=map +and use a url like `"url": "http://localhost:1882/?map=/etc/mapserver/my-app.map"` +then the url should be of the form `"url": "http://localhost:1881/?map=/etc/mapserver/my-app.map"` where *my-app.map* is the name of your map file. A quick test of the server would be to browse to http://localhost:1881/?map=/etc/mapserver/my-app.map&mode=map + +Or you can use a docker container like https://hub.docker.com/r/geodata/mapserver/ then assuming you have the mapfile 'my-app.map' in the current working directory, you could mount it as: +``` +docker run -d --name mapserver -v $(pwd):/maps:ro -p 1882:80 geodata/mapserver +``` +and use a url like `"url": "http://localhost:1882/?map=/maps/my-app.map",` + + +To use a vector mbtiles server like **MapTiler** then you can download your mbtiles file into a directory and then from that directory run +``` +docker run --name maptiler -d -v $(pwd):/data -p 1884:8080 maptiler/tileserver-gl -p 8080 +``` +and use a url like `"url": "http://localhost:1884/styles/basic-preview/{z}/{x}/{y}.png"` + ## Examples and Demo Flow diff --git a/package.json b/package.json index 70d1db3..b9bf69d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "2.8.8", + "version": "2.9.0", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "cgi": "0.3.1", @@ -9,7 +9,10 @@ "sockjs": "~0.3.21" }, "bundledDependencies": [ - "cgi","compression","express","sockjs" + "cgi", + "compression", + "express", + "sockjs" ], "repository": { "type": "git", diff --git a/worldmap.js b/worldmap.js index c334d48..845b35d 100644 --- a/worldmap.js +++ b/worldmap.js @@ -17,14 +17,17 @@ module.exports = function(RED) { "use strict"; + var fs = require('fs'); var path = require("path"); var express = require("express"); var compression = require("compression"); var sockjs = require('sockjs'); var sockets = {}; RED.log.info("Worldmap version " + require('./package.json').version ); - // add the cgi module for serving local maps.... - RED.httpNode.use("/cgi-bin/mapserv", require('cgi')(__dirname + '/mapserv')); + // add the cgi module for serving local maps.... only if mapserv exists + if (fs.existsSync((__dirname + '/mapserv'))) { + RED.httpNode.use("/cgi-bin/mapserv", require('cgi')(__dirname + '/mapserv')); + } function worldMap(node, n) { RED.nodes.createNode(node,n);