FromGeohash.mjs 993 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * @author gchq77703 []
  3. * @copyright Crown Copyright 2018
  4. * @license Apache-2.0
  5. */
  6. import Operation from "../Operation";
  7. import geohash from "ngeohash";
  8. /**
  9. * From Geohash operation
  10. */
  11. class FromGeohash extends Operation {
  12. /**
  13. * FromGeohash constructor
  14. */
  15. constructor() {
  16. super();
  17. this.name = "From Geohash";
  18. this.module = "Default";
  19. this.description = "Converts Geohash strings into Lat / Long coordinates. For example, <code>ww8p1r4t8</code> becomes <code>37.8324,112.5584</code>.";
  20. this.infoURL = "https://en.wikipedia.org/wiki/Geohash";
  21. this.inputType = "string";
  22. this.outputType = "string";
  23. this.args = [
  24. ];
  25. }
  26. /**
  27. * @param {string} input
  28. * @param {Object[]} args
  29. * @returns {string}
  30. */
  31. run(input, args) {
  32. const coords = geohash.decode(input);
  33. return [coords.latitude, coords.longitude].join(",");
  34. }
  35. }
  36. export default FromGeohash;