from typing import OrderedDict


def create_points_trip_start_end(trips, from_colour='b', to_colour='r'):
    """
    Extracts a list of all start and end positions for provided trips.
    :returns a dict of lists formatted suitably for passing to plot_geopoints()
    """

    # Using OrderedDict to always return the end of the trip last
    # to ensure "to" points appear on top in the graph.
    # In plot_geopoints, points are plotted in the order of the
    # colour-key dictionary, and depending on the colours being used,
    # either "from" or "to" points could end up on top.
    # (E.g. on my implementation, "g" points would be drawn after "b",
    # which would be drawn after "r" -
    # this would vary depending on hash function in use.)
    # With OrderedDict, I specify the order.
    return OrderedDict([
        (from_colour, [(trip['start']['lat'], trip['start']['lng']) for trip in trips]),
        (to_colour, [(trip['end']['lat'], trip['end']['lng']) for trip in trips])
    ])