mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	bump waht3words package
add msg.payload{lat:lon} option
			
			
This commit is contained in:
		@@ -27,6 +27,11 @@ To convert position to words it requires
 | 
			
		||||
 - `msg.location.lat`
 | 
			
		||||
 - `msg.location.lon`
 | 
			
		||||
 | 
			
		||||
or
 | 
			
		||||
 | 
			
		||||
 - `msg.payload.lat`
 | 
			
		||||
 - `msg.payload.lon`
 | 
			
		||||
 | 
			
		||||
or
 | 
			
		||||
 | 
			
		||||
 - `msg.payload`  containing a string  lat,lon
 | 
			
		||||
@@ -36,6 +41,8 @@ To convert words to position it requires
 | 
			
		||||
 | 
			
		||||
 - `msg.payload` containing a string of  _unique.three.words_
 | 
			
		||||
 | 
			
		||||
 A 3 word string separated by dots.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
The API-key is stored in a separate credentials file.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
    "name"          : "node-red-node-what3words",
 | 
			
		||||
    "version"       : "0.0.5",
 | 
			
		||||
    "version"       : "0.0.7",
 | 
			
		||||
    "description"   : "A Node-RED node to convert locations to/from what3words",
 | 
			
		||||
    "dependencies"  : {
 | 
			
		||||
        "geo.what3words"   : "^2.0.0"
 | 
			
		||||
 
 | 
			
		||||
@@ -12,10 +12,19 @@ module.exports = function(RED) {
 | 
			
		||||
        var w1 = /^\*\w{6,31}$/;
 | 
			
		||||
        var w3 = /^\w+\.\w+\.\w+$/;
 | 
			
		||||
        this.on("input", function(msg) {
 | 
			
		||||
            if (msg.hasOwnProperty("location")) {
 | 
			
		||||
                var lat = msg.location.lat;
 | 
			
		||||
                var lon = msg.location.lon;
 | 
			
		||||
                node.w3w.positionToWords({ position:lat + "," + lon, lang:node.lang })
 | 
			
		||||
            if (msg.hasOwnProperty("location") && msg.location.hasOwnProperty("lat") && msg.location.hasOwnProperty("lon")) {
 | 
			
		||||
                node.w3w.positionToWords({ position:msg.location.lat + "," + msg.location.lon, lang:node.lang })
 | 
			
		||||
                    .then(function(response) {
 | 
			
		||||
                        msg.payload = response; // prom.cape.pump
 | 
			
		||||
                        if (!msg.hasOwnProperty("topic") || (msg.topic === "")) { msg.topic = "what3words"; }
 | 
			
		||||
                        node.send(msg);
 | 
			
		||||
                    })
 | 
			
		||||
                    .catch(function(err) {
 | 
			
		||||
                        node.warn(err)
 | 
			
		||||
                    });
 | 
			
		||||
            }
 | 
			
		||||
            else if (msg.hasOwnProperty("payload") && msg.payload.hasOwnProperty("lat") && msg.payload.hasOwnProperty("lon")) {
 | 
			
		||||
                node.w3w.positionToWords({ position:msg.payload.lat + "," + msg.payload.lon, lang:node.lang })
 | 
			
		||||
                    .then(function(response) {
 | 
			
		||||
                        msg.payload = response; // prom.cape.pump
 | 
			
		||||
                        if (!msg.hasOwnProperty("topic") || (msg.topic === "")) { msg.topic = "what3words"; }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user