Skip to content

Instantly share code, notes, and snippets.

@tyrasd
tyrasd / index.js
Last active March 7, 2024 12:05
osm cuisine values by count
const key = 'cuisine';
fetch(`https://taginfo.openstreetmap.org/api/4/key/overview?key=${key}`)
.then(x => x.json())
.then(d => Math.ceil(d.data.counts[0].values / 999))
.then(numPages => Array.from({length: numPages}, (_, i) => i + 1))
.then(pages => Promise.all(pages
.map(i => `https://taginfo.openstreetmap.org/api/4/key/values?key=${key}&page=${i}&rp=999&sortname=count_all&sortorder=desc`)
.map(p => fetch(p).then(x => x.json())))
.then(data => {
@tyrasd
tyrasd / index.html
Last active March 23, 2023 18:53 — forked from milkbread/index.html
JavaScript: Convert GeoJSON Polygon to WKT
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Convert GeoJSON</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="poly.js"></script>
</head>
@tyrasd
tyrasd / index.md
Created August 19, 2022 13:00
iD releases playground
@tyrasd
tyrasd / index.html
Last active June 18, 2022 13:35
minimal Overpass Leaflet example
<!DOCTYPE html>
<html>
<head>
<title>Example: Overpass-API with Leaflet.js</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
<style>
body {
padding: 0;
@tyrasd
tyrasd / README.md
Last active May 9, 2022 18:08
This is how I've visualized OpenStreetMap's node density.
  1. download the source data

     wget http://fred.dev.openstreetmap.org/density/tiles.13
     wget http://fred.dev.openstreetmap.org/density/tiles.16
    
  2. convert to simple, gnuplot-readable text format

     sed 's/\([0-9]*\) z=\([0-9]*\) x=\([0-9]*\) y=\([0-9]*\)/\3 \4 \1/' < tiles.13 > tiles.13.txt
     sed 's/\([0-9]*\) z=\([0-9]*\) x=\([0-9]*\) y=\([0-9]*\)/\3 \4 \1/' < tiles.16 > tiles.16.txt
    
@tyrasd
tyrasd / index.js
Created June 8, 2021 09:02
overpass turbo URL shortener
var http = require('http');
var url = require('url');
var redis = require('redis');
var base62 = require('base62');
var db = redis.createClient("/var/run/redis/redis-server.sock");
http.createServer(function (req, res) {
if (req.method == "OPTIONS") {
res.writeHead(200, {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@font-face {
font-family: 'Rubik';
font-style: normal;
font-weight: 400;
src:
local('Rubik'),
local('Rubik-Regular'),
url('./rubik-v4-latin-regular.woff2') format('woff2'),
url('./rubik-v4-latin-regular.woff') format('woff');
}
@tyrasd
tyrasd / readme.md
Last active August 16, 2017 10:03
osm-analytics server setup walkthrough

Cruncher

  • install node/npm, curl
  • compile and install tippecanoe (version 1.8.1 works, not sure about newer releases)
  • download run.sh from cruncher repo and chmod +x it
  • replace osmqatiles-planet url with the extract you want
  • adjust paths in run.sh (and mkdir the respective working directories)
  • comment out hotprojects.sh (would fail because it requires valid AWS credentials to upload stuff into a hardcoded bucket).
  • comment out the forever restart … lines (requires a tile-serving script to be already running)
  • execute run.sh -> … -> two .mbtiles files in results directory
@tyrasd
tyrasd / index.html
Last active April 17, 2017 07:12 — forked from anonymous/index.html
st flurnamen
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>st-flurnamen Preview</title>
<link rel="stylesheet" type="text/css" href="https://api.mapbox.com/mapbox-gl-js/v0.35.1/mapbox-gl.css" />
<script src="https://api.mapbox.com/mapbox-gl-js/v0.35.1/mapbox-gl.js"></script>
<style>
body { margin:0; padding:0; background-color:black; }