import re


def middle_coord(text):
    """Get the middle coordinate from a coordinate range.

    The input is in the form <start> to <end> with both extents being in
    degrees and minutes as N/S/W/E. S and W thus need to be negated as we only
    care about N/E.

    """
    def numbers_from_string(s):
        """Find all numbers in a string."""
        return [float(n) for n in re.findall(r'[\d.]*\d[\d.]*', s)]


    def tuple_to_float(numbers):
        divisor = 1
        result = 0
        for num in numbers:
            result += float(num) / divisor
            divisor = divisor * 60
        return result

    if text is None:
        return None
    pieces = text.split(' to ', 1)
    start, end = map(numbers_from_string, pieces)
    start = tuple_to_float(start)
    end = tuple_to_float(end)
    if pieces[0][-1] in ('S', 'W'):
        start = -start
    if pieces[1][-1] in ('S', 'W'):
        end = -end
    return (start + end) / 2