~mil/mepo-devel

Add geohashing script v1 PROPOSED

Bobby Hamblin: 1
 Add geohashing script

 1 files changed, 23 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/mepo-devel/patches/36811/mbox | git am -3
Learn more about email & git

[PATCH] Add geohashing script Export this patch

run script to add pin at current day geohash in the last graticule you filedumped in. fully 30W compliant (more at https://geohashing.site)

---
 scripts/mepo_geohash.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100755 scripts/mepo_geohash.sh

diff --git a/scripts/mepo_geohash.sh b/scripts/mepo_geohash.sh
new file mode 100755
index 0000000..0a4cc51
--- /dev/null
+++ b/scripts/mepo_geohash.sh
@@ -0,0 +1,23 @@
#!/usr/bin/env osh

# Obtain graticule data from mepo
  GRATICULE_LAT=$(awk '/^prefset_n lat/{print $NF}' $XDG_CACHE_HOME/mepo/savestate | sed 's/\.[^[:blank:]]*//')
  GRATICULE_LON=$(awk '/^prefset_n lon/{print $NF}' $XDG_CACHE_HOME/mepo/savestate | sed 's/\.[^[:blank:]]*//')

# 30W Compliance
  DATE=$(date +%Y-%m-)$(date +%d)
  if (($GRATICULE_LON > -30)); then
    DATE=$(($DATE-1))
  fi

# Run seed through md5, split in half
  HASH=$DATE-$(curl -s http://geo.crox.net/djia/$DATE)
  LAT=$(echo -n $HASH | md5sum | tr -d '-' | tr '[a-z]' '[A-Z]' | cut -b 1-16 )
  LON=$(echo -n $HASH | md5sum | tr -d '-' | tr '[a-z]' '[A-Z]' | cut -b 17-32)

# Convert halves to decimal
  LAT=$GRATICULE_LAT$(echo "ibase=16; 0.$LAT" | bc | cut -b 1-5)
  LON=$GRATICULE_LON$(echo "ibase=16; 0.$LON" | bc | cut -b 1-5)

# Add point to mepo and open
  echo "pin_add 7 0 $LAT $LON geohash;" | mepo -i
-- 
2.38.1