Skip to content

Instantly share code, notes, and snippets.

View typebrook's full-sized avatar

Hsieh Chin Fan typebrook

View GitHub Profile
@typebrook
typebrook / geojson_for_tippecanoe.sh
Last active July 31, 2022 00:23
[contour-tippecannoe] Script to add extra info into contour geojson for tippecannoe #tile #mapbox #tippecanoe #contour
#!/bin/sh
for size in 500 200 100 50 20 10 ; do
if [ $size -ne 10 ]; then
rm $size"m.geojson"
fi
awk -v size=$size 'BEGIN{
ele[500]=9
ele[200]=10
@typebrook
typebrook / MBTilesServer.kt
Last active January 12, 2024 08:46
How to make MBTiles valid on Mapbox Android SDK #mbtiles #android #mapbox
package com.example.sample.offline
import android.util.Log
import java.io.BufferedReader
import java.io.ByteArrayOutputStream
import java.io.FileNotFoundException
import java.io.PrintStream
import java.net.ServerSocket
import java.net.Socket
import kotlin.math.pow
@typebrook
typebrook / config.json
Last active March 19, 2020 07:07
[tile-server] klokan tileserver config for custom style #tile-host
{
"options": {
"paths": {
"root": "",
"fonts": "glyphs",
"sprites": "sprites",
"styles": "styles",
"mbtiles": "data"
},
"formatEncoding": {
@typebrook
typebrook / command.sh
Last active March 19, 2020 07:07
[tile-server] Imposm/t-rex config #tile-host #t-rex
# stop postgres
sudo pkill -u postgres
# launch a postgis container with default user "postgres"
docker run --name rex -e POSTGRES_PASSWORD=rex -d mdillon/postgis
# into psql with identity postgres
docker run -it --link rex:postgres --rm mdillon/postgis sh -c 'exec psql -h rex -p 5432 -U postgres' sh -c 'exec psql -h rex -p 5432 -U postgres'
# launch a postgis container with db called rex
@typebrook
typebrook / findme.html
Last active March 18, 2020 04:28
[findme.help] Only shows action buttons after getting location #html #findme #rescue
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Geo Locationing Service">
<meta name="author" content="Edwin Wang">
<meta property="og:title" content="FindMe 座標定位" />
<meta property="og:description" content="透過網頁提供座標定位服務">
<meta property="og:type" content="website" />
@typebrook
typebrook / Makefile
Last active July 31, 2022 00:23
[rudymap-wiki] Parse rudymap mapsforge style file and create a Markdown #mapsforge #rudymap
all: detail-layers detail-cats
MOI_OSM.xml:
curl -o $@ https://raw.githubusercontent.com/alpha-rudy/taiwan-topo/master/styles/mapsforge_style/MOI_OSM.xml
rudymap.json: MOI_OSM.xml
xq . <$< >$@
layers: rudymap.json
@jq -r '.rendertheme.stylemenu.layer | map(select(has("overlay"))) + map(select(has("overlay") | not)) | .[] | .["@id"]' $< | tee $@
@typebrook
typebrook / geojson2gpx.sh
Last active July 31, 2022 00:23
[geojson-script] Transform geojson from GoPro video to gpx format, jq needed #geojson #gpx #garmin
#!/bin/bash
paste <(jq '.geometry.coordinates[]' $1 -c | sed -r 's/\[|\]//g' \
|sed -r 's/^([^,]+),([^,]+),.*/<trkpt lat="\2" lon="\1">/') \
<(jq '.properties.AbsoluteUtcMicroSec[]' $1 \
| sed -r 's/(.*)(.{3})$$/\1,\2/' \
| xargs -I time date -d @time +"%Y-%m-%dT%H:%M:%S") |\
# If you want to keep points at the same seconds, comment out the next line
uniq -f3 |\
sed -r 's/\t(.*)/<time>\1<\/time><\/trkpt>/' |\
@typebrook
typebrook / Makefile
Last active April 22, 2021 07:25
[taipower-data] Compare Taipower street light data with geojson file #gdal
#.PHONY: road.[^g]*
BUFFER = 10
all: overlapped.geojson
taiwan-latest.osm.pbf:
curl -o $@ http://download.geofabrik.de/asia/taiwan-latest.osm.pbf
clean:
@typebrook
typebrook / README.md
Last active April 4, 2024 14:00
A bash script for gist management #bash #gist