Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Harvey andrewharvey

View GitHub Profile
@andrewharvey
andrewharvey / index.md
Last active Jun 16, 2021
Comparison of point and box spatial index libraries for JavaScript
View index.md
Library Static / Dynamic Cartesian / Geographic kNN Index containing points Index containing boxes Within radius
rbush dynamic 🗺️ cartesian ✔️ ✔️
rbush-knn dynamic 🗺️ cartesian ✔️ ✔️ ✔️ ✔️
kdbush static 🗺️ cartesian ✔️ ✔️
geokdbush static 🌏 geo ✔️ ✔️ ✔️
flatbush static 🗺️ cartesian ✔️ ✔️ ✔️ ✔️
geoflatbush static 🌏 geo ✔️ :heavy_che
@andrewharvey
andrewharvey / inplace-mbtiles2osmand.sh
Last active Apr 20, 2021
In-place conversion of an mbtiles SQLite3 database into an osmand offline tiles SQLite3 database.
View inplace-mbtiles2osmand.sh
#!/bin/sh
# To the extent possible under law, the person who associated CC0
# with this work has waived all copyright and related or neighboring
# rights to this work.
# http://creativecommons.org/publicdomain/zero/1.0/
SCRIPT_DIR=`dirname $0`
if [ -e $1 ] ; then
@andrewharvey
andrewharvey / listFontsByStyle.js
Last active Apr 20, 2021
Lists fonts used within a Mapbox account, which fonts each Style is using, and which Styles are using each font. Useful for knowing which fonts you can clear out of your account to keep under the 100 fonts limit.
View listFontsByStyle.js
#!/usr/bin/env node
/* eslint-disable */
const MapboxClient = require('.');
const MapboxStyles = require('./services/styles');
const MapboxFonts = require('./services/fonts');
const fs = require('fs');
const fontsService = MapboxFonts({ accessToken: process.env.MAPBOX_ACCESS_TOKEN });
@andrewharvey
andrewharvey / countTiles.py
Created Jan 25, 2012
Given a WGS84 bounding box and an OSM tile zoom range calculates a total number of tiles.
View countTiles.py
#!/usr/bin/python
# This script should be considered CC0 licensed
# the deg2num function is from http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#lon.2Flat_to_tile_numbers_2
import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
@andrewharvey
andrewharvey / polygon-with-a-hole.geojson
Created Mar 10, 2018
A GeoJSON Polygon with a hole
View polygon-with-a-hole.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View polygon-with-a-hole.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View steer-clear.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewharvey
andrewharvey / logrotatecat
Created Dec 15, 2011
cat's a bunch of log rotate log files in correct order
View logrotatecat
#!/bin/bash
# using,
#
# ./logrotatecat access.log
#
# inside a directory of log rotate logs in a form like
#
# access.log
# access.log.1
@andrewharvey
andrewharvey / feed.sh
Created Jul 21, 2020
ArcGIS Rest Services Listing as FeedJSON
View feed.sh
#!/bin/sh
wget -O - 'http://data.actmapi.act.gov.au/arcgis/rest/services/actmapi/?f=pjson' | jq '{"version": "https://jsonfeed.org/version/1", "title": "data.actmapi services", "home_page_url": "http://data.actmapi.act.gov.au/arcgis/rest/services/actmapi/?f=pjson", "items": [.services[].name | {"id": ., "content_text": .}]}' > feed.json
@andrewharvey
andrewharvey / LG360.StartInterval.sh
Created Jun 27, 2020
Termux Shortcuts to start/stop LG360 Mapillary Interval Capture. Place contents in termux home .shortcuts directory. You can then add a shortcut to these scripts to the homescreen as a widget.
View LG360.StartInterval.sh
!/bin/sh
setoptions=`curl \ -X POST \ --header 'Content-Type: application/json' \ --data '{ "name": "camera.setOptions", "parameters": { "options": { "captureMode": "interval", "captureInterval": 2 } }}' \ http://192.168.43.1:6624/osc/commands/execute | jq '.state'`
startcapture=`curl \ -X POST \ --header 'Content-Type: application/json' \ --data '{"name": "camera.startCapture"}' \ http://192.168.43.1:6624/osc/commands/execute | jq '.state'`
termux-toast -g bottom "$setoptions - $startcapture"