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 pylons.decorators.util import get_pylons | |
from decorator import decorator | |
from geojson import FeatureCollection, dumps | |
@decorator | |
def geojsonify(func, *args, **kwargs): | |
pylons = get_pylons(args) | |
pylons.response.content_type = 'application/json' | |
data = func(*args, **kwargs) | |
if isinstance(data, list): # sucks !! |
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 pylons import request, response | |
from simplejson import dumps | |
def jsonify(data): | |
func = request.params.get('jsonp') or \ | |
request.params.get('callback') or \ | |
request.params.get('cb') | |
body = dumps(data, indent=None if request.is_xhr else 2) | |
response.charset = 'utf8' | |
if func is not None: |
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
-module(spatial). | |
-export([bounds/1]). | |
bounds({Atom, Coords}) when Atom == point; Atom == linestring; Atom == polygon -> | |
{lists:min([X || {X, _} <- Coords]), | |
lists:min([Y || {_, Y} <- Coords]), | |
lists:max([X || {X, _} <- Coords]), | |
lists:max([Y || {_, Y} <- Coords])}; | |
bounds(_) -> | |
error. |
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 decimal import * | |
if 'x' in request.params: | |
# deactivate all traps | |
getcontext().traps = {} | |
x = Decimal(request.params['x']) | |
if x.is_infinite() or x.is_nan(): | |
# x is NaN, -Infinity or +Infinity | |
pass | |
else: |
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> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<title>OpenLayers Example</title> | |
<link rel="stylesheet" href="http://www.openlayers.org/dev/theme/default/style.css" type="text/css"> | |
<style> | |
.into-water { |
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
BEGIN; | |
ALTER TABLE missionevents ADD COLUMN type_text text; | |
UPDATE missionevents SET type_text = type::text; | |
DROP TYPE missionevent_type CASCADE; | |
CREATE TYPE missionevent_type AS ENUM ('location', 'battery_level', 'start', 'end', 'cancel', 'light', 'expire', 'battery_low', 'comment', 'warning', 'error', 'temperature_list', 'temperature_low', 'temperature_high'); | |
ALTER TABLE missionevents ADD COLUMN type missionevent_type; | |
UPDATE missionevents SET type = type_text::missionevent_type; | |
ALTER TABLE missionevents DROP COLUMN type_text; | |
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
"type": "MultiLineString", | |
"coordinates": [[shpxy xh="[" yf="]" cs=", " ph="[ " pf=" ]" ps=","]] | |
"type": "MultiPolygon", | |
"coordinates": [[shpxy xh="[" yf="]" cs=", " ph="[ " pf=" ]" ps="," irh="[" irf="]" orh="[" orf="]"]] |
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
import re | |
def valid(awb): | |
match = re.match('\d{3}(?P<serial>\d{7})(?P<check>\d{1})', str(awb)) | |
if match: | |
serial, check = map(int, match.group('serial', 'check')) | |
_, rem = divmod(serial, 7) | |
return rem == check | |
else: |
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
import re | |
def valid(awb): | |
m = re.match('\d{3}(?P<serial>\d{7})(?P<check>\d)\Z', str(awb)) | |
return int(m.group('serial')) % 7 == int(m.group('check')) if m else False |
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
http://www.overpass-api.de/api/xapi_meta?way[builing=*] |
OlderNewer