Beispiel #1
0
import sqlite3
import urllib
import tempfile
import json
import scraperwiki

scraperwiki.cache(True)

temp = tempfile.NamedTemporaryFile()
contents = urllib.urlopen(
    "http://seagrass.goatchurch.org.uk/~julian/uusaves/kforgecavedatastations"
).read()
open(temp.name, "wb").write(contents)

conn = sqlite3.connect(temp.name)
c = conn.cursor()

data = c.execute(
    """SELECT coalesce(eqfrom.eto, sfrom) AS cfrom, stfrom.x, stfrom.y,
                             coalesce(eqto.eto, sto) AS cto, stto.x, stto.y FROM legs
                      LEFT JOIN equates AS eqfrom ON eqfrom.efrom = sfrom 
                      LEFT JOIN equates AS eqto ON eqto.efrom = sto
                      LEFT JOIN stations AS stfrom ON cfrom = stfrom.station
                      LEFT JOIN stations AS stto ON cto = stto.station""")

jcode = """
window.onload = function() {
var paper = Raphael(10, 50, 320, 200);

var d = %s; 
import sqlite3
import urllib
import tempfile
import json
import scraperwiki
import math
scraperwiki.cache(False)

temp = tempfile.NamedTemporaryFile()
contents = urllib.urlopen(
    "http://seagrass.goatchurch.org.uk/~julian/uusaves/kforgecavedata").read()
open(temp.name, "wb").write(contents)
conn = sqlite3.connect(temp.name)
c = conn.cursor()

stationlegs = {}
for leg in c.execute("""
        SELECT coalesce(eqfrom.eto, sfrom), coalesce(eqto.eto, sto), tape, compass, clino FROM legs 
        LEFT JOIN equates AS eqfrom ON eqfrom.efrom = sfrom 
        LEFT JOIN equates as eqto on eqto.efrom = sto"""):
    stationlegs.setdefault(leg[0], []).append(leg)
    stationlegs.setdefault(leg[1], []).append(leg)

station = (stationlegs.keys())[0]
stationpos = {station: (0.0, 0.0, 0.0)}  # first position
lstations = [station]
while lstations:
    station = lstations.pop(0)
    for leg in stationlegs[station]:
        ostation = (station == leg[0] and leg[1] or leg[0])
        if ostation in stationpos:
import sqlite3
import urllib
import tempfile
import json
import scraperwiki
scraperwiki.cache(True)

temp = tempfile.NamedTemporaryFile()
contents = urllib.urlopen("http://seagrass.goatchurch.org.uk/~julian/uusaves/kforgecavedatastations").read()
open(temp.name, "wb").write(contents)

conn = sqlite3.connect(temp.name)
c = conn.cursor()

data = c.execute("""SELECT coalesce(eqfrom.eto, sfrom) AS cfrom, stfrom.x, stfrom.y,
                             coalesce(eqto.eto, sto) AS cto, stto.x, stto.y FROM legs
                      LEFT JOIN equates AS eqfrom ON eqfrom.efrom = sfrom 
                      LEFT JOIN equates AS eqto ON eqto.efrom = sto
                      LEFT JOIN stations AS stfrom ON cfrom = stfrom.station
                      LEFT JOIN stations AS stto ON cto = stto.station""")


jcode = """
window.onload = function() {
var paper = Raphael("rrr", 400, 400);

var d = %s; 

function h(x) { return (x+70)*2 }; 
function v(x) { return 350-(x+70)*2 }; 
import sqlite3
import urllib
import tempfile
import json
import scraperwiki
import math
scraperwiki.cache(False)

temp = tempfile.NamedTemporaryFile()
contents = urllib.urlopen("http://seagrass.goatchurch.org.uk/~julian/uusaves/kforgecavedata").read()
open(temp.name, "wb").write(contents)
conn = sqlite3.connect(temp.name)
c = conn.cursor()

stationlegs = { }
for leg in c.execute("""
        SELECT coalesce(eqfrom.eto, sfrom), coalesce(eqto.eto, sto), tape, compass, clino FROM legs 
        LEFT JOIN equates AS eqfrom ON eqfrom.efrom = sfrom 
        LEFT JOIN equates as eqto on eqto.efrom = sto"""):
    stationlegs.setdefault(leg[0], []).append(leg)
    stationlegs.setdefault(leg[1], []).append(leg)


station = (stationlegs.keys())[0]
stationpos = {station:(0.0, 0.0, 0.0)}  # first position
lstations = [ station ]
while lstations:
    station = lstations.pop(0)
    for leg in stationlegs[station]:
        ostation = (station == leg[0] and leg[1] or leg[0])
        if ostation in stationpos: