src/main/java/ucar/geoapi/NetcdfCRS.java
static NetcdfCRS wrap(final CoordinateSystem netcdfCS, final NetcdfDataset file, final Logger logger) {
        if (netcdfCS == null) {
            return null;
        }
        /*
         * The datum to use. Fixed to Earth for now, will need to become configurable in the future.
         */
        final NetcdfEllipsoid datum = NetcdfEllipsoid.SPHERE;
        /*
         * Separate the horizontal, vertical and temporal components. We need to iterate
         * over the netCDF axes in reverse order (see class javadoc). We don't use the
         * CoordinateAxis.getTaxis() and similar methods because we want to ensure that
         * the components are build in the same order than axes are found.
         */
        final List<NetcdfCRS> components = new ArrayList<>(4);
        final List<CoordinateAxis>  axes = netcdfCS.getCoordinateAxes();
        for (int i=axes.size(); --i>=0;) {
            CoordinateAxis1D axis = (CoordinateAxis1D) axes.get(i);
            if (axis != null) {
                final AxisType type = axis.getAxisType();
                if (type != null) { // This is really null in some netCDF file.
                    switch (type) {
                        case Pressure:
                        case Height:
                        case GeoZ: {
                            components.add(new Vertical(netcdfCS, axis));
                            continue;
                        }
                        case RunTime:
                        case Time: {
                            components.add(new Temporal(netcdfCS, Temporal.complete(axis, file, logger)));
                            continue;
                        }
                        case Lat:
                        case Lon: {
                            final int upper = i+1;
                            i = lower(axes, i, AxisType.Lat, AxisType.Lon);
                            components.add(new Geographic(datum, netcdfCS, axes.subList(i, upper)));
                            continue;
                        }
                        case GeoX:
                        case GeoY: {
                            final int upper = i+1;
                            i = lower(axes, i, AxisType.GeoX, AxisType.GeoY);
                            components.add(new Projected(datum, netcdfCS, axes.subList(i, upper)));
                            continue;
                        }
                    }
                }
            }
            // Unknown axes: do not try to split.
            components.clear();
            break;
        }
        final int size = components.size();
        switch (size) {
            /*
             * If we have been unable to split the CRS ourself in various components,
             * use the information provided by the netCDF library as a fallback. Note
             * that the CRS created that way may not be valid in the ISO 19111 sense.
             */
            case 0: {
                if (netcdfCS.isLatLon()) {
                    return new Geographic(datum, netcdfCS, axes);
                }
                if (netcdfCS.isGeoXY()) {
                    return new Projected(datum, netcdfCS, axes);
                }
                return new NetcdfCRS(netcdfCS, axes);
            }
            /*
             * If we have been able to create exactly one CRS, returns that CRS.
             */
            case 1: {
                return components.get(0);
            }
            /*
             * Otherwise create a CompoundCRS will all the components we have separated.
             */
            default: {
                return new Compound(netcdfCS, components.toArray(new NetcdfCRS[size]));
            }
        }
    }
/**
     * Creates a new {@code NetcdfCRS} object, optionally using the given netCDF file for additional
     * information. This method performs the same work than {@link #wrap(CoordinateSystem)}, except
     * that more accurate coordinate axes may be created if a reference to the original dataset file
     * is provided. This apply especially to {@link CoordinateAxis1DTime}.
     *
     * @param  netcdfCS  the netCDF coordinate system to wrap, or {@code null} if none.
     * @param  file      the originating dataset file, or {@code null} if none.
     * @param  logger    an optional object where to log warnings, or {@code null} if none.
     * @return a wrapper for the given object, or {@code null} if the {@code netcdfCS} argument was null.
     * @throws ClassCastException if at least one axis is not an instance of the {@link CoordinateAxis1D} subclass.
     */
Creates a new  NetcdfCRS object, optionally using the given netCDF file for additional
information. This method performs the same work than  #wrap(CoordinateSystem), except
that more accurate coordinate axes may be created if a reference to the original dataset file
is provided. This apply especially to  CoordinateAxis1DTime.

