Example #1
0
        writebyte((int(ttime) + 8) >> 4)
        offset += 1
transfers_offsets.append(offset)  # sentinel
assert len(transfers_offsets) == nstops + 1

print "saving stop indexes"
write_text_comment("STOP STRUCTS")
loc_stops = tell()
struct_2i = Struct('II')
for stop in zip(stop_routes_offsets, transfers_offsets):
    out.write(struct_2i.pack(*stop))

print "saving stop attributes"
write_text_comment("STOP Attributes")
loc_stop_attributes = tell()
for stop_id, stop_name, stop_lat, stop_lon, attributes in db.stopattributes():
    attr = 0
    if 'wheelchair_boarding' in attributes and attributes[
            'wheelchair_boarding']:
        attr |= 1
    if 'visual_accessible' in attributes and attributes['visual_accessible']:
        attr |= 2
    writebyte(attr)

print "saving route indexes"
write_text_comment("ROUTE STRUCTS")
loc_routes = tell()
route_t = Struct('3I8H')
route_t_fields = [
    route_stops_offsets, trip_ids_offsets, headsign_offsets, route_n_stops,
    route_n_trips, route_attributes, agency_offsets, shortname_offsets,
Example #2
0
        writebyte((int(ttime) + 8) >> 4)
        offset += 1
transfers_offsets.append(offset) # sentinel
assert len(transfers_offsets) == nstops + 1
                                       
print "saving stop indexes"
write_text_comment("STOP STRUCTS")
loc_stops = tell()
struct_2i = Struct('II')
for stop in zip (stop_routes_offsets, transfers_offsets) :
    out.write(struct_2i.pack(*stop));

print "saving stop attributes"
write_text_comment("STOP Attributes")
loc_stop_attributes = tell()
for stop_id,stop_name,stop_lat,stop_lon,attributes in db.stopattributes() :
    attr = 0
    if 'wheelchair_boarding' in attributes and attributes['wheelchair_boarding']:
        attr |= 1
    if 'visual_accessible' in attributes and attributes['visual_accessible']:
        attr |= 2
    writebyte(attr)

print "saving route indexes"
write_text_comment("ROUTE STRUCTS")
loc_routes = tell()
route_t = Struct('3I8H')
route_t_fields = [route_stops_offsets, trip_ids_offsets,headsign_offsets, route_n_stops, route_n_trips,route_attributes,agency_offsets,shortname_offsets,productcategory_offsets,route_min_time, route_max_time]
# check that all list lengths match the total number of routes. 
for l in route_t_fields :
    # the extra last route is a sentinel so we can derive list lengths for the last true route.