def _make_num(parts, max_deg):
    """Parse the parts from a regular expression match into a decimal number.
    @param parts: the parts from the regex match
    @param max_deg: the maximum degrees allowed (90 or 180)
    @returns: a floating point representation
    @exception: if part of the latitude or longitude is out of range
    """
    num = float(parts['deg'])
    if num > max_deg or num < max_deg * -1:
        raise ValueError('degrees out of range {}/{}'.format(max_deg * -1,
            max_deg))
    if parts['min']:
        min = float(parts['min'])
        if min >= 60.0:
            raise ValueError('minutes must be less than 60')
        else:
            num += min / 60.0
    if parts['sec']:
        sec = float(parts['sec'])
        if sec >= 60:
            raise ValueError('seconds must be less than 60')
        num += sec / 3600.0
    if parts.get('sign') == '-' or parts.get('hemi') and parts['hemi'].upper(
        ) in ('S', 'W'):
        num *= -1
    return num
