Beispiel #1
0
def get_rendered_page():
    env = Environment(loader=FileSystemLoader('.'))
    template = env.get_template('index_template.html')
    listings = get_listings()
    add_colors(listings)
    make_map(listings, 'map.png')
    rendered = template.render(listings=listings, summary=get_summary(listings))
    return rendered
Beispiel #2
0
def get_interesting_listings():
    return [l for l in get_listings() if not (l['expired'] or l['ignored'])]
from motionless import DecoratedMap, LatLonMarker
from mapper import positions

def pairwise_distances(listings):
    coords = positions(listings)
    distances = pd.DataFrame(index=coords.keys(), columns=coords.keys())
    for name_1, name_2 in product(coords.keys(), coords.keys()):
        lat_1, lon_1 = coords[name_1]
        lat_2, lon_2 = coords[name_2]
        distances.loc[name_1, name_2] = walking_distance(lat_1, lon_1, lat_2, lon_2)

    return distances

def shortest_path(listings):
    distances = pairwise_distances(listings)
    best = None
    best_time = sp.inf
    for p in permutations(distances.index):
        time = sum(distances.at[s, t] for s, t in zip(p, p[1:]))
        if time < best_time:
            best = p
            best_time = time

    times_of_best = [distances.at[s, t] for s, t in zip(best, best[1:])]
    return best, times_of_best, best_time

# %matplotlib inline
listings = get_listings()
# print(shortest_path(listings))
make_map(listings)