From 76fe4123f6d7c6c0e35d287dff52d61f8335122f Mon Sep 17 00:00:00 2001 From: dceejay Date: Fri, 29 May 2015 17:49:19 +0100 Subject: [PATCH] Add what3words node --- parsers/what3words/LICENSE | 177 +++++++++++++++++++++++++++++ parsers/what3words/README.md | 48 ++++++++ parsers/what3words/package.json | 24 ++++ parsers/what3words/w3w.tgz | Bin 0 -> 15483 bytes parsers/what3words/what3words.html | 102 +++++++++++++++++ parsers/what3words/what3words.js | 116 +++++++++++++++++++ 6 files changed, 467 insertions(+) create mode 100644 parsers/what3words/LICENSE create mode 100644 parsers/what3words/README.md create mode 100644 parsers/what3words/package.json create mode 100644 parsers/what3words/w3w.tgz create mode 100644 parsers/what3words/what3words.html create mode 100644 parsers/what3words/what3words.js diff --git a/parsers/what3words/LICENSE b/parsers/what3words/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/parsers/what3words/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/parsers/what3words/README.md b/parsers/what3words/README.md new file mode 100644 index 00000000..7fc849f8 --- /dev/null +++ b/parsers/what3words/README.md @@ -0,0 +1,48 @@ +node-red-node-what3words +======================== + +A Node-RED node to convert positions to what3words... + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-what3words + +Pre-reqs +-------- + +You will need a valid API key from what3words + + +Usage +----- + +Uses What 3 Words to convert a location to 3 unique words. +and vice versa. Don't ask... just try it... + +To convert position to words it requires + + - msg.location.lat + - msg.location.lon + +or + + - msg.payload containing a string lat,lon + + +To convert words to position it requires + + - msg.payload containing a string unique.three.words + + +The API-key is stored in a separate credentials file. + +**Note:** This is an online service and requires a live internet connection and a valid API key to work correctly. + +See what3words for more details.

