This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run with path to postgis share dir | |
# e.g. ./postgis_template.sh /usr/local/Cellar/postgis/2.0.1/share/postgis | |
POSTGIS_TEMPLATE_PATH=$1; | |
# Creating the template spatial database | |
createdb -E UTF8 -T template0 template_postgis | |
# Loading the PostGIS SQL routines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.geos import MultiPolygon, Polygon, LinearRing | |
def to_mpoly(osmosis_file): | |
""" Parse an Osmosis polygon filter file | |
Accept a sequence of lines from a polygon file, | |
return a django.contrib.gis.MultiPolygon object. | |
http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.Icon.Hover = L.Icon.extend({ | |
options: { | |
iconSize: new L.Point(25, 41), | |
iconAnchor: new L.Point(13, 41), | |
popupAnchor: new L.Point(1, -34), | |
shadowSize: new L.Point(41, 41) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create div and call animate on it, from start to end colour for the duration | |
// for each step of the colour change, invoke the callback | |
function fadeColour(start_colour, end_colour, duration, callback) { | |
var ele = $('<div></div>'); | |
$(ele).css('color', start_colour); | |
$(ele).animate({ | |
color: end_colour | |
}, { | |
duration: duration, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
GeoJSON layer with mouse hover events to properties for each feature | |
Requires JQuery to handle the AJAX requests | |
Currently only supports FeatureCollections | |
Features must have ID's, so they can be deduplicated across tiles (not rendered twice). | |
*/ | |
/* | |
Control that shows HTML content for a point on hover | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django view to generate a gradient image. | |
Inputs: | |
* colour_model: "rgb" or "hsl" | |
* direction: "horizontal" or "vertical" | |
* start_rgb: hex colour string, e.g: #BADA55 | |
* end_rgb: hex colour string, e.g: #BEEFED | |
* width: image pixel height | |
* height: image pixel width |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install django-orm-extensions | |
from django.contrib.gis.db.models.query import GeoQuerySet | |
from django.contrib.gis.db.models import GeoManager | |
from django_orm.postgresql.hstore.queryset import HStoreQuerySet | |
from django_orm.postgresql.hstore.manager import HStoreManager | |
class GeoHStoreQuerySet(GeoQuerySet, HStoreQuerySet): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Leaflet Markers</title> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.3/leaflet.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.3/leaflet.ie.css" /> | |
<![endif]--> | |
<script src="http://cdn.leafletjs.com/leaflet-0.4.3/leaflet.js"></script> | |
<style type="text/css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nested_map(self, collection, func): | |
if type(collection) == list: | |
return [nested_map(i, func) for i in collection] | |
elif type(collection) == tuple: | |
return tuple([nested_map(i, func) for i in collection]) | |
else: | |
return func(collection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extend GeoJSON to handle google-encoded linestrings | |
// assumes that any array of coordinates that make up a linestring are replaced with the google encoded line string | |
L.extend(L.GeoJSON, { | |
// This function is from Google's polyline utility. | |
// Borrowed from: http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/decode.js | |
// Changed to return lng/lats instead of lat/lngs | |
decodeLine: function (encoded) { | |
var len = encoded.length; | |
var index = 0; | |
var array = []; |