コード例 #1
0
ファイル: processbike.py プロジェクト: LemonPi/Pathtreker
def buildgraph():
    graph = picklegraph.load()
    i = 0
    for record in bi_sh.iterRecords():
        fnode = record[fnode_index]
        tnode = record[tnode_index]
        cp_type = record[cp_type_index]
        if cp_type == None or len(cp_type) == 0 or cp_type[0] == 0x20:
            continue
        if fnode in graph and tnode in graph[fnode]:
            i += 1
            graph[fnode][tnode]["length"] *= BIKE_FRIENDLY_SCALE_FACTOR
    print("changed", i, "lengths")
    return graph
コード例 #2
0
ファイル: processbike.py プロジェクト: Lytrix/Pathtreker
def buildgraph():
    graph = picklegraph.load()
    i = 0
    for record in bi_sh.iterRecords():
        fnode = record[fnode_index]
        tnode = record[tnode_index]
        cp_type = record[cp_type_index]
        if cp_type == None or len(cp_type) == 0 or cp_type[0] == 0x20:
            continue
        if fnode in graph and tnode in graph[fnode]:
            i += 1
            graph[fnode][tnode]["length"] *= BIKE_FRIENDLY_SCALE_FACTOR
    print("changed", i, "lengths")
    return graph
コード例 #3
0
import route
import math
import picklegraph
import picklegraph_bike
from queryaddress import address_to_inter, get_dir_helper
from flask import Flask, request, jsonify
# backend to webapp that returns direction JSON object as defined in doc/backend_api
app = Flask(__name__)
app.debug = True
app.config.from_object(__name__)

# load serialized graph quickly (takes less than a second from previous time of 37 seconds)
centerline_graph = picklegraph.load()
bikelane_graph = picklegraph_bike.load()

# intersection record indices
name_index = 2


def get_dir(g, start_inter, end_inter):
    """Return direction of path segment when given adjacent starting and ending intersections."""
    # compare the difference in longitude and latitude
    start_lon = g.node[start_inter]['lon']
    start_lat = g.node[start_inter]['lat']
    end_lon = g.node[end_inter]['lon']
    end_lat = g.node[end_inter]['lat']
    dlat = end_lat - start_lat
    dlon = end_lon - start_lon
    return get_dir_helper(dlat, dlon)

コード例 #4
0
ファイル: queryaddress.py プロジェクト: Lytrix/Pathtreker
import pickleaddress
import picklegraph
import picklestreet
import util
addresses = pickleaddress.load()
gr = picklegraph.load()
streets = picklestreet.load()

def get_dir_helper(dlat, dlon):
	if abs(dlat) > abs(dlon):
		# more difference along latitude, either N or S
		if dlat > 0:
			return "North"
		else:
			return "South"
	else:
		if dlon > 0:
			return "East"
		else:
			return "West"

LEFT = "L"
RIGHT = "R"
def flip(a):
	if a == LEFT:
		return RIGHT
	return LEFT

def getaddress(name):
	"""
	returns: inter, dist, side, longitude, latitude
コード例 #5
0
import route
import math
import picklegraph
import picklegraph_bike
from queryaddress import address_to_inter, get_dir_helper
from flask import Flask, request, jsonify
# backend to webapp that returns direction JSON object as defined in doc/backend_api
app = Flask(__name__)
app.debug = True
app.config.from_object(__name__)

# load serialized graph quickly (takes less than a second from previous time of 37 seconds)
centerline_graph = picklegraph.load()
bikelane_graph = picklegraph_bike.load()

# intersection record indices
name_index = 2

def get_dir(g, start_inter, end_inter):
	"""Return direction of path segment when given adjacent starting and ending intersections."""
	# compare the difference in longitude and latitude
	start_lon = g.node[start_inter]['lon']
	start_lat = g.node[start_inter]['lat']
	end_lon = g.node[end_inter]['lon']
	end_lat = g.node[end_inter]['lat']
	dlat = end_lat - start_lat
	dlon = end_lon - start_lon
	return get_dir_helper(dlat,dlon)


# used as turn[in_dir][out_dir] to see which direction to turn