+ +Example flow: + + [{"id":"f38eba15.0c7148","type":"inject","name":"","topic":"","payload":"calibrate.newlyweds.switched","payloadType":"string","repeat":"","crontab":"","once":false,"x":646,"y":319,"z":"cf058368.30fa8","wires":[["22d6b2a5.dd294e"]]},{"id":"22d6b2a5.dd294e","type":"what3words","title":"","name":"","x":881,"y":317,"z":"cf058368.30fa8","wires":[["9caf8aa8.635078"]]},{"id":"9caf8aa8.635078","type":"debug","name":"","active":true,"console":false,"complete":"true","x":1077,"y":315,"z":"cf058368.30fa8","wires":[]}] diff --git a/parsers/what3words/package.json b/parsers/what3words/package.json new file mode 100644 index 00000000..b6f18efa --- /dev/null +++ b/parsers/what3words/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-what3words", + "version" : "0.0.1", + "description" : "A Node-RED node to convert locations to/from what3words", + "dependencies" : { + "geo.what3words" : "0.0.2" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/parsers/what3words" + }, + "license": "Apache-2.0", + "keywords": [ "node-red", "what3words" ], + "node-red" : { + "nodes" : { + "what3words": "what3words.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/parsers/what3words/w3w.tgz b/parsers/what3words/w3w.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7c5bc96c67d1888f730f12faaded27a543e391e1 GIT binary patch literal 15483 zcmV->JcPp^iwFqH3_Mi;19vlbE_7jX0PTGTSQJUqFd`<5m_5_Dq6C)(mJEVqMUn!F zf#9$^yNqmd0~x`1=5&ZTAm*HN;7q5YqL?Fk22{kXnEAVVW_D)@o)_Nx-v9fY=bl%# zr@Okks=B(Wx~5*4Tu4|c389q?{*e@qtL>8HN}9ceu-+=q|8f4Oab&oZ;J9*X5(EyHlSn94 zq+A9%A)x>*LP8}_k_t7|>V<{CF=2kb7#xhL6gWnmqJa2|Ni_hd zQA)ty@oKd~D1neGRbZ*stXaWq5>i0O zRB#F}unXb|FiQfFLL)U)OE=KW8W+vgy@2b2bHP9K7Nq+D_7x`s%!O;z@p2^^L2<ijgaCbT%~{@hT|!oi84aXBjcoSnR*le1c37b6nJu_m?9i5{3f%b zWbQRQQL-qR7uFNU;+2HRJ*t`sqBt1XNn%0`-p0y^q$rLDBNjcaagQpZfp|!Z21_b< zJRY1YfRchJnHBZGwlIwhQ^ymSNG_4clSr8uz>-RFnGnbf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Dqs`A;yOh zPn#8LVQ#X30IAs_0~sNfkihy95EfkRZ8ujhl&g*W{Gq&?Q-%VJ=}X8sWY8hx#4sMA zy|-YdRKpAemBlwoG$8G%cYMI048t-Bi6*8a0*JM^6c_8q@Zo4CB|w)PfJ!Oof^48W z3G>J4s|0AkP%&M2Ax8scG&GF40lZNE4%8o9grbeq{G*k;IqnXLl ztL%t@`8V&x8LZ&4C2~q&#d5h2e%-)|9VWnhd4&RpQ9@`FXdvPuoRnyk)M|F67?jq2DM;=JsSKu;=mKICStSham^@BGN1>42Vhz;}w0xtOVeCqYk$awW9{L-b?;)~yd^w8$i^+YqhIO<#+kATHeu6{${*B7Bjh zqq{}XX>?trh$RMeOc?r1q=?ebaKlsk9nnUlrHzmf0e6KO0gDw>6FSG0QlyC(<628a z-FDU}mAcz9I&utjGVscwvq}X~xmDxFaVfO1p<59842kvCJ!8x#v80h@HfnL91lTXc x7oMxtrNRA3f&KCPcz!%To*&PT=g0Ho`SJXCemp;(AJ2C_{|}cIV^;v60046ZX&e9m literal 0 HcmV?d00001 diff --git a/parsers/what3words/what3words.html b/parsers/what3words/what3words.html new file mode 100644 index 00000000..4249f6d9 --- /dev/null +++ b/parsers/what3words/what3words.html @@ -0,0 +1,102 @@ + + + + + + + diff --git a/parsers/what3words/what3words.js b/parsers/what3words/what3words.js new file mode 100644 index 00000000..c1d8d9bf --- /dev/null +++ b/parsers/what3words/what3words.js @@ -0,0 +1,116 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var What3Words = require('geo.what3words'); + + function what3wordsNode(n) { + RED.nodes.createNode(this, n); + this.lang = n.lang || "en"; + var credentials = RED.nodes.getCredentials(n.id); + if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } else { this.error("No what3words API key set"); } + this.w3w = new What3Words(this.pushkey); + var node = this; + 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 }) + .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 (typeof (msg.payload) === "string") { + if (msg.payload.split(",").length === 2) { // see if it's 2 comma separated words + node.w3w.positionToWords({ position:msg.payload, 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.payload.match(w3)) { // see if it's 3 dot separated words + node.w3w.wordsToPosition({ words:msg.payload }) + .then(function(response) { + if (!msg.hasOwnProperty("location")) { msg.location = {}; } + msg.location.lat = Number(response.split(",")[0]); + msg.location.lon = Number(response.split(",")[1]); + node.send(msg); + }) + .catch(function(err) { + node.warn(err) + }); + } else if (msg.payload.match(w1)) { // see if it's a *Oneword + node.w3w.wordsToPosition({ words:msg.payload }) + .then(function(response) { + if (!msg.hasOwnProperty("location")) { msg.location = {}; } + msg.location.lat = Number(response.split(",")[0]); + msg.location.lon = Number(response.split(",")[1]); + msg.payload = response; + node.send(msg); + }) + .catch(function(err) { + node.warn(err); + }); + } else { node.warn("No useable data found. See info."); } + } else { node.warn("No useable data found. See info."); } + }); + } + RED.nodes.registerType("what3words", what3wordsNode); + + var querystring = require('querystring'); + + RED.httpAdmin.get('/what3words/:id', function(req, res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({hasPassword:(credentials.pushkey && credentials.pushkey !== "")})); + } else { + res.send(JSON.stringify({})); + } + }); + + RED.httpAdmin.delete('/what3words/:id', function(req, res) { + RED.nodes.deleteCredentials(req.params.id); + res.send(200); + }); + + RED.httpAdmin.post('/what3words/:id', function(req, res) { + var body = ""; + req.on('data', function(chunk) { + body += chunk; + }); + req.on('end', function() { + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id) || {}; + if (newCreds.pushkey === "") { + delete credentials.pushkey; + } else { + credentials.pushkey = newCreds.pushkey || credentials.pushkey; + } + RED.nodes.addCredentials(req.params.id, credentials); + res.send(200); + }); + }); +}