Skip to content

Instantly share code, notes, and snippets.

@Adrianod
Adrianod / TileLayer.GWC.js
Last active March 2, 2020 13:19
GeoWebCache tile store layer for Leaflet that actually works
L.TileLayer.GWC = L.TileLayer.extend({
_zeroPadder: function(unPaddedInt, padReq) {
if (unPaddedInt == 100) {
padReq++;
}
let padded = unPaddedInt.toString();
while (padded.length < padReq) {
padded = "0" + padded;
}
return padded;
@Adrianod
Adrianod / clickndirt.js
Last active March 29, 2017 22:32
Userscript to mark tiles as dirty on openstreetmap.org. Usage: alt-click on a tile to mark as dirty.
// ==UserScript==
// @name click n' dirt
// @version 0.1
// @description Alt-click to mark tiles as dirty on openstreetmap.org
// @include http://www.openstreetmap.org/*
// @include https://www.openstreetmap.org/*
// @copyright vax 2014
// ==/UserScript==
var code = '\
@Adrianod
Adrianod / convertShapefiles.sh
Created December 7, 2013 21:14
Converts a directory of Lantmäteriet-shapefiles to DXF for orienteering map use. Requires ogr2ogr.
#!/bin/bash
mkdir dxf
function convert {
ogr2ogr "dxf/$1" -f "DXF" $2 -where "$3" -skipfailures 2>/dev/null
echo "Converted dxf/$1"
}
for f in *.shp
@Adrianod
Adrianod / osm.user.js
Created March 8, 2013 14:50
UserScript that gives you nice looking OpenStreetMap-tiles in Garmin Connect.
// ==UserScript==
// @name OSM Mapnik tiles for Garmin Connect
// @version 0.1
// @description Gives you nice looking OpenStreetMap-tiles in Garmin Connect
// @match http://*.connect.garmin.com/*
// ==/UserScript==
var code = '(function() { MAPSERVER_OSM.length = 0;MAPSERVER_OSM[0] = "tile.osm.org";MAPSERVER_OSM_TILEPATH = "";})();';
var script = document.createElement("script");
@Adrianod
Adrianod / getUsedPolygons.py
Last active December 14, 2015 05:09
Extract the KML polygons representing your LAS-order from Lantmäteriet.
import xml.etree.ElementTree as ET
tree = ET.parse('las.kml')
root = tree.getroot()[0]
for pm in root.findall('{http://www.opengis.net/kml/2.2}Placemark'):
if pm[0].text != "selected_square_style":
root.remove(pm)
else:
pm.remove(pm[0])
@Adrianod
Adrianod / gist:4978190
Created February 18, 2013 15:25
Bookmarklet for browsing kso2.lantmateriet.se without the clutter.
javascript:$('#headerContainer,#geovyTabsContainer,#geovy-ortnamn-module').remove();$('#geovyMap').attr('style','margin: 0 !important');