<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trip_to_geojson( feed: "Feed", trip_id: str, *, include_stops: bool = False ) -> Dict: """ Return a GeoJSON representation of the given trip, optionally with its stops. Parameters feed : Feed trip_id : string ID of trip in ``feed.trips`` include_stops : boolean Returns ------- dictionary A (decoded) GeoJSON FeatureCollection comprising a Linestring feature representing the trip's shape. If ``include_stops``, then also include one Point feature for each stop visited by the trip. The Linestring feature will contain as properties all the columns in ``feed.trips`` pertaining to the given trip, and each Point feature will contain as properties all the columns in ``feed.stops`` pertaining to the stop, except the ``stop_lat`` and ``stop_lon`` properties. Return the empty dictionary if the trip has no shape. """

    # Get the relevant shapes
    t = feed.trips.copy()
    t = t[t["trip_id"] == trip_id].copy()
    shid = t["shape_id"].iat[0]
    geometry_by_shape = feed.build_geometry_by_shape(
        use_utm=False, shape_ids=[shid]
    )

    if not geometry_by_shape:
        return {}

    features = [
        {
            "type": "Feature",
            "properties": json.loads(t.to_json(orient="records"))[0],
            "geometry": sg.mapping(sg.LineString(geometry_by_shape[shid])),
        }
    ]

    if include_stops:
        # Get relevant stops and geometrys
        s = feed.get_stops(trip_id=trip_id)
        cols = set(s.columns) - set(["stop_lon", "stop_lat"])
        s = s[list(cols)].copy()
        stop_ids = s["stop_id"].tolist()
        geometry_by_stop = feed.build_geometry_by_stop(stop_ids=stop_ids)
        features.extend(
            [
                {
                    "type": "Feature",
                    "properties": json.loads(
                        s[s["stop_id"] == stop_id].to_json(orient="records")
                    )[0],
                    "geometry": sg.mapping(geometry_by_stop[stop_id]),
                }
                for stop_id in stop_ids
            ]
        )

    return {"type": "FeatureCollection", "features": features}