Skip to content

Instantly share code, notes, and snippets.

View tormi's full-sized avatar
🇪🇪
Working from home

Tormi Tabor tormi

🇪🇪
Working from home
View GitHub Profile
@yuletide
yuletide / epsg.js
Created October 18, 2012 01:22
Proj4js EPSG Definitions as a node module
module.exports = function(Proj4js){
Proj4js.defs["EPSG:3819"] = "+proj=longlat +ellps=bessel +towgs84=595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408 +no_defs";
Proj4js.defs["EPSG:3821"] = "+proj=longlat +ellps=aust_SA +no_defs";
Proj4js.defs["EPSG:3824"] = "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:3889"] = "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:3906"] = "+proj=longlat +ellps=bessel +towgs84=682,-203,480,0,0,0,0 +no_defs";
Proj4js.defs["EPSG:4001"] = "+proj=longlat +ellps=airy +no_defs";
Proj4js.defs["EPSG:4002"] = "+proj=longlat +ellps=mod_airy +no_defs";
Proj4js.defs["EPSG:4003"] = "+proj=longlat +ellps=aust_SA +no_defs";
Proj4js.defs["EPSG:4004"] = "+proj=longlat +ellps=bessel +no_defs";
@bmcbride
bmcbride / LeafletToWKT.js
Last active June 7, 2022 02:17
Leaflet layer to WKT
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;
@webchick
webchick / drupal-hooks-by-implementation
Last active April 9, 2020 10:00
A list of hooks in all* Drupal contrib modules (6.x and 7.x), in descending order of how often they're implemented. (Consolidated a few that were renamed between 6 and 7) * Within a rounding error. :P
Array
(
[hook_menu] => 6744
[hook_uninstall] => 4742
[hook_perm(ission)] => 4012
[hook_install] => 3751
[hook_theme] => 3525
[hook_schema] => 3003
[hook_help] => 2465
[hook_form_alter] => 2273
@andrewxhill
andrewxhill / gist:5830659
Created June 21, 2013 11:39
Leaflet.draw control for CartoDB
function persistOnCartoDB(action,layers) {
var cartodb_ids=[];
var geojsons=[];
switch(action) {
case "UPDATE":
if(layers.getLayers().length<1)
return;
layers.eachLayer(function(layer) {
@benbalter
benbalter / geojson-conversion.sh
Last active April 23, 2024 13:16
Bulk convert shapefiles to geojson using ogr2ogr
# Bulk convert shapefiles to geojson using ogr2ogr
# For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/
# Note: Assumes you're in a folder with one or more zip files containing shape files
# and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere)
#geojson conversion
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
}
@mgedmin
mgedmin / conf.py.rst
Created July 22, 2013 10:37
HOWTO add "Show on GitHub" and "Edit on GitHub" links to the Sphinx sidebar

Edit on GitHub links for Sphinx

Create _ext/ and _templates/ subdirectories.

Move edit_on_github.py into the _ext/ subdirectory.

Move sourcelink.html into the _templates/ subdirectory.

Add the following after the import sys, os line

// +proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556
// +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80
// +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
//Allikas: https://taxofon.ee/eomap/EOMap.js
String destinationCordinateProjection=" +proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
//made by example: http://augusttown.blogspot.com/2010/03/using-java-map-projection-library-in.html
String[] proj4_w = destinationCordinateProjection.split(" ");

I had previously implemented a basic styling interface, but dropped it for the time being, because of a few factors:

  1. No established standard for GeoJSON styling (GeoJSON CSS is a flawed spec without any implementations)
  2. The focus of GeoJSON.io is data, not styling
  3. A styling interface is likely its own thing.

Basically, given that GeoJSON is taken as the language of the site, I don't want to create expectations of compatibility that won't stand - if I invent some styling language, people will expect it to work, or at least be supportable, outside of the editor, and this promise will quickly be broken. I think conceptually the way to 'fix this' is to tie styling strongly to a publish interface that can make that guarantee, and write implementations in d3/openlayers/leaflet/etc for the language if/when it exists.

A bit of a big task :) The experience of working on CartoCSS has given me a bit of appreciation/fear of the area of styling languages in general and I think they should diverge from CSS a bi

@tmcw
tmcw / json.md
Created August 15, 2013 20:27
Why JSONP is a terrible idea and I will never use it again

Moral Concerns

JSONP is not actually JSON with padding, it's Javascript code that's executed. JSON is not a real subset of Javascript and the way it is not is important to us: via UTFGrid, we are all UTF-8 masters.

JSONP is not safe: it's Javascript that's executed. It's trivial to XSS with JSONP, because JSONP is XSS. Just have a call like mapbox.load('foo.tilejson', …) and if foo.tilejson gets replaced with destroyYoursite(), it gets run. Compare to JSON.parse, which is, on purpose, not eval.

Practical Concerns

JSONP is questionable in terms of performance. To be fast, you want to have the same callback all the time so that you can cache the response. But this leads to a page like

@tormi
tormi / EHAK_Saue_vald_asustusyksus_20130901_SRID4326.geojson
Last active December 22, 2015 23:09
EHAK Saue vald asustusyksus 20130901 SRID4326 geojsonAndmed: http://geoportaal.maaamet.ee/est/Andmed-ja-kaardid/Haldus-ja-asustusjaotus-p119.html, Asustusüksus SHP ( 9.89 MB, 1.09.2013 )Konverteerimine shp > geojson, SRID3301 > SRID4326 ja päring OKOOD = "0727" (Saue vald): http://converter.mygeodata.eu/vector
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.