# Path: gtfspy/util.py
# def wgs84_distance(lat1, lon1, lat2, lon2):
#     """Distance (in meters) between two points in WGS84 coord system."""
#     dLat = math.radians(lat2 - lat1)
#     dLon = math.radians(lon2 - lon1)
#     a = (math.sin(dLat / 2) * math.sin(dLat / 2) +
#          math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) *
#          math.sin(dLon / 2) * math.sin(dLon / 2))
#     c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
#     d = EARTH_RADIUS * c
#     return d


import numpy as np
from .util import wgs84_distance
function `find_segments` take a shape-sequence and stop-sequence, and
returns a list of `break_points`, which are the indexes within
shape-sequence which correspond to each stop within stop-sequence.

You can then pass `break_points` and the shape-sequence to the
function `return_segments`, which returns a list
[ [ shape-sequence ],
  [ shape-sequence ],
  ...,
  [ ]
]
This is the shape, broken down into individual segments, one
corresponding to each stop.  The last one is empty.


"""
from __future__ import print_function
from __future__ import absolute_import



def print_coords(rows, prefix=''):
    """Print coordinates within a sequence.

    This is only used for debugging.  Printed in a form that can be
    pasted into Python for visualization."""
    lat = [row['lat'] for row in rows]
    lon = [row['lon'] for row in rows]
    print('COORDS'+'-' * 5)
    print("%slat, %slon = %r, %r" % (prefix, prefix, lat, lon))

# Path: gtfspy/util.py
# def wgs84_distance(lat1, lon1, lat2, lon2):
#     """Distance (in meters) between two points in WGS84 coord system."""
#     dLat = math.radians(lat2 - lat1)
#     dLon = math.radians(lon2 - lon1)
#     a = (math.sin(dLat / 2) * math.sin(dLat / 2) +
#          math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) *
#          math.sin(dLon / 2) * math.sin(dLon / 2))
#     c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
#     d = EARTH_RADIUS * c
#     return d


# Path: gtfspy/shapes.py
import numpy as np
from .util import wgs84_distance

function `find_segments` take a shape-sequence and stop-sequence, and
returns a list of `break_points`, which are the indexes within
shape-sequence which correspond to each stop within stop-sequence.

You can then pass `break_points` and the shape-sequence to the
function `return_segments`, which returns a list
[ [ shape-sequence ],
  [ shape-sequence ],
  ...,
  [ ]
]
This is the shape, broken down into individual segments, one
corresponding to each stop.  The last one is empty.


"""
from __future__ import print_function
from __future__ import absolute_import



def print_coords(rows, prefix=''):
    """Print coordinates within a sequence.

    This is only used for debugging.  Printed in a form that can be
    pasted into Python for visualization."""
    lat = [row['lat'] for row in rows]
    lon = [row['lon'] for row in rows]
    print('COORDS'+'-' * 5)
    print("%slat, %slon = %r, %r" % (prefix, prefix, lat, lon))

    print('-'*5)