Worldmap - Local mapserver

Hello,

I'm really enjoying the Worldmap node (node-red-contrib-web-worldmap). Great project and lots of options!

I'm hoping someone else has used this node in an "offline" setting, with no access to internet. In its default state the basemaps are sourced through the internet, but my application will be offline. It appears the function to use a local WMS server such as Mapserver would work for this application. Can anyone confirm this, or would the node error when it cannot connect to the other mapping services?

I have been working to setup the Mapserver on the same device as node-red and followed the instructions in the documentation, however I have not been able to get it to work.

I know some of this falls outside of the scope of node-red discussions, but as the two are closely integrated so I'll post both node-red and Mapserver configurations.

I'm thinking the issue may have to do with the directory setup between Worldmap and Mapserver.

The Worldmap configuration and command function to call the local WMS mapserver:

[{"id":"afe96885.6c77b8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"80dcecf8.e9e818","type":"worldmap","z":"afe96885.6c77b8","name":"","lat":"52","lon":"-115","zoom":"","layer":"Esri Dark Grey","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/map","x":670,"y":340,"wires":[]},{"id":"2c5f681.ada9818","type":"inject","z":"afe96885.6c77b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":340,"wires":[["fedeaacf.3ce8c"]]},{"id":"fedeaacf.3ce8c","type":"function","z":"afe96885.6c77b8","name":"","func":"msg.payload = { command : { map : {\n    \"name\": \"OSM-BC\",\n    \"url\": \"/cgi-bin/mapserv\",   // we will serve the tiles from this node locally.\n    \"opt\": {\n        \"layers\": \"OSM-BC\",                         // specifies a layer in your map file\n        \"format\": \"image/png\",\n        \"transparent\": true,\n        \"attribution\": \"British Columbia\"\n    },\n    \"wms\": true                                 // set to true for WMS type mapserver\n}}}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":340,"wires":[["80dcecf8.e9e818"]]}]

as described in the Worldmap documentation a "mapserv" executable was created and located in ~/.node-red/node_modules/node-red-contrib-web-worldmap/:

#! /bin/sh
# set this to the path of your WMS map file (which in turn points to your tiles)
MS_MAPFILE=/home/pi/maps/BC.map
export MS_MAPFILE
# and set this to the path of your cgi-mapserv executable
/usr/bin/mapserv

This called the mapserver mapfile BC.map as below:

MAP
    CONFIG "MS_ERRORFILE" "/home/pi/.node-red/node_modules/node-red-contrib-web-worldmap/worldmap/tmp/ms_error.txt"
    NAME "OSM-BC"
    STATUS ON
    EXTENT -141.7761 46.41459 -114.049 60.00678
#    UNITS DD
    IMAGECOLOR 255 255 255
    PROJECTION
                "init=epsg:3857"
    END # PROJECTION
    #
    # Start of web interface definition
    #
    WEB
        IMAGEPATH "/home/pi/.node-red/node_modules/node-red-contrib-web-worldmap/worldmap/tmp/"
        IMAGEURL "/map/tmp/"
        METADATA
             "WMS_ENABLE_REQUEST" "*"
        END #METADATA
    END # WEB
    #
    # Start of layer definitions
    #
    LAYER
        NAME  "OSM-BC"
        DATA "/home/pi/maps/OSM/osm-2017-07-03-v3.6.1-canada_british-columbia.mbtiles"
        PROJECTION
           "init=epsg:3857"
        END # PROJECTION
        TYPE RASTER
        STATUS DEFAULT
    END #LAYER
END # MAP

With this mapfile, there are no errors in the mapserver ms_error.txt, the layer is visible as a choice in the worldmap page, but when selected only displays a blank screen. I'm unsure about the WEB image paths as set in the mapfile, should these be a specific location within the node-red directory tree?

    WEB
        IMAGEPATH "/home/pi/.node-red/node_modules/node-red-contrib-web-worldmap/worldmap/tmp/"
        IMAGEURL "/map/tmp/"

If anyone has some working config for this setup using a local Mapserver that would help.

Thanks!

Hi

my map file is like this

MAP
	NAME 'WorldMap'
	STATUS	ON
	SIZE	1024 768
	EXTENT	-180 -90 180 90
	UNITS	dd
	IMAGECOLOR	240 240 240
	IMAGETYPE	png24
	IMAGEQUALITY  80

	WEB
		METADATA
			"wms_title"           "Local WMS Server"
			"wms_onlineresource"  "http://localhost:1880/cgi-bin/mapserv?map=uk.map&"
			"wms_srs"             "EPSG:4326 EPSG:27700"
			"wms_enable_request"  "*"
		END
	END

	OUTPUTFORMAT
		NAME png
		DRIVER "GD/PNG"
		MIMETYPE "image/png"
		IMAGEMODE PC256
		EXTENSION "png"
	END

	PROJECTION
		'proj=longlat'
		'ellps=WGS84'
		'datum=WGS84'
		'init=epsg:4326'
		'no_defs'
	END

	LAYER
		NAME 'gb'
		TILEINDEX	"World.shp"
		TILEITEM	"Location"
		METADATA
			'wms_title' 'World'
		END
		STATUS       DEFAULT
		TYPE         RASTER
		MINSCALEDENOM	1000000
		PROJECTION
			"init=epsg:4326"
		END
	END

	LAYER
		NAME		"MiniScale"
		TILEINDEX	"MiniScale.shp"
		TILEITEM	"Location"
		METADATA
			wms_title	'MiniScale'
		END
		STATUS		DEFAULT
		TYPE		RASTER
		MAXSCALEDENOM	10000000
		MINSCALEDENOM	  250001
		PROJECTION
			"init=epsg:27700"
		END
	END

	LAYER
		NAME	"250k"
		TILEINDEX	"a2zuk.shp"
		TILEITEM	"Location"
		METADATA
			wms_title	'250k'
		END
		STATUS		DEFAULT
		TYPE		RASTER
		MAXSCALEDENOM	250000
		MINSCALEDENOM	 50001
		PROJECTION
			"init=epsg:27700"
		END
	END

	LAYER
		NAME	"50k"
		TILEINDEX	"50k.shp"
		TILEITEM	"Location"
		METADATA
			wms_title	'50k'
		END
		STATUS		DEFAULT
		TYPE		RASTER
		MAXSCALEDENOM	50000
		MINSCALEDENOM	10000
		PROJECTION
			"init=epsg:27700"
		END
	END

	LAYER
		NAME	"25k"
		TILEINDEX	"25k.shp"
		TILEITEM	"Location"
		METADATA
			wms_title	'25k'
		END
		STATUS		DEFAULT
		TYPE		RASTER
		MAXSCALEDENOM	20000
		MINSCALEDENOM	 501
		PROJECTION
			"init=epsg:27700"
		END
	END

	LAYER
		NAME		"10k"
		TILEINDEX	"10k.shp"
		TILEITEM	"Location"
		METADATA
			wms_title	'10k'
		END
		STATUS		DEFAULT
		TYPE		RASTER
		MAXSCALEDENOM 	5000
		TRANSPARENCY	75
		PROJECTION
			"init=epsg:27700"
		END
	END
END

and is in the same directory as the map .shp files (and .shx and .dbf files)
And the mapserv file is similar to yours - pointing to the .map file.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.