From 00b136155183ae522ca458e540a8cf29bf525e74 Mon Sep 17 00:00:00 2001 From: typebrook Date: Thu, 27 Feb 2020 16:32:37 +0800 Subject: update --- Makefile | 2 +- alias | 4 +- misc/cron | 2 +- scripts/check_upstream | 25 ------ scripts/csv.move_column | 18 ---- scripts/csv.reorder | 17 ---- scripts/csv2geojson | 46 ---------- scripts/gpx/footer | 1 - scripts/gpx/gpx.check.py | 85 ------------------ scripts/gpx/gpx.merge_gpx.sh | 5 -- scripts/gpx/gpx.merge_trk.sh | 4 - scripts/gpx/header | 10 --- scripts/load-settings.sh | 24 ------ scripts/match-road.sh | 148 -------------------------------- scripts/mvt_decode.py | 11 --- scripts/osm/josm_install.sh | 8 -- scripts/osm/osm | 17 ---- scripts/osm/osm.api.changeset.add | 10 --- scripts/osm/osm.api.changeset.close | 3 - scripts/osm/osm.api.changeset.create | 21 ----- scripts/osm/osm.api.changeset.update | 7 -- scripts/osm/osm.api.changeset.upload | 6 -- scripts/osm/osm.api.fetch | 6 -- scripts/osm/osm.api.fetch.full | 5 -- scripts/osm/osm.api.fetch.history | 6 -- scripts/osm/osm.api.member.relation | 4 - scripts/osm/osm.api.referenced.relation | 6 -- scripts/osm/osm.api.referenced.way | 5 -- scripts/osm/osm.api.upload.to | 12 --- scripts/osm/osm.file.get | 4 - scripts/osm/osm.file.get.full | 4 - scripts/osm/osm.file.query | 4 - scripts/osm/osm.goto | 3 - scripts/osm/osm.help | 34 -------- scripts/osm/osm.list.ids | 3 - scripts/osm/osm.list.tag | 10 --- scripts/osm/osm.list.tags | 15 ---- scripts/osm/osm.member.relation | 8 -- scripts/osm/osm.osc.by_member | 31 ------- scripts/osm/osm.osc.by_tag | 45 ---------- scripts/osm/osm.osm.remove | 9 -- scripts/osm/osm.pbf.update | 39 --------- scripts/osm/osm.query | 3 - scripts/osm/sequence_number.sh | 22 ----- scripts/refresh-todo.sh | 5 -- scripts/sync.sh | 6 -- scripts/upload-github-release-asset.sh | 84 ------------------ scripts/yaoren.sh | 16 ---- tigrc | 2 +- tools/check_upstream | 25 ++++++ tools/csv.move_column | 18 ++++ tools/csv.reorder | 17 ++++ tools/csv2geojson | 46 ++++++++++ tools/gpx/footer | 1 + tools/gpx/gpx.check.py | 85 ++++++++++++++++++ tools/gpx/gpx.merge_gpx.sh | 5 ++ tools/gpx/gpx.merge_trk.sh | 4 + tools/gpx/header | 10 +++ tools/load-settings.sh | 24 ++++++ tools/match-road.sh | 148 ++++++++++++++++++++++++++++++++ tools/mvt_decode.py | 11 +++ tools/osm/josm_install.sh | 8 ++ tools/osm/osm | 17 ++++ tools/osm/osm.api.changeset.add | 10 +++ tools/osm/osm.api.changeset.close | 3 + tools/osm/osm.api.changeset.create | 21 +++++ tools/osm/osm.api.changeset.update | 7 ++ tools/osm/osm.api.changeset.upload | 6 ++ tools/osm/osm.api.fetch | 6 ++ tools/osm/osm.api.fetch.full | 5 ++ tools/osm/osm.api.fetch.history | 6 ++ tools/osm/osm.api.member.relation | 4 + tools/osm/osm.api.referenced.relation | 6 ++ tools/osm/osm.api.referenced.way | 5 ++ tools/osm/osm.api.upload.to | 12 +++ tools/osm/osm.file.get | 4 + tools/osm/osm.file.get.full | 4 + tools/osm/osm.file.query | 4 + tools/osm/osm.goto | 3 + tools/osm/osm.help | 34 ++++++++ tools/osm/osm.list.ids | 3 + tools/osm/osm.list.tag | 10 +++ tools/osm/osm.list.tags | 15 ++++ tools/osm/osm.member.relation | 8 ++ tools/osm/osm.osc.by_member | 31 +++++++ tools/osm/osm.osc.by_tag | 45 ++++++++++ tools/osm/osm.osm.remove | 9 ++ tools/osm/osm.pbf.update | 39 +++++++++ tools/osm/osm.query | 3 + tools/osm/sequence_number.sh | 22 +++++ tools/refresh-todo.sh | 5 ++ tools/sync.sh | 6 ++ tools/upload-github-release-asset.sh | 84 ++++++++++++++++++ tools/yaoren.sh | 16 ++++ 94 files changed, 860 insertions(+), 860 deletions(-) delete mode 100755 scripts/check_upstream delete mode 100755 scripts/csv.move_column delete mode 100755 scripts/csv.reorder delete mode 100755 scripts/csv2geojson delete mode 100644 scripts/gpx/footer delete mode 100755 scripts/gpx/gpx.check.py delete mode 100755 scripts/gpx/gpx.merge_gpx.sh delete mode 100755 scripts/gpx/gpx.merge_trk.sh delete mode 100644 scripts/gpx/header delete mode 100755 scripts/load-settings.sh delete mode 100755 scripts/match-road.sh delete mode 100644 scripts/mvt_decode.py delete mode 100755 scripts/osm/josm_install.sh delete mode 100644 scripts/osm/osm delete mode 100755 scripts/osm/osm.api.changeset.add delete mode 100755 scripts/osm/osm.api.changeset.close delete mode 100755 scripts/osm/osm.api.changeset.create delete mode 100755 scripts/osm/osm.api.changeset.update delete mode 100755 scripts/osm/osm.api.changeset.upload delete mode 100755 scripts/osm/osm.api.fetch delete mode 100755 scripts/osm/osm.api.fetch.full delete mode 100755 scripts/osm/osm.api.fetch.history delete mode 100755 scripts/osm/osm.api.member.relation delete mode 100755 scripts/osm/osm.api.referenced.relation delete mode 100755 scripts/osm/osm.api.referenced.way delete mode 100755 scripts/osm/osm.api.upload.to delete mode 100755 scripts/osm/osm.file.get delete mode 100755 scripts/osm/osm.file.get.full delete mode 100755 scripts/osm/osm.file.query delete mode 100755 scripts/osm/osm.goto delete mode 100755 scripts/osm/osm.help delete mode 100755 scripts/osm/osm.list.ids delete mode 100755 scripts/osm/osm.list.tag delete mode 100755 scripts/osm/osm.list.tags delete mode 100755 scripts/osm/osm.member.relation delete mode 100755 scripts/osm/osm.osc.by_member delete mode 100755 scripts/osm/osm.osc.by_tag delete mode 100755 scripts/osm/osm.osm.remove delete mode 100755 scripts/osm/osm.pbf.update delete mode 100755 scripts/osm/osm.query delete mode 100755 scripts/osm/sequence_number.sh delete mode 100755 scripts/refresh-todo.sh delete mode 100755 scripts/sync.sh delete mode 100755 scripts/upload-github-release-asset.sh delete mode 100755 scripts/yaoren.sh create mode 100755 tools/check_upstream create mode 100755 tools/csv.move_column create mode 100755 tools/csv.reorder create mode 100755 tools/csv2geojson create mode 100644 tools/gpx/footer create mode 100755 tools/gpx/gpx.check.py create mode 100755 tools/gpx/gpx.merge_gpx.sh create mode 100755 tools/gpx/gpx.merge_trk.sh create mode 100644 tools/gpx/header create mode 100755 tools/load-settings.sh create mode 100755 tools/match-road.sh create mode 100644 tools/mvt_decode.py create mode 100755 tools/osm/josm_install.sh create mode 100644 tools/osm/osm create mode 100755 tools/osm/osm.api.changeset.add create mode 100755 tools/osm/osm.api.changeset.close create mode 100755 tools/osm/osm.api.changeset.create create mode 100755 tools/osm/osm.api.changeset.update create mode 100755 tools/osm/osm.api.changeset.upload create mode 100755 tools/osm/osm.api.fetch create mode 100755 tools/osm/osm.api.fetch.full create mode 100755 tools/osm/osm.api.fetch.history create mode 100755 tools/osm/osm.api.member.relation create mode 100755 tools/osm/osm.api.referenced.relation create mode 100755 tools/osm/osm.api.referenced.way create mode 100755 tools/osm/osm.api.upload.to create mode 100755 tools/osm/osm.file.get create mode 100755 tools/osm/osm.file.get.full create mode 100755 tools/osm/osm.file.query create mode 100755 tools/osm/osm.goto create mode 100755 tools/osm/osm.help create mode 100755 tools/osm/osm.list.ids create mode 100755 tools/osm/osm.list.tag create mode 100755 tools/osm/osm.list.tags create mode 100755 tools/osm/osm.member.relation create mode 100755 tools/osm/osm.osc.by_member create mode 100755 tools/osm/osm.osc.by_tag create mode 100755 tools/osm/osm.osm.remove create mode 100755 tools/osm/osm.pbf.update create mode 100755 tools/osm/osm.query create mode 100755 tools/osm/sequence_number.sh create mode 100755 tools/refresh-todo.sh create mode 100755 tools/sync.sh create mode 100755 tools/upload-github-release-asset.sh create mode 100755 tools/yaoren.sh diff --git a/Makefile b/Makefile index 77e60d9..fcd6c5d 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,4 @@ wiki: fi crontab: - (crontab -l 2>/dev/null; cat scripts/*.cron) | crontab - + (crontab -l 2>/dev/null; cat tools/*.cron) | crontab - diff --git a/alias b/alias index ebd31c9..c32500b 100644 --- a/alias +++ b/alias @@ -115,7 +115,7 @@ upload_tig() { # about custom settings alias cds="cd $SETTING_DIR" -alias cdss="cd $SETTING_DIR/scripts" +alias cdss="cd $SETTING_DIR/tools" alias chs="cd $SETTING_DIR && tig status" # about vimwiki @@ -253,7 +253,7 @@ alias mm='mkvmerge -o out.webm -w 01.webm + 02.webm' alias du='ncdu' alias we='weechat' mvt_decode() { - python3 $SETTING_DIR/scripts/mvt_decode.py $1 | tr \' \" | sed 's/True/true/g' | jq . + python3 $SETTING_DIR/tools/mvt_decode.py $1 | tr \' \" | sed 's/True/true/g' | jq . } big52utf8() { iconv -f BIG-5 -t UTF-8 diff --git a/misc/cron b/misc/cron index aeb498a..64fe9a7 100644 --- a/misc/cron +++ b/misc/cron @@ -1,2 +1,2 @@ # update Taiwan OSM replication -0 7 * * * cd data && $HOME/settings/scripts/osm/osm.pbf.update taiwan-latest.osm.pbf >> log +0 7 * * * cd data && $HOME/settings/tools/osm/osm.pbf.update taiwan-latest.osm.pbf >> log diff --git a/scripts/check_upstream b/scripts/check_upstream deleted file mode 100755 index 3313e5b..0000000 --- a/scripts/check_upstream +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/bash - -# This script is for repo forked from others -# check $1(repo) if upstream branch origin/master is -# ahead of local branch $2(default to dev) - -if [ ! -d "$1" ]; then - return 0 -fi - -head='dev' -if [ $# -eq 2 ] -then - head=$2 -fi - -cd "$1" && \ -git fetch origin && \ -if ! git rev-list "$head" | grep "$(git rev-parse origin/master)" > /dev/null -then - [[ $(git pull my) == 'Alrady up to date.' ]] || \ - echo "New commit at" "$1" -fi - -echo "$(date)" check "$1" >> "$SETTING_DIR/log" diff --git a/scripts/csv.move_column b/scripts/csv.move_column deleted file mode 100755 index a62701f..0000000 --- a/scripts/csv.move_column +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/bash - -# show each field with index in csv -echo -------------- > /dev/tty -head -1 < $1 | sed 's/,/ /g' | awk '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty -echo -------------- > /dev/tty -echo > /dev/tty - -# get index of lon/lat column -read -p "Move which column? " origin_col -read -p "To which index? " new_col - -cat $1 | -# move lon and lat to the first and second column -awk -F',' -v OFS="," -v origin_th=$origin_col -v new_th=$new_col '\ - {for (i=1; i<= NF; i++) if (i == new_th) printf $origin_th OFS $i OFS; else if (i == origin_th); else printf $i OFS; print ""}\ - ' |\ -sed 's/,$//g' diff --git a/scripts/csv.reorder b/scripts/csv.reorder deleted file mode 100755 index 8a64239..0000000 --- a/scripts/csv.reorder +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/bash - -# show each field with index in csv -echo -------------- > /dev/tty -head -1 < $1 | awk -F',' '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty -echo -------------- > /dev/tty -echo > /dev/tty - -read -p "type column numbers by new order, like 3 2 1: " order - -arrange=$(echo $order | sed -r 's/([^ ]+)/$\1/g' | tr ' ' ',') - -cat $1 |\ -awk -F',' "BEGIN{OFS=\",\"}{print $arrange}" |\ -tee /tmp/csv - -echo "Also copied to /tmp/csv" > /dev/tty diff --git a/scripts/csv2geojson b/scripts/csv2geojson deleted file mode 100755 index 028aed7..0000000 --- a/scripts/csv2geojson +++ /dev/null @@ -1,46 +0,0 @@ -#! /bin/bash - -# -s to skip specify columns of longitude and latitude -for i in "$@" -do -case $i in - -s) - lon_col=0; lat_col=1 - shift;; - - *) - csv=$i - shift;; -esac -done - -# if no -s option, just read from input -if [ "$lon_col" != "0" ]; then - # show each field with index in csv - echo -------------- > /dev/tty - head -1 < $csv | awk -F',' '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty - echo -------------- > /dev/tty - echo > /dev/tty - - # get index of lon/lat column - read -p "Number of latitude column: " lat_col - read -p "Number of longitude column: " lon_col -fi - -cat $csv | -# move lon and lat to the first and second column -awk -F',' -v lon_th=$lon_col -v lat_th=$lat_col '\ - BEGIN{OFS=","}\ - {printf $lon_th "," $lat_th; for (i=1; i<= NF; i++) if (i != lat_th && i != lon_th) printf "," $i; print ""}\ - ' |\ -# change csv into array format, like [lon, lat, "field1", field2...] -sed 's/[^,]*/"\0"/g; s/.*/[\0]/g' |\ -# wrap other fields as a json object, like [lon, lat, {...}] -jq -s '.[0][2:] as $fields | .[1:][] | [.[0], .[1], ([$fields, .[2:]] | transpose | map({(.[0]): .[1]}) | add)]' |\ -# create array of geojson point features -jq '{"type": "Feature", "properties": .[2], "geometry":{ "type": "Point", "coordinates": [(.[0] | tonumber), (.[1] | tonumber)] } }' |\ -# wrap features as geojson format -jq -s '{"type": "FeatureCollection", "features": .}' |\ -tee /tmp/geojson - -echo stored into /tmp/geojson > /dev/tty diff --git a/scripts/gpx/footer b/scripts/gpx/footer deleted file mode 100644 index d0759c0..0000000 --- a/scripts/gpx/footer +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scripts/gpx/gpx.check.py b/scripts/gpx/gpx.check.py deleted file mode 100755 index 10be97c..0000000 --- a/scripts/gpx/gpx.check.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -import argparse -import copy -import fileinput -from osgeo import ogr -import osr -import urllib.parse - -def rewrite_gpx(filename): - for line in fileinput.input(filename, inplace=True): - if fileinput.isfirstline() and "'" in line: - line = '' - if fileinput.filelineno() == 2 and "version" not in line: - line = line.replace('= threshold: - if not flag: - print(f'{filename} has problem, the following urls shows the points with distance far from {threshold}m:') - print() - flag = True - if add_prefix: - dir = os.path.dirname(filename) - if dir: - dir += '/' - os.rename(filename, f'{dir}invalid_{os.path.basename(filename)}') - - geojson = '{{"type": "LineString", "coordinates": [[{}, {}], [{}, {}]]}}'.format( - geom1.GetX(), geom1.GetY(), - geom2.GetX(), geom2.GetY() - ) - encoded = urllib.parse.quote(geojson) - print('http://geojson.io/#data=data:application/json,{}'.format(encoded)) - print() - else: - break - trkpt = nextTrkpt - -def main(argv): - parser = argparse.ArgumentParser() - parser.add_argument('file', help="you can add multiple gpx files at the same time", nargs='+') - parser.add_argument("-i", help="add prefix to invalid files", action="store_true") - parser.add_argument("-d", help="distance of tolerance(m), 100 by default", dest="distance", default=100) - args = parser.parse_args() - for file in args.file: - check_valid(file, float(args.distance), args.i) - -if __name__ == '__main__': - main(sys.argv) diff --git a/scripts/gpx/gpx.merge_gpx.sh b/scripts/gpx/gpx.merge_gpx.sh deleted file mode 100755 index 4b024a7..0000000 --- a/scripts/gpx/gpx.merge_gpx.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -GPX_DIR=$(dirname $0) - -sed '// p' -nr | cat $GPX_DIR/header - $GPX_DIR/footer diff --git a/scripts/gpx/gpx.merge_trk.sh b/scripts/gpx/gpx.merge_trk.sh deleted file mode 100755 index c3a72d4..0000000 --- a/scripts/gpx/gpx.merge_trk.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -sed '//,/<\/name>/ d; /<\/trk>/ d; /<\/gpx>/ i \ \ <\/trk>' |\ -awk '// && !x {print " \n combined_trk"; x=1} 1' diff --git a/scripts/gpx/header b/scripts/gpx/header deleted file mode 100644 index 1912e8b..0000000 --- a/scripts/gpx/header +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - Garmin International - - - - diff --git a/scripts/load-settings.sh b/scripts/load-settings.sh deleted file mode 100755 index 07c8791..0000000 --- a/scripts/load-settings.sh +++ /dev/null @@ -1,24 +0,0 @@ -if [[ -z "$SETTING_DIR" ]]; then - SETTING_DIR=$HOME/settings -fi - -# load custom aliases -source $SETTING_DIR/alias - -# Add custom scripts into PATH -PATH=$PATH:$SETTING_DIR/scripts -find $SETTING_DIR/scripts -type d | sed 1d |\ -while read dir; do - PATH=$PATH:$dir -done - -# sync with important git repos -$SETTING_DIR/scripts/sync.sh - -# load custom functions -OSM_UTIL_DIR=$SETTING_DIR/scripts/osm -source $OSM_UTIL_DIR/osm - -# go -PATH=$PATH:$HOME/go/bin - diff --git a/scripts/match-road.sh b/scripts/match-road.sh deleted file mode 100755 index d9beaae..0000000 --- a/scripts/match-road.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash -# -# Author: Pham -# -# This script accepts a single GPX file as parameter and -# output the processed GPX body to STDOUT, using Mapbox Map Matching API v4. -# read doc at: https://docs.mapbox.com/api/legacy/map-matching-v4/ -# -# Example: -# -# match-road.sh raw.gpx > new.gpx -# -# Hint: -# -# Remember to put Mapbox Access Token at the top! - -#set -x -set -e - -# put yout Mapbox token here -ACCESS_TOKEN=$(cat ~/settings/tokens/mapbox) -# number of coordinates for each Mapbox Map Matching API request, Maximum value is 100 -LIMIT=100 -# define the lowest confidence of accepted matched points -THRESHOLD=0.0001 - -if [[ -z $1 ]]; then echo "You need to give a gpx file!"; exit 1; fi -ORIGIN_DATA=/tmp/$(basename $1).origin -RESPONSES=/tmp/$(basename $1).responses && true > $RESPONSES -MATCHED=/tmp/$(basename $1).matched - -# extract data from the given gpx file -# only keep first point and remove the rest which in the same "second" -# input: [gpx format] -# output: [121.0179739,14.5515336] 1984-01-01T08:00:46 -get_data() { - sed -nr '// {H; /<\/trkpt>/ {x; s/\n/ /g; p; s/.*//; x}}' $1 | - sed -nr 'h; s/.*lon="([^"]+).*/\1/; H; g - s/.*lat="([^"]+).*/\1/; H; g - # If trkpt has no time, leave it blank - /time/ { - s/.*