mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
lots of little node edits to clean up jsHint "errors"
This commit is contained in:
@@ -36,13 +36,13 @@ module.exports = function(RED) {
|
||||
node.send(msg);
|
||||
}
|
||||
else {
|
||||
var lat = msg.location.lat;
|
||||
var lon = msg.location.lon;
|
||||
var len = parseInt(msg.location.precision || msg.location.payload || 9);
|
||||
if (len < 1) { len = 1; }
|
||||
if (len > 9) { len = 9; }
|
||||
if (lat && lon) {
|
||||
msg.location.geohash = geohash.encode(lat, lon, len);
|
||||
var lt = msg.location.lat;
|
||||
var ln = msg.location.lon;
|
||||
var le = parseInt(msg.location.precision || msg.location.payload || 9);
|
||||
if (le < 1) { le = 1; }
|
||||
if (le > 9) { le = 9; }
|
||||
if (lt && ln) {
|
||||
msg.location.geohash = geohash.encode(lt, ln, le);
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,9 @@ module.exports = function(RED) {
|
||||
// try to decode it...
|
||||
var regexp = new RegExp('^[a-z0-9]{1,9}$'); // can only contain a-z or 0-9 and length 1-9
|
||||
if (regexp.test(msg.payload)) {
|
||||
var pos = geohash.decode(msg.payload);
|
||||
msg.payload = { lat:round(pos.latitude,5), lon:round(pos.longitude,5) };
|
||||
msg.payload.error = { lat:round(pos.error.latitude,5), lon:round(pos.error.longitude,5) };
|
||||
var po = geohash.decode(msg.payload);
|
||||
msg.payload = { lat:round(po.latitude,5), lon:round(po.longitude,5) };
|
||||
msg.payload.error = { lat:round(po.error.latitude,5), lon:round(po.error.longitude,5) };
|
||||
node.send(msg);
|
||||
}
|
||||
else if (msg.payload.indexOf(",") !== -1) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-geohash",
|
||||
"version" : "0.0.2",
|
||||
"version" : "0.0.3",
|
||||
"description" : "A Node-RED node to encode and decode lat,lon pairs to a geohash.",
|
||||
"dependencies" : {
|
||||
"ngeohash" : "0.6.0"
|
||||
|
Reference in New Issue
Block a user