Skip to content

Instantly share code, notes, and snippets.

View lukasmartinelli's full-sized avatar

Lukas Martinelli lukasmartinelli

View GitHub Profile
@lukasmartinelli
lukasmartinelli / maputnik_mockup.json
Last active November 24, 2016 10:37
Maputnik Balsamiq Mockup
{
"mockup":{
"controls":{
"control":[
{
"ID":"0",
"h":"215",
"measuredH":"70",
"measuredW":"100",
"typeID":"Canvas",
@lukasmartinelli
lukasmartinelli / style.json
Created September 23, 2016 07:18
Mapbox GL JSON Style Document Layer Example
{
"layers": [
{
"id": "building",
"type": "fill",
"source": "osm2vectortiles",
"source-layer": "building",
"paint": {
"fill-color": "#eee"
}
@lukasmartinelli
lukasmartinelli / liberty.html
Last active August 7, 2016 14:12
Example of using OSM Liberty basemap.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>OSM2VectorTiles with Liberty style</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.0/mapbox-gl.css' rel='stylesheet' />
<style>
@lukasmartinelli
lukasmartinelli / patch_mapbox_gl_style.py
Created August 6, 2016 21:31
Patch sources of a Mapbox GL style with settings from style and purge private details
import json
import sys
if __name__ == '__main__':
if len(sys.argv) >= 2:
style_src = sys.argv[1]
patch_src = sys.argv[2]
else:
print('patch_mabpox_gl_style.py <style> <patch-src>')
@lukasmartinelli
lukasmartinelli / tiles_to_geojson.py
Created August 2, 2016 10:43
Turn tile text files into GeoJSON
"""
Usage example:
cat missing_tiles.txt | sed 's/MISSING//g' | python tiles_to_geojson.py > missing_tiles.geojson
"""
import json
import hashlib
import mercantile
@lukasmartinelli
lukasmartinelli / compress_tiff_files.sh
Created July 30, 2016 12:18
Compress all DEM TIFF files in a directory in place
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
function compress_inplace() {
local filename="$1"
gdal_translate -co compress=lzw "$filename" "$filename.compressed"
rm "$filename"
mv "$filename.compressed" "$f"
@lukasmartinelli
lukasmartinelli / README.md
Created July 26, 2016 09:15
Pyramid Jobs from Tile List File

Usage

Meant to create pyramid jobs for OSM2VectorTiles when only a tile list file is available (e.g. recovering missing tiles).

cat missing_tiles.txt | sed 's/MISSING//g' | python generate_pyramid_jobs.py
```
#admin
[admin_level]
[disputed]
[maritime]
[osm_id]
#aeroway
[osm_id]
[type]
#building
[osm_id]
@lukasmartinelli
lukasmartinelli / PROPOSAL.md
Last active July 12, 2016 18:37
OSM2VectorTiles v3
@lukasmartinelli
lukasmartinelli / filter_nginx_log_by_time.py
Created May 18, 2016 10:35
Filter NGINX for requests longer than 10 seconds
import fileinput
import sys
for line in fileinput.input():
tokens = line.split('"-"')
time_tokens = tokens[-1].strip().split(' ')
try:
nginx_time, php_time = float(time_tokens[0]), float(time_tokens[1])
except ValueError: