def EdgeTouchesMeridian(a, b, longitude):
  """Determines whether the edge from a to b touches a given meridian."""
  # To ensure that our crossing counts have the correct parity, we include the
  # left endpoint but not the right endpoint.
  low, high = min(a.lon, b.lon), max(a.lon, b.lon)
  if high - low >= 180:  # edge crosses the 180-degree meridian
    return longitude >= high or longitude < low
  return low <= longitude < high