# Path: karta/errors.py
# class NoIntersection(Exception):
#     """ Indicates that no intersection exists between segments """
#     def __init__(self, message=''):
#         self.message = message


import numpy as np
import warnings
from math import sqrt, sin, cos, tan, asin, acos, atan, atan2, atanh, pi
from .errors import NoIntersection
        # strategy 2
        return (abs((pt[0]+360)%360 - lon_1) < 180) and \
               (segment[0][1] <= pt[1] <= segment[1][1])
    else:
        # strategy 1
        return isbetween_circular(pt[0], lon_1, lon_2)

def intersection_spherical(segment1, segment2):
    """ compute the intersection between two great circle segments on a sphere

    Parameters
    ----------
    segment1, segment2 : tuple of tuples
        Tuples of the form ((x1, y1), (x2, y2)) describing line segements
    """
    gc1 = eulerpole(*segment1)
    gc2 = eulerpole(*segment2)
    n = cross(gc1, gc2)
    lon, lat = cart2sph(*n)
    lon_antipodal = (lon+360)%360-180

    pt = (lon, lat)
    pt_antipodal = (lon_antipodal, -lat)
    if (check_in_segment_range(pt, segment1) and
        check_in_segment_range(pt, segment2)):
        return pt
    elif (check_in_segment_range(pt_antipodal, segment1) and
          check_in_segment_range(pt_antipodal, segment2)):
        return pt_antipodal
    else:

# Path: karta/errors.py
# class NoIntersection(Exception):
#     """ Indicates that no intersection exists between segments """
#     def __init__(self, message=''):
#         self.message = message


# Path: karta/geodesy.py
import numpy as np
import warnings
from math import sqrt, sin, cos, tan, asin, acos, atan, atan2, atanh, pi
from .errors import NoIntersection

        # strategy 2
        return (abs((pt[0]+360)%360 - lon_1) < 180) and \
               (segment[0][1] <= pt[1] <= segment[1][1])
    else:
        # strategy 1
        return isbetween_circular(pt[0], lon_1, lon_2)

def intersection_spherical(segment1, segment2):
    """ compute the intersection between two great circle segments on a sphere

    Parameters
    ----------
    segment1, segment2 : tuple of tuples
        Tuples of the form ((x1, y1), (x2, y2)) describing line segements
    """
    gc1 = eulerpole(*segment1)
    gc2 = eulerpole(*segment2)
    n = cross(gc1, gc2)
    lon, lat = cart2sph(*n)
    lon_antipodal = (lon+360)%360-180

    pt = (lon, lat)
    pt_antipodal = (lon_antipodal, -lat)
    if (check_in_segment_range(pt, segment1) and
        check_in_segment_range(pt, segment2)):
        return pt
    elif (check_in_segment_range(pt_antipodal, segment1) and
          check_in_segment_range(pt_antipodal, segment2)):
        return pt_antipodal
    else:

        raise NoIntersection()