2018-08-26 14:27:15 +01:00
|
|
|
/**
|
|
|
|
* @author gchq77703 []
|
|
|
|
* @copyright Crown Copyright 2018
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Operation from "../Operation";
|
|
|
|
import geohash from "ngeohash";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* From Geohash operation
|
|
|
|
*/
|
|
|
|
class FromGeohash extends Operation {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FromGeohash constructor
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "From Geohash";
|
|
|
|
this.module = "Default";
|
|
|
|
this.description = "Converts Geohash strings into Lat / Long coordinates. For example, <code>ww8p1r4t8</code> becomes <code>37.8324,112.5584</code>.";
|
|
|
|
this.infoURL = "https://en.wikipedia.org/wiki/Geohash";
|
|
|
|
this.inputType = "string";
|
|
|
|
this.outputType = "string";
|
|
|
|
this.args = [
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} input
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
run(input, args) {
|
2018-08-26 18:06:02 +01:00
|
|
|
const coords = geohash.decode(input);
|
|
|
|
return [coords.latitude, coords.longitude].join(",");
|
2018-08-26 14:27:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FromGeohash;
|