cdm/src/main/java/ucar/nc2/ft2/coverage/HorizCoordSys.java
private List<MAMath.MinMax> subsetLonIntervals(double wantMin, double wantMax, double start, double end) {
    if (wantMin <= wantMax) {
      if (wantMin > end && wantMax > end) // none A.1
        return Collections.EMPTY_LIST;

      if (wantMin < end && wantMax < end) // A.2
        return Lists.newArrayList(new MAMath.MinMax(wantMin, wantMax));

      if (wantMin < end && wantMax > end) // A.3
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end));

    } else {
      if (wantMin > end && wantMax > end) // all B.1
        return Lists.newArrayList(new MAMath.MinMax(start, end));

      if (wantMin < end && wantMax < end) { // B.2
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end), new MAMath.MinMax(start, wantMax));
      }
      if (wantMin < end && wantMax > end) // B.3
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end));
    }

    // otherwise shouldnt get to this
    logger.error("longitude want [%f,%f] does not intersect axis [%f,%f]", wantMin, wantMax, start, end);
    return Collections.EMPTY_LIST;
  }
private List<MAMath.MinMax> subsetLonIntervals(double wantMin, double wantMax, double start, double end) {
    if (wantMin <= wantMax) {
      if (wantMin > end && wantMax > end) // none A.1
        return Collections.EMPTY_LIST;

      if (wantMin < end && wantMax < end) // A.2
        return Lists.newArrayList(new MAMath.MinMax(wantMin, wantMax));

      if (wantMin < end && wantMax > end) // A.3
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end));

    } else {
      if (wantMin > end && wantMax > end) // all B.1
        return Lists.newArrayList(new MAMath.MinMax(start, end));

      if (wantMin < end && wantMax < end) { // B.2
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end), new MAMath.MinMax(start, wantMax));
      }
      if (wantMin < end && wantMax > end) // B.3
        return Lists.newArrayList(new MAMath.MinMax(wantMin, end));
    }

    // otherwise shouldnt get to this
    logger.error("longitude want [%f,%f] does not intersect axis [%f,%f]", wantMin, wantMax, start, end);
    return Collections.EMPTY_LIST;
  }
/*
longitude subset, after normalizing to start
draw a circle, representing longitude values from start to start + 360.
all values are on this circle and are > start.
put start at bottom of circle, end > start, data has values from start, counterclockwise to end.
wantMin, wantMax can be anywhere, want goes from wantMin counterclockwise to wantMax.
wantMin may be less than or greater than wantMax.

cases:
A. wantMin < wantMax
1 wantMin, wantMax > end : empty
2 wantMin, wantMax < end : [wantMin, wantMax]
3 wantMin < end, wantMax > end : [wantMin, end]

B. wantMin > wantMax
1 wantMin, wantMax > end : all [start, end]
2 wantMin, wantMax < end : 2 pieces: [wantMin, end] + [start, max]
3 wantMin < end, wantMax > end : [wantMin, end]