<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_segment_length( linestring: LineString, p: Point, q: Optional[Point] = None ) -> float: """ Given a Shapely linestring and two Shapely points, project the points onto the linestring, and return the distance along the linestring between the two points. If ``q is None``, then return the distance from the start of the linestring to the projection of ``p``. The distance is measured in the native coordinates of the linestring. """

    # Get projected distances
    d_p = linestring.project(p)
    if q is not None:
        d_q = linestring.project(q)
        d = abs(d_p - d_q)
    else:
        d = d_p
    return d