@param  netcdfCS  the netCDF coordinate system to wrap, or  null if none.
@param  file      the originating dataset file, or  null if none.
@param  logger    an optional object where to log warnings, or  null if none.
@return a wrapper for the given object, or  null if the  netcdfCS argument was null.
@throws ClassCastException if at least one axis is not an instance of the  CoordinateAxis1D subclass.
Creates a new NetcdfCRS object optionally using the given netCDF file for additional information . This method performs the same work than #wrap ( CoordinateSystem ) except that more accurate coordinate axes may be created if a reference to the original dataset file is provided . This apply especially to CoordinateAxis1DTime . @param netcdfCS the netCDF coordinate system to wrap or null if none . @param file the originating dataset file or null if none . @param logger an optional object where to log warnings or null if none . @return a wrapper for the given object or null if the netcdfCS argument was null . @throws ClassCastException if at least one axis is not an instance of the CoordinateAxis1D subclass .
static NetcdfCRS wrap(final CoordinateSystem netcdfCS, final NetcdfDataset file, final Logger logger) {
        if (netcdfCS == null) {
            return null;
        }
        /*
         * The datum to use. Fixed to Earth for now, will need to become configurable in the future.
         */
        final NetcdfEllipsoid datum = NetcdfEllipsoid.SPHERE;
        /*
         * Separate the horizontal, vertical and temporal components. We need to iterate
         * over the netCDF axes in reverse order (see class javadoc). We don't use the
         * CoordinateAxis.getTaxis() and similar methods because we want to ensure that
         * the components are build in the same order than axes are found.
         */
        final List<NetcdfCRS> components = new ArrayList<>(4);
        final List<CoordinateAxis>  axes = netcdfCS.getCoordinateAxes();
        for (int i=axes.size(); --i>=0;) {
            CoordinateAxis1D axis = (CoordinateAxis1D) axes.get(i);
            if (axis != null) {
                final AxisType type = axis.getAxisType();
                if (type != null) { 
                    switch (type) {
                        case Pressure:
                        case Height:
                        case GeoZ: {
                            components.add(new Vertical(netcdfCS, axis));
                            continue;
                        }
                        case RunTime:
                        case Time: {
                            components.add(new Temporal(netcdfCS, Temporal.complete(axis, file, logger)));
                            continue;
                        }
                        case Lat:
                        case Lon: {
                            final int upper = i+1;
                            i = lower(axes, i, AxisType.Lat, AxisType.Lon);
                            components.add(new Geographic(datum, netcdfCS, axes.subList(i, upper)));
                            continue;
                        }
                        case GeoX:
                        case GeoY: {
                            final int upper = i+1;
                            i = lower(axes, i, AxisType.GeoX, AxisType.GeoY);
                            components.add(new Projected(datum, netcdfCS, axes.subList(i, upper)));
                            continue;
                        }
                    }
                }
            }
            components.clear();
            break;
        }
        final int size = components.size();
        switch (size) {
            /*
             * If we have been unable to split the CRS ourself in various components,
             * use the information provided by the netCDF library as a fallback. Note
             * that the CRS created that way may not be valid in the ISO 19111 sense.
             */
            case 0: {
                if (netcdfCS.isLatLon()) {
                    return new Geographic(datum, netcdfCS, axes);
                }
                if (netcdfCS.isGeoXY()) {
                    return new Projected(datum, netcdfCS, axes);
                }
                return new NetcdfCRS(netcdfCS, axes);
            }
            /*
             * If we have been able to create exactly one CRS, returns that CRS.
             */
            case 1: {
                return components.get(0);
            }
            /*
             * Otherwise create a CompoundCRS will all the components we have separated.
             */
            default: {
                return new Compound(netcdfCS, components.toArray(new NetcdfCRS[size]));
            }
        }
    }
static NetcdfCRS wrap ( final CoordinateSystem netcdfCS , final NetcdfDataset file , final Logger logger ) { if ( netcdfCS == null ) { return null ; } /*
         * The datum to use. Fixed to Earth for now, will need to become configurable in the future.
         */ final NetcdfEllipsoid datum = NetcdfEllipsoid . SPHERE ; /*
         * Separate the horizontal, vertical and temporal components. We need to iterate
         * over the netCDF axes in reverse order (see class javadoc). We don't use the
         * CoordinateAxis.getTaxis() and similar methods because we want to ensure that
         * the components are build in the same order than axes are found.
         */ final List < NetcdfCRS > components = new ArrayList < > ( 4 ) ; final List < CoordinateAxis > axes = netcdfCS . getCoordinateAxes ( ) ; for ( int i = axes . size ( ) ; -- i >= 0 ; ) { CoordinateAxis1D axis = ( CoordinateAxis1D ) axes . get ( i ) ; if ( axis != null ) { final AxisType type = axis . getAxisType ( ) ; if ( type != null ) { switch ( type ) { case Pressure : case Height : case GeoZ : { components . add ( new Vertical ( netcdfCS , axis ) ) ; continue ; } case RunTime : case Time : { components . add ( new Temporal ( netcdfCS , Temporal . complete ( axis , file , logger ) ) ) ; continue ; } case Lat : case Lon : { final int upper = i + 1 ; i = lower ( axes , i , AxisType . Lat , AxisType . Lon ) ; components . add ( new Geographic ( datum , netcdfCS , axes . subList ( i , upper ) ) ) ; continue ; } case GeoX : case GeoY : { final int upper = i + 1 ; i = lower ( axes , i , AxisType . GeoX , AxisType . GeoY ) ; components . add ( new Projected ( datum , netcdfCS , axes . subList ( i , upper ) ) ) ; continue ; } } } } components . clear ( ) ; break ; } final int size = components . size ( ) ; switch ( size ) { /*
             * If we have been unable to split the CRS ourself in various components,
             * use the information provided by the netCDF library as a fallback. Note
             * that the CRS created that way may not be valid in the ISO 19111 sense.
             */ case 0 : { if ( netcdfCS . isLatLon ( ) ) { return new Geographic ( datum , netcdfCS , axes ) ; } if ( netcdfCS . isGeoXY ( ) ) { return new Projected ( datum , netcdfCS , axes ) ; } return new NetcdfCRS ( netcdfCS , axes ) ; } /*
             * If we have been able to create exactly one CRS, returns that CRS.
             */ case 1 : { return components . get ( 0 ) ; } /*
             * Otherwise create a CompoundCRS will all the components we have separated.
             */ default : { return new Compound ( netcdfCS , components . toArray ( new NetcdfCRS [ size ] ) ) ; } } }
Creates a new {@code NetcdfCRS} object, optionally using the given netCDF file for additional
 information.
Creates a new { @code NetcdfCRS } object optionally using the given netCDF file for additional information .
// This is really null in some netCDF file. // Unknown axes: do not try to split.