public Optional < CoverageCoordAxis > subsetByIntervals ( List < MAMath . MinMax > lonIntvs , int stride ) { if ( axisType != AxisType . Lon ) return Optional . empty ( "subsetByIntervals only for longitude" ) ; if ( ! isRegular ( ) ) return Optional . empty ( "subsetByIntervals only for regular longitude" ) ; CoordAxisHelper helper = new CoordAxisHelper ( this ) ; double start = Double . NaN ; boolean first = true ; List < RangeIterator > ranges = new ArrayList <> ( ) ; for ( MAMath . MinMax lonIntv : lonIntvs ) { if ( first ) start = lonIntv . min ; first = false ; Optional < RangeIterator > opt = helper . makeRange ( lonIntv . min , lonIntv . max , stride ) ; if ( ! opt . isPresent ( ) ) return Optional . empty ( opt . getErrorMessage ( ) ) ; ranges . add ( opt . get ( ) ) ; } try { RangeComposite compositeRange = new RangeComposite ( AxisType . Lon . toString ( ) , ranges ) ; int npts = compositeRange . length ( ) ; double end = start + npts * resolution ; CoverageCoordAxisBuilder builder = new CoverageCoordAxisBuilder ( this ) ; // copy builder . subset ( npts , start , end , resolution , null ) ; builder . setRange ( null ) ; builder . setCompositeRange ( compositeRange ) ; return Optional . of ( new CoverageCoordAxis1D ( builder ) ) ; } catch ( InvalidRangeException e ) { return Optional . empty ( e . getMessage ( ) ) ; } }
only for longitude only for regular ( do we need a subclass for longitude 1D coords ??