signature:
public class GradsTimeDimension { /** * Replace the time template parameters in a filename
 * @ param filespec the file template
 * @ param timeIndex the time index
 * @ see " http : / / www . iges . org / grads / gadoc / templates . html "
 * @ return the filled in template */
public String replaceFileTemplate ( String filespec , int timeIndex ) { } }

implementation:
GradsTimeStruct ts = makeTimeStruct ( timeIndex ) ; // System . out . println ( ts ) ;
String retString = filespec ; String format ; while ( hasTimeTemplate ( retString ) ) { // initial time
if ( retString . indexOf ( "%ix1" ) >= 0 ) { retString = retString . replaceAll ( "%ix1" , String . format ( "%d" , initialTime . year / 10 ) ) ; } if ( retString . indexOf ( "%ix3" ) >= 0 ) { retString = retString . replaceAll ( "%ix3" , String . format ( "%03d" , initialTime . year / 10 ) ) ; } if ( retString . indexOf ( "%iy2" ) >= 0 ) { int cent = initialTime . year / 100 ; int val = initialTime . year - cent * 100 ; retString = retString . replaceAll ( "%iy2" , String . format ( "%02d" , val ) ) ; } if ( retString . indexOf ( "%iy4" ) >= 0 ) { retString = retString . replaceAll ( "%iy4" , String . format ( "%d" , initialTime . year ) ) ; } if ( retString . indexOf ( "%im1" ) >= 0 ) { retString = retString . replaceAll ( "%im1" , String . format ( "%d" , initialTime . month ) ) ; } if ( retString . indexOf ( "%im2" ) >= 0 ) { retString = retString . replaceAll ( "%im2" , String . format ( "%02d" , initialTime . month ) ) ; } if ( retString . indexOf ( "%imc" ) >= 0 ) { retString = retString . replaceAll ( "%imc" , GradsTimeStruct . months [ initialTime . month - 1 ] ) ; } if ( retString . indexOf ( "%id1" ) >= 0 ) { retString = retString . replaceAll ( "%id1" , String . format ( "%d" , initialTime . day ) ) ; } if ( retString . indexOf ( "%id2" ) >= 0 ) { retString = retString . replaceAll ( "%id2" , String . format ( "%02d" , initialTime . day ) ) ; } if ( retString . indexOf ( "%ih1" ) >= 0 ) { retString = retString . replaceAll ( "%ih1" , String . format ( "%d" , initialTime . hour ) ) ; } if ( retString . indexOf ( "%ih2" ) >= 0 ) { retString = retString . replaceAll ( "%ih2" , String . format ( "%02d" , initialTime . hour ) ) ; } if ( retString . indexOf ( "%ih3" ) >= 0 ) { retString = retString . replaceAll ( "%ih3" , String . format ( "%03d" , initialTime . hour ) ) ; } if ( retString . indexOf ( "%in2" ) >= 0 ) { retString = retString . replaceAll ( "%in2" , String . format ( "%02d" , initialTime . minute ) ) ; } // any time
// decade
if ( retString . indexOf ( "%x1" ) >= 0 ) { retString = retString . replaceAll ( "%x1" , String . format ( "%d" , ts . year / 10 ) ) ; } if ( retString . indexOf ( "%x3" ) >= 0 ) { retString = retString . replaceAll ( "%x3" , String . format ( "%03d" , ts . year / 10 ) ) ; } // year
if ( retString . indexOf ( "%y2" ) >= 0 ) { int cent = ts . year / 100 ; int val = ts . year - cent * 100 ; retString = retString . replaceAll ( "%y2" , String . format ( "%02d" , val ) ) ; } if ( retString . indexOf ( "%y4" ) >= 0 ) { retString = retString . replaceAll ( "%y4" , String . format ( "%d" , ts . year ) ) ; } // month
if ( retString . indexOf ( "%m1" ) >= 0 ) { retString = retString . replaceAll ( "%m1" , String . format ( "%d" , ts . month ) ) ; } if ( retString . indexOf ( "%m2" ) >= 0 ) { retString = retString . replaceAll ( "%m2" , String . format ( "%02d" , ts . month ) ) ; } if ( retString . indexOf ( "%mc" ) >= 0 ) { retString = retString . replaceAll ( "%mc" , GradsTimeStruct . months [ ts . month - 1 ] ) ; } // day
if ( retString . indexOf ( "%d1" ) >= 0 ) { retString = retString . replaceAll ( "%d1" , String . format ( "%d" , ts . day ) ) ; } if ( retString . indexOf ( "%d2" ) >= 0 ) { retString = retString . replaceAll ( "%d2" , String . format ( "%02d" , ts . day ) ) ; } // hour
if ( retString . indexOf ( "%h1" ) >= 0 ) { retString = retString . replaceAll ( "%h1" , String . format ( "%d" , ts . hour ) ) ; } if ( retString . indexOf ( "%h2" ) >= 0 ) { retString = retString . replaceAll ( "%h2" , String . format ( "%02d" , ts . hour ) ) ; } if ( retString . indexOf ( "%h3" ) >= 0 ) { retString = retString . replaceAll ( "%h3" , String . format ( "%03d" , ts . hour ) ) ; } // minute
if ( retString . indexOf ( "%n2" ) >= 0 ) { retString = retString . replaceAll ( "%n2" , String . format ( "%02d" , ts . minute ) ) ; } // julian day
if ( retString . indexOf ( "%j3" ) >= 0 ) { retString = retString . replaceAll ( "%j3" , String . format ( "%03d" , ts . jday ) ) ; } // time index ( 1 based )
if ( retString . indexOf ( "%t1" ) >= 0 ) { retString = retString . replaceAll ( "%t1" , String . format ( "%d" , timeIndex + 1 ) ) ; } if ( retString . indexOf ( "%t2" ) >= 0 ) { retString = retString . replaceAll ( "%t2" , String . format ( "%02d" , timeIndex + 1 ) ) ; } if ( retString . indexOf ( "%t3" ) >= 0 ) { retString = retString . replaceAll ( "%t3" , String . format ( "%03d" , timeIndex + 1 ) ) ; } if ( retString . indexOf ( "%t4" ) >= 0 ) { retString = retString . replaceAll ( "%t4" , String . format ( "%04d" , timeIndex + 1 ) ) ; } if ( retString . indexOf ( "%t5" ) >= 0 ) { retString = retString . replaceAll ( "%t5" , String . format ( "%05d" , timeIndex + 1 ) ) ; } if ( retString . indexOf ( "%t6" ) >= 0 ) { retString = retString . replaceAll ( "%t6" , String . format ( "%06d" , timeIndex + 1 ) ) ; } // time index ( 0 based )
if ( retString . indexOf ( "%tm1" ) >= 0 ) { retString = retString . replaceAll ( "%tm1" , String . format ( "%d" , timeIndex ) ) ; } if ( retString . indexOf ( "%tm2" ) >= 0 ) { retString = retString . replaceAll ( "%tm2" , String . format ( "%02d" , timeIndex ) ) ; } if ( retString . indexOf ( "%tm3" ) >= 0 ) { retString = retString . replaceAll ( "%tm3" , String . format ( "%03d" , timeIndex ) ) ; } if ( retString . indexOf ( "%tm4" ) >= 0 ) { retString = retString . replaceAll ( "%tm4" , String . format ( "%04d" , timeIndex ) ) ; } if ( retString . indexOf ( "%tm5" ) >= 0 ) { retString = retString . replaceAll ( "%tm5" , String . format ( "%05d" , timeIndex ) ) ; } if ( retString . indexOf ( "%tm6" ) >= 0 ) { retString = retString . replaceAll ( "%tm6" , String . format ( "%06d" , timeIndex ) ) ; } // forecast hours
if ( retString . indexOf ( "%f" ) >= 0 ) { int mins = ( int ) getValues ( ) [ timeIndex ] * 60 ; int tdif ; if ( retString . indexOf ( "%f2" ) >= 0 ) { format = "%02d" ; tdif = mins / 60 ; if ( tdif > 99 ) { format = "%d" ; } retString = retString . replaceAll ( "%f2" , String . format ( format , tdif ) ) ; } if ( retString . indexOf ( "%f3" ) >= 0 ) { format = "%03d" ; tdif = mins / 60 ; if ( tdif > 999 ) { format = "%d" ; } retString = retString . replaceAll ( "%f3" , String . format ( format , tdif ) ) ; } if ( retString . indexOf ( "%fn2" ) >= 0 ) { format = "%02d" ; if ( mins > 99 ) { format = "%d" ; } retString = retString . replaceAll ( "%fn2" , String . format ( format , mins ) ) ; } if ( retString . indexOf ( "%fhn2" ) >= 0 ) { tdif = mins ; int hrs = tdif / 60 ; int mns = tdif - ( hrs * 60 ) ; format = "%02d%02d" ; if ( hrs > 99 ) { format = "%d%02d" ; } retString = retString . replaceAll ( "%fhn2" , String . format ( format , hrs , mns ) ) ; } if ( retString . indexOf ( "%fdhn2" ) >= 0 ) { tdif = mins ; int dys = tdif / 1440 ; int hrs = ( tdif - ( dys * 1440 ) ) / 60 ; int mns = tdif - ( dys * 1440 ) - ( hrs * 60 ) ; format = "%02d%02d%02d" ; if ( dys > 99 ) { format = "%d%02d%02d" ; } retString = retString . replaceAll ( "%fdhn2" , String . format ( format , dys , hrs , mns ) ) ; } } } return retString ;


signature:
public class GradsTimeDimension { /** * Does this file definition have a time template in it ?
 * @ param template the file template
 * @ return true if it does */
public static boolean hasTimeTemplate ( String template ) { } }

implementation: for ( int i = 0 ; i < timeTemplates . length ; i ++ ) { if ( template . indexOf ( timeTemplates [ i ] ) >= 0 ) { return true ; } } return false ;


signature:
public class TransverseMercator { /** * Does the line between these two points cross the projection " seam " .
 * @ param pt1 the line goes between these two points
 * @ param pt2 the line goes between these two points
 * @ return false if there is no seam */
public boolean crossSeam ( ProjectionPoint pt1 , ProjectionPoint pt2 ) { } }

implementation:
// either point is infinite
if ( ProjectionPointImpl . isInfinite ( pt1 ) || ProjectionPointImpl . isInfinite ( pt2 ) ) { return true ; } double y1 = pt1 . getY ( ) - falseNorthing ; double y2 = pt2 . getY ( ) - falseNorthing ; // opposite signed long lines
return ( y1 * y2 < 0 ) && ( Math . abs ( y1 - y2 ) > 2 * earthRadius ) ;


signature:
public class TransverseMercator { /** * Convert a LatLonPoint to projection coordinates
 * @ param latLon convert from these lat , lon coordinates
 * @ param result the object to write to
 * @ return the given result */
public ProjectionPoint latLonToProj ( LatLonPoint latLon , ProjectionPointImpl result ) { } }

implementation:
double toX , toY ; double fromLat = latLon . getLatitude ( ) ; double fromLon = latLon . getLongitude ( ) ; double lon = Math . toRadians ( fromLon ) ; double lat = Math . toRadians ( fromLat ) ; double dlon = lon - lon0 ; double b = Math . cos ( lat ) * Math . sin ( dlon ) ; if ( ( Math . abs ( Math . abs ( b ) - 1.0 ) ) < TOLERANCE ) { // infinite projection
toX = Double . POSITIVE_INFINITY ; toY = Double . POSITIVE_INFINITY ; } else { toX = scale * SpecialMathFunction . atanh ( b ) ; toY = scale * ( Math . atan2 ( Math . tan ( lat ) , Math . cos ( dlon ) ) - lat0 ) ; } result . setLocation ( toX + falseEasting , toY + falseNorthing ) ; return result ;


signature:
public class TransverseMercator { /** * Convert projection coordinates to a LatLonPoint
 * Note : a new object is not created on each call for the return value .
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint convert to these lat / lon coordinates */
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation: double toLat , toLon ; double fromX = world . getX ( ) ; double fromY = world . getY ( ) ; double x = ( fromX - falseEasting ) / scale ; double d = ( fromY - falseNorthing ) / scale + lat0 ; toLon = Math . toDegrees ( lon0 + Math . atan2 ( Math . sinh ( x ) , Math . cos ( d ) ) ) ; toLat = Math . toDegrees ( Math . asin ( Math . sin ( d ) / Math . cosh ( x ) ) ) ; result . setLatitude ( toLat ) ; result . setLongitude ( toLon ) ; return result ;


signature:
public class TransverseMercator { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] ,
 * where from [ 0 ] [ i ] , from [ 1 ] [ i ] is the ( lat , lon )
 * coordinate of the ith point
 * @ param to resulting array of projection coordinates ,
 * where to [ 0 ] [ i ] , to [ 1 ] [ i ] is the ( x , y ) coordinate
 * of the ith point
 * @ param latIndex index of latitude in " from "
 * @ param lonIndex index of longitude in " from "
 * @ return the " to " array . */
public float [ ] [ ] latLonToProj ( float [ ] [ ] from , float [ ] [ ] to , int latIndex , int lonIndex ) { } }

implementation:
int cnt = from [ 0 ] . length ; float [ ] fromLatA = from [ latIndex ] ; float [ ] fromLonA = from [ lonIndex ] ; float [ ] resultXA = to [ INDEX_X ] ; float [ ] resultYA = to [ INDEX_Y ] ; double toX , toY ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromLat = fromLatA [ i ] ; double fromLon = fromLonA [ i ] ; double lon = Math . toRadians ( fromLon ) ; double lat = Math . toRadians ( fromLat ) ; double dlon = lon - lon0 ; double b = Math . cos ( lat ) * Math . sin ( dlon ) ; // infinite projection
if ( ( Math . abs ( Math . abs ( b ) - 1.0 ) ) < TOLERANCE ) { toX = 0.0 ; toY = 0.0 ; } else { toX = scale * SpecialMathFunction . atanh ( b ) + falseEasting ; toY = scale * ( Math . atan2 ( Math . tan ( lat ) , Math . cos ( dlon ) ) - lat0 ) + falseNorthing ; } resultXA [ i ] = ( float ) toX ; resultYA [ i ] = ( float ) toY ; } return to ;


signature:
public class TransverseMercator { /** * Convert lat / lon coordinates to projection coordinates .
 * @ param from array of lat / lon coordinates : from [ 2 ] [ n ] , where
 * ( from [ 0 ] [ i ] , from [ 1 ] [ i ] ) is the ( lat , lon ) coordinate
 * of the ith point
 * @ param to resulting array of projection coordinates : to [ 2 ] [ n ]
 * where ( to [ 0 ] [ i ] , to [ 1 ] [ i ] ) is the ( x , y ) coordinate
 * of the ith point
 * @ return the " to " array */
public double [ ] [ ] projToLatLon ( double [ ] [ ] from , double [ ] [ ] to ) { } }

implementation: int cnt = from [ 0 ] . length ; double [ ] fromXA = from [ INDEX_X ] ; double [ ] fromYA = from [ INDEX_Y ] ; double [ ] toLatA = to [ INDEX_LAT ] ; double [ ] toLonA = to [ INDEX_LON ] ; double toLat , toLon ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromX = fromXA [ i ] ; double fromY = fromYA [ i ] ; double x = ( fromX - falseEasting ) / scale ; double d = ( fromY - falseNorthing ) / scale + lat0 ; toLon = Math . toDegrees ( lon0 + Math . atan2 ( Math . sinh ( x ) , Math . cos ( d ) ) ) ; toLat = Math . toDegrees ( Math . asin ( Math . sin ( d ) / Math . cosh ( x ) ) ) ; toLatA [ i ] = ( double ) toLat ; toLonA [ i ] = ( double ) toLon ; } return to ;


signature:
public class FunctionLibrary { /** * Adds a function to the library . The function will be inspected
 * to determine whether it is a boolean or BaseType function . */
public void add ( ServerSideFunction function ) { } }

implementation: if ( function instanceof BoolFunction ) { boolFunctions . put ( function . getName ( ) , function ) ; } if ( function instanceof BTFunction ) { btFunctions . put ( function . getName ( ) , function ) ; }


signature:
public class FunctionLibrary { /** * Retrieves a boolean function from the library . If the function
 * is not found the library will attempt to load it using the
 * mechanism described in the class documentation .
 * @ param name The name of the function being requested .
 * @ return Null if the function is not
 * in the library , and the attempt to load it fails . */
public BoolFunction getBoolFunction ( String name ) throws NoSuchFunctionException { } }

implementation: if ( ! boolFunctions . containsKey ( name ) ) { loadNewFunction ( name ) ; } return ( BoolFunction ) boolFunctions . get ( name ) ;


signature:
public class FunctionLibrary { /** * Retrieves a BaseType function from the library . If the function
 * is not found the library will attempt to load it using the
 * mechanism described in the class documentation .
 * @ param name The name of the function being requested .
 * @ return Null if the function is not
 * in the library , and the attempt to load it fails . */
public BTFunction getBTFunction ( String name ) throws NoSuchFunctionException { } }

implementation: if ( ! btFunctions . containsKey ( name ) ) { loadNewFunction ( name ) ; } return ( BTFunction ) btFunctions . get ( name ) ;


signature:
public class FunctionLibrary { /** * Tries to load a function with the given name . */
protected void loadNewFunction ( String name ) { } }

implementation: try { String fullName = prefix + name ; Class value = Class . forName ( fullName ) ; if ( ( ServerSideFunction . class ) . isAssignableFrom ( value ) ) { add ( ( ServerSideFunction ) value . newInstance ( ) ) ; return ; } } catch ( ClassNotFoundException e ) { } catch ( IllegalAccessException e ) { } catch ( InstantiationException e ) { }


signature:
public class DefaultConvention { /** * look for aliases .
 * @ param ds containing dataset
 * @ param axisType look for this axis type
 * @ return name of axis of that type */
private String findCoordinateName ( NetcdfDataset ds , AxisType axisType ) { } }

implementation: List < Variable > vlist = ds . getVariables ( ) ; for ( Variable aVlist : vlist ) { VariableEnhanced ve = ( VariableEnhanced ) aVlist ; if ( axisType == getAxisType ( ds , ve ) ) { return ve . getFullName ( ) ; } } return null ;


signature:
public class FnmocTables { /** * genProcess */
@ Override @ Nullable public String getGeneratingProcessName ( int genProcess ) { } }

implementation: if ( genProcessMap == null ) genProcessMap = readGenProcess ( fnmocTableA ) ; if ( genProcessMap == null ) return null ; return genProcessMap . get ( genProcess ) ;


signature:
public class FnmocTables { /** * / levels */
protected VertCoordType getLevelType ( int code ) { } }

implementation: if ( levelTypesMap == null ) levelTypesMap = readFnmocTable3 ( fnmocTable3 ) ; if ( levelTypesMap == null ) return super . getLevelType ( code ) ; VertCoordType levelType = levelTypesMap . get ( code ) ; if ( levelType != null ) return levelType ; return super . getLevelType ( code ) ;


signature:
public class FnmocTables { /** * < entry >
 * < grib1Id > 222 < / grib1Id >
 * < fnmocId > mid _ cld < / fnmocId >
 * < name > mid _ cld < / name >
 * < description > middle cloud layer < / description >
 * < status > deprecated < / status >
 * < / entry >
 * < fnmocTable >
 * < entry >
 * < grib1Id > 001 < / grib1Id >
 * < fnmocId > surface < / fnmocId >
 * < name > surface < / name >
 * < description > ground or water surface ( the atmosphere ' s lower boundary , land / sea surface ) < / description >
 * < status > current < / status >
 * < / entry > */
@ Nullable private HashMap < Integer , VertCoordType > readFnmocTable3 ( String path ) { } }

implementation:
try ( InputStream is = GribResourceReader . getInputStream ( path ) ) { SAXBuilder builder = new SAXBuilder ( ) ; org . jdom2 . Document doc = builder . build ( is ) ; Element root = doc . getRootElement ( ) ; HashMap < Integer , VertCoordType > result = new HashMap < > ( 200 ) ; Element fnmocTable = root . getChild ( "fnmocTable" ) ; List < Element > params = fnmocTable . getChildren ( "entry" ) ; for ( Element elem1 : params ) { int code = Integer . parseInt ( elem1 . getChildText ( "grib1Id" ) ) ; if ( code < 129 ) continue ; String desc = elem1 . getChildText ( "description" ) ; String abbrev = elem1 . getChildText ( "name" ) ; String units = elem1 . getChildText ( "units" ) ; if ( units == null ) units = ( code == 219 ) ? "Pa" : "" ; String datum = elem1 . getChildText ( "datum" ) ; boolean isLayer = elem1 . getChild ( "isLayer" ) != null ; boolean isPositiveUp = elem1 . getChild ( "isPositiveUp" ) != null ; VertCoordType lt = new VertCoordType ( code , desc , abbrev , units , datum , isPositiveUp , isLayer ) ; result . put ( code , lt ) ; } return result ; // all at once - thread safe
} catch ( IOException | JDOMException e ) { logger . error ( "Cant read FnmocTable3 = " + path , e ) ; return null ; }


signature:
public class LocalDatasetSource { /** * Build an unnamed InvCatalog for this DatasetSource and return the
 * top - level InvDataset . The ResultService for this DatasetSource is
 * used to create the InvService for the new InvCatalog . Each InvDataset
 * in the catalog is named with the location of the object they represent
 * on the dataset source .
 * @ return the top - level dataset of the newly constructed InvCatalog .
 * @ throws IOException if top - level dataset does not exist or is not a collection dataset . */
protected InvCatalog createSkeletonCatalog ( String prefixUrlPath ) throws IOException { } }

implementation:
this . checkAccessPoint ( ) ; // Create catalog .
InvCatalogImpl catalog = new InvCatalogImpl ( null , null , null ) ; // this . getName ( ) , null , null ) ;
// Create service .
InvService service = new InvService ( this . getResultService ( ) . getName ( ) , this . getResultService ( ) . getServiceType ( ) . toString ( ) , this . getResultService ( ) . getBase ( ) , this . getResultService ( ) . getSuffix ( ) , this . getResultService ( ) . getDescription ( ) ) ; for ( Iterator it = this . getResultService ( ) . getProperties ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addProperty ( ( InvProperty ) it . next ( ) ) ; } for ( Iterator it = this . getResultService ( ) . getServices ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addService ( ( InvService ) it . next ( ) ) ; } // Add service to catalog .
catalog . addService ( service ) ; // Create top - level dataset .
File apFile = new File ( this . getAccessPoint ( ) ) ; InvDatasetImpl topDs = new LocalInvDataset ( null , apFile , prefixUrlPath ) ; // Set the serviceName ( inherited by all datasets ) in top - level dataset .
ThreddsMetadata tm = new ThreddsMetadata ( false ) ; tm . setServiceName ( service . getName ( ) ) ; InvMetadata md = new InvMetadata ( topDs , null , XMLEntityResolver . CATALOG_NAMESPACE_10 , "" , true , true , null , tm ) ; ThreddsMetadata tm2 = new ThreddsMetadata ( false ) ; tm2 . addMetadata ( md ) ; topDs . setLocalMetadata ( tm2 ) ; // Add top - level dataset to catalog .
catalog . addDataset ( topDs ) ; // Tie up any loose ends in catalog with finish ( ) .
( ( InvCatalogImpl ) catalog ) . finish ( ) ; return ( catalog ) ;


signature:
public class LocalDatasetSource { /** * Return a list of the InvDatasets contained in the given collection dataset
 * on this DatasetSource .
 * @ param dataset - the collection dataset to be expanded .
 * @ return A list of the InvDatasets contained in the given collection dataset .
 * @ throws IllegalArgumentException when given dataset is not a collection dataset .
 * @ throws NullPointerException if given dataset is null .
 * @ throws ClassCastException if the given InvDataset is not a LocalInvDataset . */
protected List expandThisLevel ( InvDataset dataset , String prefixUrlPath ) { } }

implementation:
if ( dataset == null ) throw new NullPointerException ( "Given dataset cannot be null." ) ; if ( ! isCollection ( dataset ) ) throw new IllegalArgumentException ( "Dataset \"" + dataset . getName ( ) + "\" is not a collection dataset." ) ; // Deal with all files in this directory .
File theDir = new File ( ( ( LocalInvDataset ) dataset ) . getLocalPath ( ) ) ; File [ ] allFiles = theDir . listFiles ( ) ; InvDataset curDs = null ; ArrayList list = new ArrayList ( ) ; for ( int i = 0 ; i < allFiles . length ; i ++ ) { try { curDs = new LocalInvDataset ( dataset , allFiles [ i ] , prefixUrlPath ) ; } catch ( IOException e ) { // Given file doesn ' t exist or is not under the accessPointHeader directory , skip .
continue ; } list . add ( curDs ) ; } return ( list ) ;


signature:
public class McIDASLookup { /** * gets parameter table , then grib1 parameter based on number .
 * @ param gr GridRecord
 * @ return Parameter */
public final GridParameter getParameter ( GridRecord gr ) { } }

implementation: McIDASGridRecord mgr = ( McIDASGridRecord ) gr ; String name = mgr . getParameterName ( ) ; String desc = mgr . getGridDescription ( ) ; if ( desc . trim ( ) . equals ( "" ) ) { desc = name ; } String unit = visad . jmet . MetUnits . makeSymbol ( mgr . getParamUnitName ( ) ) ; return new GridParameter ( 0 , name , desc , unit ) ;


signature:
public class McIDASLookup { /** * gets the LevelName . */
public final String getLevelName ( GridRecord gr ) { } }

implementation: if ( cust != null ) { String result = cust . getLevelNameShort ( gr . getLevelType1 ( ) ) ; if ( result != null ) return result ; } String levelUnit = getLevelUnit ( gr ) ; if ( levelUnit != null ) { int level1 = ( int ) gr . getLevel1 ( ) ; int level2 = ( int ) gr . getLevel2 ( ) ; if ( levelUnit . equalsIgnoreCase ( "hPa" ) ) { return "pressure" ; } else if ( level1 == 1013 ) { return "mean sea level" ; } else if ( level1 == 0 ) { return "tropopause" ; } else if ( level1 == 1001 ) { return "surface" ; } else if ( level2 != 0 ) { return "layer" ; } } return "" ;


signature:
public class McIDASLookup { /** * gets the LevelDescription . */
public final String getLevelDescription ( GridRecord gr ) { } }

implementation:
if ( cust != null ) { String result = cust . getLevelDescription ( gr . getLevelType1 ( ) ) ; if ( result != null ) return result ; } // TODO : flesh this out
return getLevelName ( gr ) ;


signature:
public class McIDASLookup { /** * gets the LevelUnit . */
public final String getLevelUnit ( GridRecord gr ) { } }

implementation: if ( cust != null ) { String result = cust . getLevelUnits ( gr . getLevelType1 ( ) ) ; if ( result != null ) return result ; } return visad . jmet . MetUnits . makeSymbol ( ( ( McIDASGridRecord ) gr ) . getLevelUnitName ( ) ) ;


signature:
public class McIDASLookup { /** * gets the ProjectionType . */
public final int getProjectionType ( GridDefRecord gds ) { } }

implementation: String name = getProjectionName ( gds ) . trim ( ) ; switch ( name ) { case "MERC" : return Mercator ; case "CONF" : return LambertConformal ; case "PS" : return PolarStereographic ; default : return - 1 ; }


signature:
public class McIDASLookup { /** * is this a VerticalCoordinate . */
public final boolean isVerticalCoordinate ( GridRecord gr ) { } }

implementation: if ( cust != null ) { return cust . isVerticalCoordinate ( gr . getLevelType1 ( ) ) ; } int type = gr . getLevelType1 ( ) ; if ( ( ( McIDASGridRecord ) gr ) . hasGribInfo ( ) ) { if ( type == 20 ) { return true ; } if ( type == 100 ) { return true ; } if ( type == 101 ) { return true ; } if ( ( type >= 103 ) && ( type <= 128 ) ) { return true ; } if ( type == 141 ) { return true ; } if ( type == 160 ) { return true ; } } else if ( getLevelUnit ( gr ) . equals ( "hPa" ) ) { return true ; } return false ;


signature:
public class McIDASLookup { /** * Is this a layer ?
 * @ param gr record to check
 * @ return true if a layer */
public boolean isLayer ( GridRecord gr ) { } }

implementation: if ( cust != null ) { return cust . isLayer ( gr . getLevelType1 ( ) ) ; } if ( gr . getLevel2 ( ) == 0 ) { return false ; } return true ;


signature:
public class CdmrfWriter { /** * / * message CoverageDataset {
 * required string name = 1;
 * repeated Attribute atts = 2;
 * required Rectangle latlonRect = 3;
 * optional Rectangle projRect = 4;
 * required CalendarDateRange timeRange = 5;
 * repeated CoordSys coordSys = 6;
 * repeated CoordTransform coordTransforms = 7;
 * repeated CoordAxis coordAxes = 8;
 * repeated Coverage grids = 9; */
CdmrFeatureProto . CoverageDataset . Builder encodeHeader ( CoverageCollection gridDataset , String location ) { } }

implementation: CdmrFeatureProto . CoverageDataset . Builder builder = CdmrFeatureProto . CoverageDataset . newBuilder ( ) ; builder . setName ( location ) ; builder . setCoverageType ( convertCoverageType ( gridDataset . getCoverageType ( ) ) ) ; builder . setDateRange ( encodeDateRange ( gridDataset . getCalendarDateRange ( ) ) ) ; if ( gridDataset . getLatlonBoundingBox ( ) != null ) builder . setLatlonRect ( encodeRectangle ( gridDataset . getLatlonBoundingBox ( ) ) ) ; if ( gridDataset . getProjBoundingBox ( ) != null ) builder . setProjRect ( encodeRectangle ( gridDataset . getProjBoundingBox ( ) ) ) ; for ( Attribute att : gridDataset . getGlobalAttributes ( ) ) builder . addAtts ( NcStream . encodeAtt ( att ) ) ; for ( CoverageCoordSys gcs : gridDataset . getCoordSys ( ) ) builder . addCoordSys ( encodeCoordSys ( gcs ) ) ; for ( CoverageTransform gct : gridDataset . getCoordTransforms ( ) ) builder . addCoordTransforms ( encodeCoordTransform ( gct ) ) ; for ( CoverageCoordAxis axis : gridDataset . getCoordAxes ( ) ) builder . addCoordAxes ( encodeCoordAxis ( axis ) ) ; for ( Coverage grid : gridDataset . getCoverages ( ) ) builder . addGrids ( encodeGrid ( grid ) ) ; return builder ;


signature:
public class CdmrfWriter { /** * / * message Rectangle {
 * required double startx = 1;
 * required double starty = 2;
 * required double incx = 3;
 * required double incy = 4; */
CdmrFeatureProto . Rectangle . Builder encodeRectangle ( LatLonRect rect ) { } }

implementation:
CdmrFeatureProto . Rectangle . Builder builder = CdmrFeatureProto . Rectangle . newBuilder ( ) ; // this ( r . getLowerLeftPoint ( ) , r . getUpperRightPoint ( ) . getLatitude ( ) - r . getLowerLeftPoint ( ) . getLatitude ( ) , r . getWidth ( ) ) ;
LatLonPoint ll = rect . getLowerLeftPoint ( ) ; LatLonPoint ur = rect . getUpperRightPoint ( ) ; builder . setStartx ( ll . getLongitude ( ) ) ; builder . setStarty ( ll . getLatitude ( ) ) ; builder . setIncx ( rect . getWidth ( ) ) ; builder . setIncy ( ur . getLatitude ( ) - ll . getLatitude ( ) ) ; return builder ;


signature:
public class CdmrfWriter { /** * / * message CalendarDateRange {
 * required int64 start = 1;
 * required int64 end = 2;
 * required int32 calendar = 3 ; / / calendar ordinal */
CdmrFeatureProto . CalendarDateRange . Builder encodeDateRange ( CalendarDateRange dateRange ) { } }

implementation: CdmrFeatureProto . CalendarDateRange . Builder builder = CdmrFeatureProto . CalendarDateRange . newBuilder ( ) ; builder . setStart ( dateRange . getStart ( ) . getMillis ( ) ) ; builder . setEnd ( dateRange . getEnd ( ) . getMillis ( ) ) ; Calendar cal = dateRange . getStart ( ) . getCalendar ( ) ; builder . setCalendar ( convertCalendar ( cal ) ) ; return builder ;


signature:
public class CdmrfWriter { /** * message Coverage {
 * required string name = 1 ; / / short name
 * required DataType dataType = 2;
 * optional bool unsigned = 3 [ default = false ] ;
 * repeated Attribute atts = 4;
 * required string coordSys = 5; */
CdmrFeatureProto . Coverage . Builder encodeGrid ( Coverage grid ) { } }

implementation: CdmrFeatureProto . Coverage . Builder builder = CdmrFeatureProto . Coverage . newBuilder ( ) ; builder . setName ( grid . getName ( ) ) ; builder . setDataType ( NcStream . convertDataType ( grid . getDataType ( ) ) ) ; for ( Attribute att : grid . getAttributes ( ) ) builder . addAtts ( NcStream . encodeAtt ( att ) ) ; builder . setUnits ( grid . getUnitsString ( ) ) ; builder . setDescription ( grid . getDescription ( ) ) ; builder . setCoordSys ( grid . getCoordSysName ( ) ) ; return builder ;


signature:
public class CdmrfWriter { /** * / * message CoordSys {
 * required string name = 1 ; / / must be unique in dataset ' s CoordSys
 * repeated string axisNames = 2;
 * repeated string transformNames = 3;
 * optional CoverageType coverageType = 5; */
CdmrFeatureProto . CoordSys . Builder encodeCoordSys ( CoverageCoordSys gcs ) { } }

implementation: CdmrFeatureProto . CoordSys . Builder builder = CdmrFeatureProto . CoordSys . newBuilder ( ) ; builder . setName ( gcs . getName ( ) ) ; builder . setCoverageType ( convertCoverageType ( gcs . getCoverageType ( ) ) ) ; for ( String axis : gcs . getAxisNames ( ) ) builder . addAxisNames ( axis ) ; for ( String gct : gcs . getTransformNames ( ) ) builder . addTransformNames ( gct ) ; return builder ;


signature:
public class CdmrfWriter { /** * / * message CoordTransform {
 * required bool isHoriz = 1;
 * required string name = 2;
 * repeated Attribute params = 3; */
CdmrFeatureProto . CoordTransform . Builder encodeCoordTransform ( CoverageTransform gct ) { } }

implementation: CdmrFeatureProto . CoordTransform . Builder builder = CdmrFeatureProto . CoordTransform . newBuilder ( ) ; builder . setIsHoriz ( gct . isHoriz ( ) ) ; builder . setName ( gct . getName ( ) ) ; for ( Attribute att : gct . getAttributes ( ) ) builder . addParams ( NcStream . encodeAtt ( att ) ) ; return builder ;


signature:
public class CdmrfWriter { /** * / * message CoordAxis {
 * required string name = 1;
 * required DataType dataType = 2;
 * required int32 axisType = 3 ; / / ucar . nc2 . constants . AxisType ordinal
 * required int64 nvalues = 4;
 * required string units = 5;
 * optional bool isRegular = 6;
 * required double min = 7 ; / / required ? ?
 * required double max = 8;
 * optional double resolution = 9; */
CdmrFeatureProto . CoordAxis . Builder encodeCoordAxis ( CoverageCoordAxis axis ) { } }

implementation: CdmrFeatureProto . CoordAxis . Builder builder = CdmrFeatureProto . CoordAxis . newBuilder ( ) ; builder . setName ( axis . getName ( ) ) ; builder . setDataType ( NcStream . convertDataType ( axis . getDataType ( ) ) ) ; builder . setAxisType ( convertAxisType ( axis . getAxisType ( ) ) ) ; builder . setNvalues ( axis . getNcoords ( ) ) ; if ( axis . getUnits ( ) != null ) builder . setUnits ( axis . getUnits ( ) ) ; if ( axis . getDescription ( ) != null ) builder . setDescription ( axis . getDescription ( ) ) ; builder . setDepend ( convertDependenceType ( axis . getDependenceType ( ) ) ) ; for ( String s : axis . getDependsOnList ( ) ) builder . addDependsOn ( s ) ; if ( axis instanceof LatLonAxis2D ) { LatLonAxis2D latlon2D = ( LatLonAxis2D ) axis ; for ( int shape : latlon2D . getShape ( ) ) builder . addShape ( shape ) ; } for ( Attribute att : axis . getAttributes ( ) ) builder . addAtts ( NcStream . encodeAtt ( att ) ) ; builder . setSpacing ( convertSpacing ( axis . getSpacing ( ) ) ) ; builder . setStartValue ( axis . getStartValue ( ) ) ; builder . setEndValue ( axis . getEndValue ( ) ) ; builder . setResolution ( axis . getResolution ( ) ) ; if ( ! axis . isRegular ( ) && axis . getNcoords ( ) < MAX_INLINE_NVALUES ) { double [ ] values = axis . getValues ( ) ; ByteBuffer bb = ByteBuffer . allocate ( 8 * values . length ) ; DoubleBuffer db = bb . asDoubleBuffer ( ) ; db . put ( values ) ; builder . setValues ( ByteString . copyFrom ( bb . array ( ) ) ) ; } return builder ;


signature:
public class CdmrfWriter { /** * public enum Type { Coverage , Curvilinear , Grid , Swath , Fmrc } */
static public CdmrFeatureProto . CoverageType convertCoverageType ( FeatureType type ) { } }

implementation: switch ( type ) { case COVERAGE : return CdmrFeatureProto . CoverageType . General ; case CURVILINEAR : return CdmrFeatureProto . CoverageType . Curvilinear ; case GRID : return CdmrFeatureProto . CoverageType . Grid ; case SWATH : return CdmrFeatureProto . CoverageType . Swath ; case FMRC : return CdmrFeatureProto . CoverageType . Fmrc ; } throw new IllegalStateException ( "illegal CoverageType " + type ) ;


signature:
public class CdmrfWriter { /** * message GeoReferencedArray {
 * required string gridName = 1 ; / / full escaped name .
 * required DataType dataType = 2;
 * optional bool bigend = 3 [ default = true ] ;
 * optional uint32 version = 4 [ default = 0 ] ;
 * optional Compress compress = 5 [ default = NONE ] ;
 * optional uint32 uncompressedSize = 6;
 * repeated uint32 shape = 7 ; / / the shape of the returned array
 * repeated string axisName = 8 ; / / each dimension corresponds to this axis
 * required string coordSysName = 9 ; / / must have coordAxis corresponding to shape
 * message DataResponse {
 * repeated CoordAxis coordAxes = 1 ; / / may be shared if asking for multiple grids
 * repeated CoordSys coordSys = 2 ; / / may be shared if asking for multiple grids
 * repeated GeoReferencedArray data = 4; */
public CdmrFeatureProto . CoverageDataResponse encodeDataResponse ( Iterable < CoverageCoordAxis > axes , Iterable < CoverageCoordSys > coordSys , Iterable < CoverageTransform > transforms , List < GeoReferencedArray > arrays , boolean deflate ) { } }

implementation: CdmrFeatureProto . CoverageDataResponse . Builder builder = CdmrFeatureProto . CoverageDataResponse . newBuilder ( ) ; for ( CoverageCoordAxis axis : axes ) builder . addCoordAxes ( encodeCoordAxis ( axis ) ) ; for ( CoverageCoordSys cs : coordSys ) builder . addCoordSys ( encodeCoordSys ( cs ) ) ; for ( CoverageTransform t : transforms ) builder . addCoordTransforms ( encodeCoordTransform ( t ) ) ; for ( GeoReferencedArray array : arrays ) builder . addGeoArray ( encodeGeoReferencedArray ( array , deflate ) ) ; return builder . build ( ) ;


signature:
public class CollectionGlob { /** * from http : / / blog . eyallupu . com / 2011/11 / java - 7 - working - with - directories . html */
public static DirectoryStream newDirectoryStream ( Path dir , String glob ) throws IOException { } }

implementation: FileSystem fs = dir . getFileSystem ( ) ; final PathMatcher matcher = fs . getPathMatcher ( "glob:" + glob ) ; DirectoryStream . Filter < Path > filter = new DirectoryStream . Filter < Path > ( ) { public boolean accept ( Path entry ) { return matcher . matches ( entry . getFileName ( ) ) ; } } ; return fs . provider ( ) . newDirectoryStream ( dir , filter ) ;


signature:
public class CoordTransBuilder { /** * Register a class that implements a Coordinate Transform .
 * @ param transformName name of transform . This name is used in the datasets to identify the transform , eg CF names .
 * @ param c class that implements CoordTransBuilderIF . */
static public void registerTransform ( String transformName , Class c ) { } }

implementation:
if ( ! ( VertTransformBuilderIF . class . isAssignableFrom ( c ) ) && ! ( HorizTransformBuilderIF . class . isAssignableFrom ( c ) ) ) throw new IllegalArgumentException ( "Class " + c . getName ( ) + " must implement VertTransformBuilderIF or HorizTransformBuilderIF" ) ; // fail fast - check newInstance works
try { c . newInstance ( ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( "CoordTransBuilderIF Class " + c . getName ( ) + " cannot instantiate, probably need default Constructor" ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "CoordTransBuilderIF Class " + c . getName ( ) + " is not accessible" ) ; } // user stuff gets put at top
if ( userMode ) transformList . add ( 0 , new Transform ( transformName , c ) ) ; else transformList . add ( new Transform ( transformName , c ) ) ;


signature:
public class CoordTransBuilder { /** * Register a class that implements a Coordinate Transform .
 * @ param transformName name of transform . This name is used in the datasets to identify the transform , eg CF names .
 * @ param className name of class that implements CoordTransBuilderIF .
 * @ throws ClassNotFoundException if Class . forName ( className ) fails */
static public void registerTransform ( String transformName , String className ) throws ClassNotFoundException { } }

implementation: Class c = Class . forName ( className ) ; registerTransform ( transformName , c ) ;


signature:
public class CoordTransBuilder { /** * Register a class that implements a Coordinate Transform .
 * @ param transformName name of transform . This name is used in the datasets to identify the transform , eg CF names .
 * @ param className name of class that implements CoordTransBuilderIF . */
static public void registerTransformMaybe ( String transformName , String className ) { } }

implementation: Class c ; try { c = Class . forName ( className ) ; } catch ( ClassNotFoundException e ) { if ( loadWarnings ) log . warn ( "Coordinate Transform Class " + className + " not found." ) ; return ; } registerTransform ( transformName , c ) ;


signature:
public class CoordTransBuilder { /** * Make a CoordinateTransform object from the parameters in a Coordinate Transform Variable , using an intrinsic or registered CoordTransBuilder .
 * @ param ds enclosing dataset , only used for vertical transforms
 * @ param ctv the Coordinate Transform Variable - container for the transform parameters
 * @ param parseInfo pass back information about the parsing .
 * @ param errInfo pass back error information .
 * @ return CoordinateTransform , or null if failure . */
static public CoordinateTransform makeCoordinateTransform ( NetcdfDataset ds , AttributeContainer ctv , Formatter parseInfo , Formatter errInfo ) { } }

implementation:
// standard name
String transform_name = ctv . findAttValueIgnoreCase ( "transform_name" , null ) ; if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( "Projection_Name" , null ) ; // these names are from CF - dont want to have to duplicate
if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( CF . GRID_MAPPING_NAME , null ) ; if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( CF . STANDARD_NAME , null ) ; if ( null == transform_name ) { parseInfo . format ( "**Failed to find Coordinate Transform name from Variable= %s%n" , ctv ) ; return null ; } transform_name = transform_name . trim ( ) ; // do we have a transform registered for this ?
Class builderClass = null ; for ( Transform transform : transformList ) { if ( transform . transName . equals ( transform_name ) ) { builderClass = transform . transClass ; break ; } } if ( null == builderClass ) { parseInfo . format ( "**Failed to find CoordTransBuilder name= %s from Variable= %s%n" , transform_name , ctv ) ; return null ; } // get an instance of that class
Object builderObject ; try { builderObject = builderClass . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . error ( "Cant create new instance " + builderClass . getName ( ) , e ) ; return null ; } if ( null == builderObject ) { // cant happen - because this was tested in registerTransform ( )
parseInfo . format ( "**Failed to build CoordTransBuilder object from class= %s for Variable= %s%n" , builderClass . getName ( ) , ctv ) ; return null ; } CoordinateTransform ct ; if ( builderObject instanceof VertTransformBuilderIF ) { VertTransformBuilderIF vertBuilder = ( VertTransformBuilderIF ) builderObject ; vertBuilder . setErrorBuffer ( errInfo ) ; ct = vertBuilder . makeCoordinateTransform ( ds , ctv ) ; } else if ( builderObject instanceof HorizTransformBuilderIF ) { HorizTransformBuilderIF horizBuilder = ( HorizTransformBuilderIF ) builderObject ; horizBuilder . setErrorBuffer ( errInfo ) ; String units = AbstractTransformBuilder . getGeoCoordinateUnits ( ds , ctv ) ; // barfola
ct = horizBuilder . makeCoordinateTransform ( ctv , units ) ; } else { log . error ( "Illegals class " + builderClass . getName ( ) ) ; return null ; } if ( ct != null ) { parseInfo . format ( " Made Coordinate transform %s from variable %s: %s%n" , transform_name , ctv . getName ( ) , builderObject . getClass ( ) . getName ( ) ) ; } return ct ;


signature:
public class CoordTransBuilder { /** * Create a " dummy " Coordinate Transform Variable based on the given CoordinateTransform .
 * This creates a scalar Variable with dummy data , and adds the Parameters of the CoordinateTransform
 * as attributes .
 * @ param ds for this dataset
 * @ param ct based on the CoordinateTransform
 * @ return the Coordinate Transform Variable . You must add it to the dataset . */
static public VariableDS makeDummyTransformVariable ( NetcdfDataset ds , CoordinateTransform ct ) { } }

implementation:
VariableDS v = new VariableDS ( ds , null , null , ct . getName ( ) , DataType . CHAR , "" , null , null ) ; List < Parameter > params = ct . getParameters ( ) ; for ( Parameter p : params ) { if ( p . isString ( ) ) v . addAttribute ( new Attribute ( p . getName ( ) , p . getStringValue ( ) ) ) ; else { double [ ] data = p . getNumericValues ( ) ; Array dataA = Array . factory ( DataType . DOUBLE , new int [ ] { data . length } , data ) ; v . addAttribute ( new Attribute ( p . getName ( ) , dataA ) ) ; } } v . addAttribute ( new Attribute ( _Coordinate . TransformType , ct . getTransformType ( ) . toString ( ) ) ) ; // fake data
Array data = Array . factory ( DataType . CHAR , new int [ ] { } , new char [ ] { ' ' } ) ; v . setCachedData ( data , true ) ; return v ;


signature:
public class CoordTransBuilder { /** * Make a CoordinateTransform object from the parameters in a GridCoordTransform , using an intrinsic or
 * registered CoordTransBuilder .
 * @ param errInfo pass back error information .
 * @ return CoordinateTransform , or null if failure . */
static public ProjectionImpl makeProjection ( CoverageTransform gct , Formatter errInfo ) { } }

implementation:
// standard name
String transform_name = gct . findAttValueIgnoreCase ( CF . GRID_MAPPING_NAME , null ) ; if ( null == transform_name ) { errInfo . format ( "**Failed to find Coordinate Transform name from GridCoordTransform= %s%n" , gct ) ; return null ; } transform_name = transform_name . trim ( ) ; // do we have a transform registered for this ?
Class builderClass = null ; for ( Transform transform : transformList ) { if ( transform . transName . equals ( transform_name ) ) { builderClass = transform . transClass ; break ; } } if ( null == builderClass ) { errInfo . format ( "**Failed to find CoordTransBuilder name= %s from GridCoordTransform= %s%n" , transform_name , gct ) ; return null ; } // get an instance of that class
HorizTransformBuilderIF builder ; try { builder = ( HorizTransformBuilderIF ) builderClass . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . error ( "Cant create new instance " + builderClass . getName ( ) , e ) ; return null ; } if ( null == builder ) { // cant happen - because this was tested in registerTransform ( )
errInfo . format ( "**Failed to build CoordTransBuilder object from class= %s for GridCoordTransform= %s%n" , builderClass . getName ( ) , gct ) ; return null ; } String units = gct . findAttValueIgnoreCase ( CDM . UNITS , null ) ; builder . setErrorBuffer ( errInfo ) ; ProjectionCT ct = builder . makeCoordinateTransform ( gct , units ) ; assert ct != null ; return ct . getProjection ( ) ;


signature:
public class ThreddsDatasetChooser { /** * Fires a PropertyChangeEvent :
 * < ul >
 * < li > propertyName = " Dataset " or " File " , getNewValue ( ) = InvDataset chosen .
 * < li > propertyName = " Datasets " , getNewValue ( ) = InvDataset [ ] chosen . This can only happen if
 * you have set doResolve = true , and the resolved dataset is a list of datasets .
 * < li > propertyName = " InvAccess " getNewValue ( ) = InvAccess chosen .
 * < / ul > */
private void firePropertyChangeEvent ( PropertyChangeEvent event ) { } }

implementation:
// System . out . println ( " firePropertyChangeEvent " + ( ( InvDatasetImpl ) ds ) . dump ( ) ) ;
if ( pipeOut ) pipeEvent ( event ) ; if ( messageOut ) messageEvent ( event ) ; firePropertyChange ( event . getPropertyName ( ) , event . getOldValue ( ) , event . getNewValue ( ) ) ;


signature:
public class ThreddsDatasetChooser { /** * Wrap this in a JDialog component .
 * @ param parent put dialog on top of this , may be null
 * @ param title dialog window title
 * @ param modal is modal */
public JDialog makeDialog ( JFrame parent , String title , boolean modal ) { } }

implementation: return new Dialog ( frame , title , modal ) ;


signature:
public class ThreddsDatasetChooser { /** * Standalone application .
 * @ param args recognized values :
 * < ul > < li > - usePopup to popup messages < / ul > */
public static void main ( String args [ ] ) { } }

implementation:
boolean usePopup = false ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] . equals ( "-usePopup" ) ) usePopup = true ; } try { store = XMLStore . createFromFile ( "ThreddsDatasetChooser" , null ) ; p = store . getPreferences ( ) ; } catch ( IOException e ) { System . out . println ( "XMLStore Creation failed " + e ) ; } // put it together in a JFrame
final JFrame frame = new JFrame ( "Thredds Dataset Chooser" ) ; frame . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { chooser . save ( ) ; Rectangle bounds = frame . getBounds ( ) ; p . putBeanObject ( FRAME_SIZE , bounds ) ; try { store . save ( ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } System . exit ( 0 ) ; } } ) ; chooser = new ThreddsDatasetChooser ( p , null , frame , true , usePopup , false ) ; chooser . setDoResolve ( true ) ; frame . getContentPane ( ) . add ( chooser ) ; Rectangle bounds = ( Rectangle ) p . getBean ( FRAME_SIZE , new Rectangle ( 50 , 50 , 800 , 450 ) ) ; frame . setBounds ( bounds ) ; frame . pack ( ) ; frame . setBounds ( bounds ) ; frame . setVisible ( true ) ;


signature:
public class VTfromExistingData { /** * Get the 1D vertical coordinate array for this time step and point
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ param xIndex the x index
 * @ param yIndex the y index
 * @ return vertical coordinate array
 * @ throws java . io . IOException problem reading data
 * @ throws ucar . ma2 . InvalidRangeException _ more _ */
public D1 getCoordinateArray1D ( int timeIndex , int xIndex , int yIndex ) throws IOException , InvalidRangeException { } }

implementation: ArrayDouble . D3 ddata = getCoordinateArray ( timeIndex ) ; int [ ] origin = new int [ ] { 0 , yIndex , xIndex } ; int [ ] shape = new int [ ] { ddata . getShape ( ) [ 0 ] , 1 , 1 } ; return ( ArrayDouble . D1 ) ddata . section ( origin , shape ) . reduce ( ) ;


signature: public class DataRoot { public String getFileLocationFromRequestPath ( String reqPath ) { } }

implementation:
if ( datasetScan != null ) { // LOOK should check to see if its been filtered out by scan
return getFileLocationFromRequestPath ( reqPath , datasetScan . getPath ( ) , datasetScan . getScanLocation ( ) , false ) ; } else if ( catScan != null ) { // LOOK should check to see if its allowed in fc
return getFileLocationFromRequestPath ( reqPath , catScan . getPath ( ) , catScan . getLocation ( ) , false ) ; } else if ( featCollection != null ) { // LOOK should check to see if its allowed in fc
return getFileLocationFromRequestPath ( reqPath , featCollection . getPath ( ) , featCollection . getTopDirectoryLocation ( ) , true ) ; } else { // must be a datasetRoot
// LOOK should check to see if it exists ? ?
return getFileLocationFromRequestPath ( reqPath , getPath ( ) , getDirLocation ( ) , false ) ; }


signature:
public class FmrcCollectionTable { /** * private MetadataManager mm ; */
public void save ( ) { } }

implementation: collectionNameTable . saveState ( false ) ; dataTable . saveState ( false ) ; prefs . putBeanObject ( "InfoWindowBounds" , infoWindow . getBounds ( ) ) ; prefs . putInt ( "splitPos" , split . getDividerLocation ( ) ) ;


signature:
public class Bufr2Xml { /** * iterate through the observations */
private void writeSequence ( StructureDS s , StructureDataIterator sdataIter ) throws IOException , XMLStreamException { } }

implementation:
int count = 0 ; try { while ( sdataIter . hasNext ( ) ) { // out . format ( " % sSequence % s count = % d % n " , indent , s . getShortName ( ) , count + + ) ;
StructureData sdata = sdataIter . next ( ) ; staxWriter . writeCharacters ( "\n" ) ; staxWriter . writeCharacters ( indent . toString ( ) ) ; staxWriter . writeStartElement ( "struct" ) ; staxWriter . writeAttribute ( "name" , escaper . escape ( s . getShortName ( ) ) ) ; staxWriter . writeAttribute ( "count" , Integer . toString ( count ++ ) ) ; for ( StructureMembers . Member m : sdata . getMembers ( ) ) { Variable v = s . findVariable ( m . getName ( ) ) ; indent . incr ( ) ; if ( m . getDataType ( ) . isString ( ) || m . getDataType ( ) . isNumeric ( ) ) { writeVariable ( ( VariableDS ) v , sdata . getArray ( m ) ) ; } else if ( m . getDataType ( ) == DataType . STRUCTURE ) { StructureDS sds = ( StructureDS ) v ; ArrayStructure data = ( ArrayStructure ) sdata . getArray ( m ) ; writeSequence ( sds , data . getStructureDataIterator ( ) ) ; } else if ( m . getDataType ( ) == DataType . SEQUENCE ) { SequenceDS sds = ( SequenceDS ) v ; ArraySequence data = ( ArraySequence ) sdata . getArray ( m ) ; writeSequence ( sds , data . getStructureDataIterator ( ) ) ; } indent . decr ( ) ; } staxWriter . writeCharacters ( "\n" ) ; staxWriter . writeCharacters ( indent . toString ( ) ) ; staxWriter . writeEndElement ( ) ; } } finally { sdataIter . close ( ) ; }


signature:
public class GetHTMLInterfaceHandler2 { /** * Default handler for OPeNDAP . html requests . Returns an html form
 * and javascript code that allows the user to use their browser
 * to select variables and build constraints for a data request .
 * The DDS and DAS for the data set are used to build the form . The
 * types in opendap . servlet . www are integral to the form generation .
 * @ param request The < code > HttpServletRequest < / code > from the client .
 * @ param response The < code > HttpServletResponse < / code > for the client .
 * @ param dataSet
 * @ param sdds
 * @ param myDAS
 * @ throws opendap . dap . DAP2Exception
 * @ throws opendap . dap . parsers . ParseException
 * @ see opendap . servlet . www . wwwFactory */
public void sendDataRequestForm ( HttpServletRequest request , HttpServletResponse response , String dataSet , ServerDDS sdds , DAS myDAS ) // changed jc
throws DAP2Exception , ParseException { } }

implementation:
if ( _Debug ) System . out . println ( "Sending DODS Data Request Form For: " + dataSet + "    CE: '" + request . getQueryString ( ) + "'" ) ; String requestURL ; /* / / Turn this on later if we discover we ' re supposed to accept
 / / constraint expressions as input to the Data Request Web Form
 String ce ;
 if ( request . getQueryString ( ) = = null ) {
 ce = " " ;
 else {
 ce = " ? " + request . getQueryString ( ) ; */
int suffixIndex = request . getRequestURL ( ) . toString ( ) . lastIndexOf ( "." ) ; requestURL = request . getRequestURL ( ) . substring ( 0 , suffixIndex ) ; String dapCssUrl = "/" + requestURL . split ( "/" , 5 ) [ 3 ] + "/" + "tdsDap.css" ; try { // PrintWriter pw = new PrintWriter ( response . getOutputStream ( ) ) ;
PrintWriter pw ; if ( false ) { pw = new PrintWriter ( new FileOutputStream ( new File ( "debug.html" ) ) ) ; } else pw = response . getWriter ( ) ; wwwOutPut wOut = new wwwOutPut ( pw ) ; // Get the DDS and the DAS ( if one exists ) for the dataSet .
DDS myDDS = getWebFormDDS ( dataSet , sdds ) ; // DAS myDAS = dServ . getDAS ( dataSet ) ; / / change jc
jscriptCore jsc = new jscriptCore ( ) ; pw . println ( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n" + "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n" + "<title>OPeNDAP Dataset Query Form</title>\n" + "<link type=\"text/css\" rel=\"stylesheet\" media=\"screen\" href=\"" + dapCssUrl + "\"/>\n" + "<base href=\"" + helpLocation + "\">\n" + "\n" + "\n" + "\n" + "

OPeNDAP Dataset Access Form
\n" + "
\n" + "<form action=\"\">\n" + "
\n" ) ; pw . flush ( ) ; wOut . writeDisposition ( requestURL ) ; pw . println ( "

\n" ) ; wOut . writeGlobalAttributes ( myDAS , myDDS ) ; pw . println ( "

\n" ) ; wOut . writeVariableEntries ( myDAS , myDDS ) ; pw . println ( "
</form>\n" ) ; pw . println ( "
\n" ) ; pw . println ( "<address>" ) ; pw . println ( "
For questions or comments about this dataset, contact the administrator of this server [" + serverContactName + "] at: " + serverContactEmail + "
" ) ; pw . println ( "
For questions or comments about OPeNDAP, email OPeNDAP support at:" + " " + odapSupportEmail + "
" ) ; pw . println ( "</address>" ) ; pw . println ( "
" ) ; pw . println ( "
DDS:
" ) ; pw . println ( "
" ) ; myDDS . print ( pw ) ; pw . println ( "
" ) ; pw . println ( "
" ) ; pw . flush ( ) ; } catch ( IOException ioe ) { System . out . println ( "OUCH! IOException: " + ioe . getMessage ( ) ) ; ioe . printStackTrace ( System . out ) ; }


signature:
public class GetHTMLInterfaceHandler2 { /** * Gets a DDS for the specified data set and builds it using the class
 * factory in the package < b > opendap . servlet . www < / b > .
 * Currently this method uses a deprecated API to perform a translation
 * of DDS types . This is a known problem , and as soon as an alternate
 * way of achieving this result is identified we will implement it .
 * ( Your comments appreciated ! )
 * @ param dataSet A < code > String < / code > containing the data set name .
 * 3 * @ return A DDS object built using the www interface class factory .
 * @ see opendap . dap . DDS
 * @ see opendap . servlet . www . wwwFactory */
public DDS getWebFormDDS ( String dataSet , ServerDDS sDDS ) // changed jc
throws DAP2Exception , ParseException { } }

implementation:
// Get the DDS we need , using the getDDS method
// for this particular server
// ServerDDS sDDS = dServ . getDDS ( dataSet ) ;
// Make a new DDS using the web form ( www interface ) class factory
wwwFactory wfactory = new wwwFactory ( ) ; DDS wwwDDS = new DDS ( dataSet , wfactory ) ; wwwDDS . setURL ( dataSet ) ; // Make a special print writer to catch the ServerDDS ' s
// persistent representation in a String .
StringWriter ddsSW = new StringWriter ( ) ; sDDS . print ( new PrintWriter ( ddsSW ) ) ; // Now use that string to make an input stream to
// pass to our new DDS for parsing .
// Since parser expects / requires InputStream ,
// we must adapt utf16 string to at least utf - 8
ByteArrayInputStream bai = null ; try { bai = new ByteArrayInputStream ( ddsSW . toString ( ) . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException uee ) { throw new DAP2Exception ( "UTF-8 encoding not supported" ) ; } wwwDDS . parse ( bai ) ; return ( wwwDDS ) ;


signature:
public class NdfdLocalTables { /** * take from degrib repository : http : / / slosh . nws . noaa . gov / pubview / degrib / src / degrib / metaname . c ? root = degrib & view = markup
 * Apparently for center 8 , subcenter 0 and subcenter 255 ( ! ) */
private void init ( ) { } }

implementation:
add ( 0 , 0 , 193 , "ApparentT" , "Apparent Temperature" , "K" ) ; add ( 0 , 1 , 192 , "Wx" , "Weather string" , "" ) ; /* LOOK ignored : grandfather ' ed in a NDFD choice for POP . */
add ( 0 , 10 , 8 , "PoP12" , "Prob of 0.01 In. of Precip" , "%" ) ; add ( 0 , 13 , 194 , "smokes" , "Surface level smoke from fires" , "log10(g/m^3)" ) ; add ( 0 , 13 , 195 , "smokec" , "Average vertical column smoke from fires" , "log10(g/m^3)" ) ; add ( 0 , 14 , 192 , "O3MR" , "Ozone Mixing Ratio" , "kg/kg" ) ; add ( 0 , 14 , 193 , "OZCON" , "Ozone Concentration" , "PPB" ) ; /* Arthur adopted NCEP ozone values from NCEP local table to NDFD local tables . ( 11/14/2009) */
add ( 0 , 14 , 200 , "OZMAX1" , "Ozone Daily Max from 1-hour Average" , "ppbV" ) ; add ( 0 , 14 , 201 , "OZMAX8" , "Ozone Daily Max from 8-hour Average" , "ppbV" ) ; /* Added 1/23/2007 in preparation for SPC NDFD Grids */
add ( 0 , 19 , 194 , "ConvOutlook" , "Convective Hazard Outlook" , "0=none; 2=tstm; 4=slight; 6=moderate; 8=high" ) ; add ( 0 , 19 , 197 , "TornadoProb" , "Tornado Probability" , "%" ) ; add ( 0 , 19 , 198 , "HailProb" , "Hail Probability" , "%" ) ; add ( 0 , 19 , 199 , "WindProb" , "Damaging Thunderstorm Wind Probability" , "%" ) ; add ( 0 , 19 , 200 , "XtrmTornProb" , "Extreme Tornado Probability" , "%" ) ; add ( 0 , 19 , 201 , "XtrmHailProb" , "Extreme Hail Probability" , "%" ) ; add ( 0 , 19 , 202 , "XtrmWindProb" , "Extreme Thunderstorm Wind Probability" , "%" ) ; add ( 0 , 19 , 215 , "TotalSvrProb" , "Total Probability of Severe Thunderstorms" , "%" ) ; add ( 0 , 19 , 216 , "TotalXtrmProb" , "Total Probability of Extreme Severe Thunderstorms" , "%" ) ; add ( 0 , 19 , 217 , "WWA" , "Watch Warning Advisory" , "" ) ; /* Leaving next two lines in for grandfathering sake . 9/19/2007 . . . Probably can remove in future . */
add ( 0 , 19 , 203 , "TotalSvrProb" , "Total Probability of Severe Thunderstorms" , "%" ) ; add ( 0 , 19 , 204 , "TotalXtrmProb" , "Total Probability of Extreme Severe Thunderstorms" , "%" ) ; add ( 0 , 192 , 192 , "FireWx" , "Critical Fire Weather" , "%" ) ; add ( 0 , 192 , 194 , "DryLightning" , "Dry Lightning" , "%" ) ; /* Arthur Added this to both NDFD and NCEP local tables . ( 5/1/2006) */
add ( 10 , 3 , 192 , "Surge" , "Hurricane Storm Surge" , "m" ) ; add ( 10 , 3 , 193 , "ETSurge" , "Extra Tropical Storm Surge" , "m" ) ;


signature:
public class FixedYearLengthChronology { /** * Throws UnsupportedOperationException unless the time zone is UTC */
@ Override public final Chronology withZone ( DateTimeZone zone ) { } }

implementation: if ( zone . equals ( DateTimeZone . UTC ) ) return this . withUTC ( ) ; throw new UnsupportedOperationException ( "Not supported yet." ) ;


signature:
public class SerialWriter { /** * Encode an array of primitive values .
 * @ param vtype The type of the object
 * @ param values The value array
 * @ return bytebuffer encoding of the array using the
 * platform ' s native encoding . */
static public ByteBuffer encodeArray ( DapType vtype , Object values , ByteOrder order ) throws IOException { } }

implementation:
TypeSort atomtype = vtype . getAtomicType ( ) ; assert values != null && values . getClass ( ) . isArray ( ) ; int count = Array . getLength ( values ) ; int total = ( int ) TypeSort . getSize ( atomtype ) * count ; ByteBuffer buf = ByteBuffer . allocate ( total ) . order ( order ) ; switch ( atomtype ) { case Char : char [ ] datac = ( char [ ] ) values ; for ( int i = 0 ; i < datac . length ; i ++ ) { byte b = ( byte ) ( 0xFFL & ( long ) ( datac [ i ] ) ) ; buf . put ( b ) ; } break ; case UInt8 : case Int8 : byte [ ] data8 = ( byte [ ] ) values ; buf . put ( data8 ) ; break ; case Int16 : case UInt16 : short [ ] data16 = ( short [ ] ) values ; buf . asShortBuffer ( ) . put ( data16 ) ; buf . position ( total ) ; // because we are using asXXXBuffer
break ; case Int32 : case UInt32 : int [ ] data32 = ( int [ ] ) values ; buf . asIntBuffer ( ) . put ( data32 ) ; buf . position ( total ) ; // because we are using asXXXBuffer
break ; case Int64 : case UInt64 : long [ ] data64 = ( long [ ] ) values ; buf . asLongBuffer ( ) . put ( data64 ) ; buf . position ( total ) ; // because we are using asXXXBuffer
break ; case Float32 : float [ ] dataf = ( float [ ] ) values ; buf . asFloatBuffer ( ) . put ( dataf ) ; buf . position ( total ) ; // because we are using asXXXBuffer
break ; case Float64 : double [ ] datad = ( double [ ] ) values ; buf . asDoubleBuffer ( ) . put ( datad ) ; buf . position ( total ) ; // because we are using asXXXBuffer
break ; case URL : case String : // Convert the string to a counted UTF - 8 bytestring
String [ ] datas = ( String [ ] ) values ; // Pass 1 : get total size
total = 0 ; for ( int i = 0 ; i < datas . length ; i ++ ) { String content = datas [ i ] ; byte [ ] bytes = content . getBytes ( DapUtil . UTF8 ) ; total += ( bytes . length + COUNTSIZE ) ; } buf = ByteBuffer . allocate ( total ) . order ( order ) ; // Pass 2 : write the strings
for ( int i = 0 ; i < datas . length ; i ++ ) { String content = datas [ i ] ; byte [ ] bytes = content . getBytes ( DapUtil . UTF8 ) ; buf . putLong ( bytes . length ) ; buf . put ( bytes ) ; } break ; case Opaque : // Unfortunately , Array . get1d does not produce
// a ByteBuffer [ ] .
Object [ ] datao = ( Object [ ] ) values ; // Pass 1 : get total size
total = 0 ; int size = 0 ; for ( int i = 0 ; i < datao . length ; i ++ ) { ByteBuffer opaquedata = ( ByteBuffer ) datao [ i ] ; // the data may be at an offset in the buffer
size = opaquedata . remaining ( ) ; // should be limit - pos
total += ( size + COUNTSIZE ) ; } buf = ByteBuffer . allocate ( total ) . order ( order ) ; // Pass 2 : write the opaque elements
for ( int i = 0 ; i < datao . length ; i ++ ) { ByteBuffer opaquedata = ( ByteBuffer ) datao [ i ] ; size = opaquedata . remaining ( ) ; // should be limit - pos
buf . putLong ( size ) ; int savepos = opaquedata . position ( ) ; buf . put ( opaquedata ) ; opaquedata . position ( savepos ) ; } break ; case Enum : // handled by getPrimitiveType ( ) above
assert false : "Unexpected ENUM type" ; default : throw new DapException ( "Unknown type: " + vtype . getTypeName ( ) ) ; } return buf ;


signature:
public class SerialWriter { /** * Write out a prefix count
 * @ param count the count to write out
 * @ throws IOException */
public void writeCount ( long count ) throws IOException { } }

implementation: countbuffer . clear ( ) ; countbuffer . putLong ( count ) ; byte [ ] countbuf = countbuffer . array ( ) ; int len = countbuffer . position ( ) ; writeBytes ( countbuf , len ) ; if ( DEBUG ) { System . err . printf ( "count: %d%n" , count ) ; }


signature:
public class SerialWriter { /** * Write out an array of atomic values
 * @ param daptype type of the values
 * @ param values the array of values
 * @ throws IOException */
public void writeAtomicArray ( DapType daptype , Object values ) throws IOException { } }

implementation: assert values != null && values . getClass ( ) . isArray ( ) ; ByteBuffer buf = SerialWriter . encodeArray ( daptype , values , this . order ) ; byte [ ] bytes = buf . array ( ) ; int len = buf . position ( ) ; writeBytes ( bytes , len ) ; if ( DEBUG ) { System . err . printf ( "%s: " , daptype . getShortName ( ) ) ; for ( int i = 0 ; i < len ; i ++ ) { int x = ( int ) ( order == ByteOrder . BIG_ENDIAN ? bytes [ i ] : bytes [ ( len - 1 ) - i ] ) ; System . err . printf ( "%02x" , ( int ) ( x & 0xff ) ) ; } System . err . println ( ) ; }


signature:
public class SerialWriter { /** * Write out a set of bytes
 * @ param bytes
 * @ param len
 * @ throws IOException */
public void writeBytes ( byte [ ] bytes , int len ) throws IOException { } }

implementation: outputBytes ( bytes , 0 , len ) ; if ( this . checksummode . enabled ( ChecksumMode . DAP ) ) { this . checksum . update ( bytes , 0 , len ) ; if ( DUMPCSUM ) { System . err . print ( "SSS " ) ; for ( int i = 0 ; i < len ; i ++ ) { System . err . printf ( "%02x" , bytes [ i ] ) ; } System . err . println ( ) ; } }


signature:
public class SerialWriter { /** * Deliberate choke point for debugging
 * @ param bytes
 * @ param start
 * @ param count
 * @ throws IOException */
public void outputBytes ( byte [ ] bytes , int start , int count ) throws IOException { } }

implementation: if ( DUMPDATA ) { System . err . printf ( "output %d/%d:" , start , count ) ; for ( int i = 0 ; i < count ; i ++ ) { System . err . printf ( " %02x" , bytes [ i ] ) ; } System . err . println ( "" ) ; System . err . flush ( ) ; } output . write ( bytes , start , count ) ;


signature:
public class PointDatasetStandardFactory { /** * Check if this is a POINT datatype . If so , a TableAnalyser is used to analyze its structure .
 * The TableAnalyser is reused when the dataset is opened .
 * < ol >
 * < li > Can handle ANY _ POINT FeatureType .
 * < li > Must have time , lat , lon axis ( from CoordSysBuilder )
 * < li > Call TableAnalyzer . factory ( ) to create a TableAnalyzer
 * < li > TableAnalyzer must agree it can handle the requested FeatureType
 * < / ol >
 * @ param wantFeatureType desired feature type , null means FeatureType . ANY _ POINT
 * @ param ds analyse this dataset
 * @ param errlog log error messages here ( may not be null )
 * @ return if successful , return non - null . This object is then passed back into open ( ) , so analysis can be reused .
 * @ throws IOException */
@ Override public Object isMine ( FeatureType wantFeatureType , NetcdfDataset ds , Formatter errlog ) throws IOException { } }

implementation:
if ( wantFeatureType == null ) wantFeatureType = FeatureType . ANY_POINT ; if ( wantFeatureType != FeatureType . ANY_POINT ) { if ( ! wantFeatureType . isPointFeatureType ( ) ) return null ; } TableConfigurer tc = TableAnalyzer . getTableConfigurer ( wantFeatureType , ds ) ; // if no explicit tc , then check whatever we can before expensive analysis )
if ( tc == null ) { boolean hasTime = false ; boolean hasLat = false ; boolean hasLon = false ; for ( CoordinateAxis axis : ds . getCoordinateAxes ( ) ) { if ( axis . getAxisType ( ) == AxisType . Time ) // & & ( axis . getRank ( ) = = 1 ) )
hasTime = true ; if ( axis . getAxisType ( ) == AxisType . Lat ) // & & ( axis . getRank ( ) = = 1 ) )
hasLat = true ; if ( axis . getAxisType ( ) == AxisType . Lon ) // & & ( axis . getRank ( ) = = 1 ) )
hasLon = true ; } // minimum we need
if ( ! ( hasTime && hasLon && hasLat ) ) { errlog . format ( "PointDataset must have lat,lon,time" ) ; return null ; } } else if ( showTables ) { System . out . printf ( "TableConfigurer = %s%n" , tc . getClass ( ) . getName ( ) ) ; } try { // gotta do some work
TableAnalyzer analyser = TableAnalyzer . factory ( tc , wantFeatureType , ds ) ; if ( analyser == null ) return null ; if ( ! analyser . featureTypeOk ( wantFeatureType , errlog ) ) { return null ; } return analyser ; } catch ( Throwable t ) { return null ; }


signature:
public class ReqState { /** * This method is used to convert special characters into their
 * actual byte values .
 * For example , in a URL the space character
 * is represented as " % 20 " this method will replace that with a
 * space charater . ( a single value of 0x20)
 * @ param ce The constraint expresion string as collected from the request
 * object with < code > getQueryString ( ) < / code >
 * @ return A string containing the prepared constraint expression . If there
 * is a problem with the constraint expression a < code > null < / code > is returned . */
private String prepCE ( String ce ) { } }

implementation:
int index ; // System . out . println ( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " ) ;
// System . out . println ( " Prepping : \ " " + ce + " \ " " ) ;
if ( ce == null ) { ce = "" ; // System . out . println ( " null Constraint expression . " ) ;
} else if ( ! ce . equals ( "" ) ) { // System . out . println ( " Searching for : % " ) ;
index = ce . indexOf ( "%" ) ; // System . out . println ( " index of % : " + index ) ;
if ( index == - 1 ) return ( ce ) ; if ( index > ( ce . length ( ) - 3 ) ) return ( null ) ; while ( index >= 0 ) { // System . out . println ( " Found % at character " + index ) ;
String specChar = ce . substring ( index + 1 , index + 3 ) ; // System . out . println ( " specChar : \ " " + specChar + " \ " " ) ;
// Convert that bad boy !
char val = ( char ) Byte . parseByte ( specChar , 16 ) ; // System . out . println ( " val : ' " + val + " ' " ) ;
// System . out . println ( " String . valueOf ( val ) : \ " " + String . valueOf ( val ) + " \ " " ) ;
ce = ce . substring ( 0 , index ) + String . valueOf ( val ) + ce . substring ( index + 3 , ce . length ( ) ) ; // System . out . println ( " ce : \ " " + ce + " \ " " ) ;
index = ce . indexOf ( "%" ) ; if ( index > ( ce . length ( ) - 3 ) ) return ( null ) ; } } // char ca [ ] = ce . toCharArray ( ) ;
// for ( int i = 0 ; i < ca . length ; i + + )
// System . out . print ( " ' " + ( byte ) ca [ i ] + " ' " ) ;
// System . out . println ( " " ) ;
// System . out . println ( ce ) ;
// System . out . println ( " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " ) ;
// System . out . println ( " Returning CE : \ " " + ce + " \ " " ) ;
return ( ce ) ;


signature:
public class ReqState { /** * Processes an incoming < code > HttpServletRequest < / code > . Uses the content of
 * the < code > HttpServletRequest < / code > to create a < code > ReqState < / code >
 * object in that caches the values for :
 * < ul >
 * < li > < b > dataSet < / b > The data set name . ( Accessible using
 * < code > setDataSet ( ) < / code >
 * and < code > getDataSet ( ) < / code > ) < / li >
 * < li > < b > CE < / b > The constraint expression . ( Accessible using
 * < code > setCE ( ) < / code >
 * and < code > getCE ( ) < / code > ) < / li >
 * < li > < b > requestSuffix < / b > The request suffix , used by OPeNDAP DAP2 to
 * indicate the type of response desired by the client .
 * ( Accessible using
 * < code > setRequestSuffix ( ) < / code >
 * and < code > getRequestSuffix ( ) < / code > ) < / li >
 * < li > < b > isClientCompressed < / b > Does the requesting client
 * accept a compressed response ? < / li >
 * < li > < b > ServletConfig < / b > The < code > ServletConfig < / code > object
 * for this servlet . < / li >
 * < li > < b > ServerName < / b > The class name of this server . < / li >
 * < li > < b > RequestURL < / b > THe URL that that was used to call thye servlet . < / li >
 * < / ul >
 * @ see ReqState */
protected void processDodsURL ( ) { } }

implementation:
String cxtpath = HTTPUtil . canonicalpath ( myHttpRequest . getContextPath ( ) ) ; if ( cxtpath != null && cxtpath . length ( ) == 0 ) cxtpath = null ; if ( cxtpath == null ) cxtpath = "/" ; // we are running as webapps / ROOT
String servletpath = HTTPUtil . canonicalpath ( myHttpRequest . getServletPath ( ) ) ; if ( servletpath != null && servletpath . length ( ) == 0 ) servletpath = null ; this . dataSetName = HTTPUtil . canonicalpath ( myHttpRequest . getPathInfo ( ) ) ; if ( this . dataSetName != null && this . dataSetName . length ( ) == 0 ) this . dataSetName = null ; if ( this . dataSetName == null ) { if ( servletpath != null ) { // use servlet path
if ( cxtpath != null && servletpath . startsWith ( cxtpath ) ) { this . dataSetName = servletpath . substring ( cxtpath . length ( ) ) ; } else { this . dataSetName = servletpath ; } } } else { if ( dataSetName . startsWith ( "/dodsC" ) ) dataSetName = dataSetName . substring ( 6 ) ; } this . requestSuffix = null ; if ( this . dataSetName != null ) { String name = this . dataSetName ; if ( name . startsWith ( "/" ) ) name = name . substring ( 1 ) ; // remove any leading ' / '
String [ ] pieces = name . split ( "/" ) ; if ( pieces . length == 0 || pieces [ 0 ] . length ( ) == 0 ) { requestSuffix = "" ; this . dataSetName = name ; } else { String endOPath = pieces [ pieces . length - 1 ] ; // Check the last element in the path for the character " . "
int index = endOPath . lastIndexOf ( '.' ) ; // If a dot is found take the stuff after it as the DAP2 request suffix
if ( index > 0 ) { // pluck the DAP2 request suffix off of the end
requestSuffix = endOPath . substring ( index + 1 ) ; // Set the data set name to the entire path minus the
// suffix which we know exists in the last element
// of the path .
this . dataSetName = this . dataSetName . substring ( 1 , this . dataSetName . lastIndexOf ( '.' ) ) ; } else { // strip the leading slash ( / ) from the dataset name and set the suffix to an empty string
requestSuffix = "" ; this . dataSetName = name ; } } }


signature:
public class ReqState { /** * Evaluates the ( private ) request object to determine if the client that
 * sent the request accepts compressed return documents .
 * @ return True is the client accpets a compressed return document .
 * False otherwise . */
public boolean getAcceptsCompressed ( ) { } }

implementation: boolean isTiny ; isTiny = false ; String encoding = this . myHttpRequest . getHeader ( "Accept-Encoding" ) ; if ( encoding != null ) isTiny = encoding . contains ( "deflate" ) ; else isTiny = false ; return ( isTiny ) ;


signature:
public class EcmwfParamTable { /** * # Code table 4.2 - Parameter number by product discipline and parameter category
 * 0 0 Estimated precipitation ( kg m - 2)
 * 1 1 Instantaneous rain rate ( kg m - 2 s - 1)
 * 2 2 Cloud top height ( m )
 * 3 3 Cloud top height quality indicator ( Code table 4.219)
 * 4 4 Estimated u - component of wind ( m / s )
 * 5 5 Estimated v - component of wind ( m / s )
 * 6 6 Number of pixel used ( Numeric )
 * 7 7 Solar zenith angle ( deg )
 * 8 8 Relative azimuth angle ( deg )
 * 9 9 Reflectance in 0.6 micron channel ( % )
 * 10 10 Reflectance in 0.8 micron channel ( % )
 * 11 11 Reflectance in 1.6 micron channel ( % )
 * 12 12 Reflectance in 3.9 micron channel ( % )
 * 13 13 Atmospheric divergence ( / s )
 * 14 14 Cloudy brightness temperature ( K )
 * 15 15 Clear - sky brightness temperature ( K )
 * 16 16 Cloudy radiance ( with respect to wave number ) ( W m - 1 sr - 1)
 * 17 17 Clear - sky radiance ( with respect to wave number ) ( W m - 1 sr - 1)
 * 18 18 Reserved
 * 19 19 Wind speed ( m / s )
 * 20 20 Aerosol optical thickness at 0.635 um
 * 21 21 Aerosol optical thickness at 0.810 um
 * 22 22 Aerosol optical thickness at 1.640 um
 * 23 23 Angstrom coefficient
 * # 24-26 Reserved
 * 27 27 Bidirectional reflectance factor ( numeric )
 * 28 28 Brightness temperature ( K )
 * 29 29 Scaled radiance ( numeric )
 * # 30-191 Reserved
 * # 192-254 Reserved for local use
 * 255 255 Missing */
private ImmutableMap < Integer , Grib2Parameter > readTable ( String path ) throws IOException { } }

implementation:
ImmutableMap . Builder < Integer , Grib2Parameter > builder = ImmutableMap . builder ( ) ; if ( debugOpen ) { System . out . printf ( "readEcmwfTable path= %s%n" , path ) ; } ClassLoader cl = Grib2TableConfig . class . getClassLoader ( ) ; try ( InputStream is = cl . getResourceAsStream ( path ) ) { if ( is == null ) { throw new IllegalStateException ( "Cant find " + path ) ; } try ( BufferedReader dataIS = new BufferedReader ( new InputStreamReader ( is , Charset . forName ( "UTF8" ) ) ) ) { int count = 0 ; while ( true ) { String line = dataIS . readLine ( ) ; if ( line == null ) { break ; } if ( line . startsWith ( "#" ) || line . trim ( ) . length ( ) == 0 ) { continue ; } count ++ ; int posBlank1 = line . indexOf ( ' ' ) ; int posBlank2 = line . indexOf ( ' ' , posBlank1 + 1 ) ; int lastParen = line . lastIndexOf ( '(' ) ; String num1 = line . substring ( 0 , posBlank1 ) . trim ( ) ; String num2 = line . substring ( posBlank1 + 1 , posBlank2 ) ; String desc = ( lastParen > 0 ) ? line . substring ( posBlank2 + 1 , lastParen ) . trim ( ) : line . substring ( posBlank2 + 1 ) . trim ( ) ; String units = ( lastParen > 0 ) ? line . substring ( lastParen ) . trim ( ) : "" ; if ( units . startsWith ( "(" ) & units . endsWith ( ")" ) ) units = units . substring ( 1 , units . length ( ) - 1 ) ; if ( ! num1 . equals ( num2 ) ) { if ( debug ) { System . out . printf ( "*****num1 != num2 for %s%n" , line ) ; } continue ; } int number = Integer . parseInt ( num1 ) ; // public Grib2Parameter ( int discipline , int category , int number , String name , String unit , String abbrev ) {
Grib2Parameter parameter = new Grib2Parameter ( discipline , category , number , desc , units , null , desc ) ; builder . put ( parameter . getNumber ( ) , parameter ) ; if ( debug ) { System . out . printf ( " %s%n" , parameter ) ; } } } } return builder . build ( ) ;


signature:
public class SimpleGeomController { /** * stuff to do after UI is complete */
void finishInit ( ) { } }

implementation:
// some widgets from the GridUI
np = ui . panz ; vertPanel = ui . vertPanel ; dataValueLabel = ui . dataValueLabel ; posLabel = ui . positionLabel ; // get last saved Projection
project = ( ProjectionImpl ) store . getBean ( LastProjectionName , null ) ; if ( project != null ) setProjection ( project ) ; // get last saved MapArea
ProjectionRect ma = ( ProjectionRect ) store . getBean ( LastMapAreaName , null ) ; if ( ma != null ) np . setMapArea ( ma ) ; makeEventManagement ( ) ; // last thing
/* get last dataset filename and reopen it
 String filename = ( String ) store . get ( LastDatasetName ) ;
 if ( filename ! = null )
 setDataset ( filename ) ; */


signature:
public class SimpleGeomController { /** * assume that its done in the event thread */
boolean showDataset ( ) { } }

implementation:
// temp kludge for initialization
java . util . List grids = gridDataset . getGrids ( ) ; if ( ( grids == null ) || grids . size ( ) == 0 ) { javax . swing . JOptionPane . showMessageDialog ( null , "No gridded fields in file " + gridDataset . getTitle ( ) ) ; return false ; } currentField = ( GridDatatype ) grids . get ( 0 ) ; currentSlice = 0 ; currentLevel = 0 ; currentTime = 0 ; currentEnsemble = 0 ; currentRunTime = 0 ; eventsOK = false ; // dont let this trigger redraw
renderGrid . setGeoGrid ( currentField ) ; ui . setFields ( gridDataset . getGrids ( ) ) ; setField ( currentField ) ; // if possible , change the projection and the map area to one that fits this
// dataset
ProjectionImpl dataProjection = currentField . getProjection ( ) ; if ( dataProjection != null ) setProjection ( dataProjection ) ; // ready to draw
// draw ( true ) ;
// events now ok
eventsOK = true ; return true ;


signature:
public class SimpleGeomController { /** * public GridDatatype getField ( ) { return currentField ; } */
private boolean setField ( Object fld ) { } }

implementation:
GridDatatype gg = null ; if ( fld instanceof GridDatatype ) gg = ( GridDatatype ) fld ; else if ( fld instanceof String ) gg = gridDataset . findGridDatatype ( ( String ) fld ) ; if ( null == gg ) return false ; renderGrid . setGeoGrid ( gg ) ; currentField = gg ; GridCoordSystem gcs = gg . getCoordinateSystem ( ) ; gcs . setProjectionBoundingBox ( ) ; // set levels
CoordinateAxis1D vaxis = gcs . getVerticalAxis ( ) ; levelNames = ( vaxis == null ) ? new ArrayList ( ) : vaxis . getNames ( ) ; if ( ( levelNames == null ) || ( currentLevel >= levelNames . size ( ) ) ) currentLevel = 0 ; vertPanel . setCoordSys ( currentField . getCoordinateSystem ( ) , currentLevel ) ; // set times
if ( gcs . hasTimeAxis ( ) ) { CoordinateAxis1DTime taxis = gcs . hasTimeAxis1D ( ) ? gcs . getTimeAxis1D ( ) : gcs . getTimeAxisForRun ( 0 ) ; timeNames = ( taxis == null ) ? new ArrayList ( ) : taxis . getNames ( ) ; if ( ( timeNames == null ) || ( currentTime >= timeNames . size ( ) ) ) currentTime = 0 ; hasDependentTimeAxis = ! gcs . hasTimeAxis1D ( ) ; } else hasDependentTimeAxis = false ; // set ensembles
CoordinateAxis1D eaxis = gcs . getEnsembleAxis ( ) ; ensembleNames = ( eaxis == null ) ? new ArrayList ( ) : eaxis . getNames ( ) ; currentEnsemble = ensembleNames . size ( ) > 0 ? 0 : - 1 ; // set runtimes
CoordinateAxis1DTime rtaxis = gcs . getRunTimeAxis ( ) ; runtimeNames = ( rtaxis == null ) ? new ArrayList ( ) : rtaxis . getNames ( ) ; currentRunTime = runtimeNames . size ( ) > 0 ? 0 : - 1 ; ui . setField ( gg ) ; return true ;


signature:
public class NcepRfcTables { /** * / * TABLE C - SUB - CENTERS FOR CENTER 9 US NWS FIELD STATIONS
 * from bdgparm . f John Halquist < John . Halquist @ noaa . gov > 9/12/2011
 * These are not in the WMO common tables like NCEP ' s are */
@ Override @ Nullable public String getSubCenterName ( int subcenter ) { } }

implementation: if ( nwsoSubCenter == null ) nwsoSubCenter = readNwsoSubCenter ( "resources/grib1/noaa_rfc/tableC.txt" ) ; if ( nwsoSubCenter == null ) return null ; return nwsoSubCenter . get ( subcenter ) ;


signature:
public class NcepRfcTables { /** * order : num , name , desc , unit */
@ Nullable private static Map < Integer , String > readNwsoSubCenter ( String path ) { } }

implementation:
Map < Integer , String > result = new HashMap < > ( ) ; try ( InputStream is = GribResourceReader . getInputStream ( path ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( is , CDM . utf8Charset ) ) ) { while ( true ) { String line = br . readLine ( ) ; if ( line == null ) { break ; } if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) { continue ; } StringBuilder lineb = new StringBuilder ( line ) ; StringUtil2 . remove ( lineb , "'+,/" ) ; String [ ] flds = lineb . toString ( ) . split ( "[:]" ) ; int val = Integer . parseInt ( flds [ 0 ] . trim ( ) ) ; // must have a number
String name = flds [ 1 ] . trim ( ) + ": " + flds [ 2 ] . trim ( ) ; result . put ( val , name ) ; } return Collections . unmodifiableMap ( result ) ; // all at once - thread safe
} catch ( IOException ioError ) { logger . warn ( "An error occurred in Grib1Tables while trying to open the table " + path + " : " + ioError ) ; return null ; }


signature:
public class CalendarDateRange { /** * Does not handle non - standard calendars
 * @ deprecated */
static public CalendarDateRange of ( DateRange dr ) { } }

implementation: if ( dr == null ) return null ; return CalendarDateRange . of ( dr . getStart ( ) . getDate ( ) , dr . getEnd ( ) . getDate ( ) ) ;


signature:
public class Grib2Gds { /** * reletive error in position - GRIB numbers sometimes miscoded */
public static Grib2Gds factory ( int template , byte [ ] data ) { } }

implementation:
Grib2Gds result ; switch ( template ) { case 0 : result = new LatLon ( data ) ; break ; case 1 : result = new RotatedLatLon ( data ) ; break ; case 10 : result = new Mercator ( data ) ; break ; case 20 : result = new PolarStereographic ( data ) ; break ; case 30 : result = new LambertConformal ( data , 30 ) ; break ; case 31 : result = new AlbersEqualArea ( data ) ; break ; case 40 : result = new GaussLatLon ( data ) ; break ; case 50 : // Spherical Harmonic Coefficients BOGUS
result = new GdsSpherical ( data , template ) ; break ; case 90 : result = new SpaceViewPerspective ( data ) ; break ; // LOOK NCEP specific
case 204 : result = new CurvilinearOrthogonal ( data ) ; break ; case 32769 : result = new RotatedLatLon32769 ( data ) ; break ; default : throw new UnsupportedOperationException ( "Unsupported GDS type = " + template ) ; } result . finish ( ) ; // stuff that cant be done in the constructor
return result ;


signature:
public class Grib2Gds { /** * Code Table Code table 3.2 - Shape of the Earth ( 3.2)
 * 0 : Earth assumed spherical with radius = 6 367 470.0 m
 * 1 : Earth assumed spherical with radius specified ( in m ) by data producer
 * 2 : Earth assumed oblate spheroid with size as determined by IAU in 1965 ( major axis = 6 378 160.0 m , minor axis = 6 356 775.0 m , f = 1/297.0)
 * 3 : Earth assumed oblate spheroid with major and minor axes specified ( in km ) by data producer
 * 4 : Earth assumed oblate spheroid as defined in IAG - GRS80 model ( major axis = 6 378 137.0 m , minor axis = 6 356 752.314 m , f = 1/298.257 222 101)
 * 5 : Earth assumed represented by WGS84 ( as used by ICAO since 1998)
 * 6 : Earth assumed spherical with radius of 6 371 229.0 m
 * 7 : Earth assumed oblate spheroid with major or minor axes specified ( in m ) by data producer
 * 8 : Earth model assumed spherical with radius of 6 371 200 m , but the horizontal datum of the resulting
 * latitude / longitude field is the WGS84 reference frame */
protected Earth getEarth ( ) { } }

implementation:
switch ( earthShape ) { case 0 : return new Earth ( 6367470.0 ) ; case 1 : if ( earthRadius < 6000000 ) earthRadius *= 1000.0 ; // bad units
return new Earth ( earthRadius ) ; case 2 : return EarthEllipsoid . IAU ; case 3 : // oblate in km , so bad values will be large and not scaled
if ( majorAxis < 6000000 ) majorAxis *= 1000.0 ; if ( minorAxis < 6000000 ) minorAxis *= 1000.0 ; return new EarthEllipsoid ( "Grib2 Type 3" , - 1 , majorAxis , minorAxis , 0 ) ; case 4 : return EarthEllipsoid . IAG_GRS80 ; case 5 : return EarthEllipsoid . WGS84 ; case 6 : return new Earth ( 6371229.0 ) ; case 7 : // Oblate in meters
if ( majorAxis < 6000000 ) majorAxis *= 1000.0 ; // bad units
if ( minorAxis < 6000000 ) minorAxis *= 1000.0 ; // bad units
return new EarthEllipsoid ( "Grib2 Type 7" , - 1 , majorAxis , minorAxis , 0 ) ; case 8 : return new Earth ( 6371200.0 ) ; case 9 : return EarthEllipsoid . Airy1830 ; default : return new Earth ( ) ; }


signature:
public class AlbersEqualAreaEllipse { /** * also see Snyder p 101 */
public ProjectionPoint latLonToProj ( LatLonPoint latLon , ProjectionPointImpl result ) { } }

implementation: double fromLat = Math . toRadians ( latLon . getLatitude ( ) ) ; double theta = computeTheta ( latLon . getLongitude ( ) ) ; double term = earth . isSpherical ( ) ? n2 * Math . sin ( fromLat ) : n * MapMath . qsfn ( Math . sin ( fromLat ) , e , one_es ) ; double rho = c - term ; if ( rho < 0.0 ) throw new RuntimeException ( "F" ) ; rho = dd * Math . sqrt ( rho ) ; double toX = rho * Math . sin ( theta ) ; double toY = rho0 - rho * Math . cos ( theta ) ; result . setLocation ( totalScale * toX + falseEasting , totalScale * toY + falseNorthing ) ; return result ;


signature:
public class AlbersEqualAreaEllipse { /** * Convert projection coordinates to a LatLonPoint
 * Note : a new object is not created on each call for the return value .
 * @ param world convert from these projection coordinates
 * @ param result the object to write to
 * @ return LatLonPoint convert to these lat / lon coordinates
 * public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) {
 * double toLat , toLon ;
 * double fromX = world . getX ( ) - falseEasting ;
 * double fromY = world . getY ( ) - falseNorthing ;
 * double rrho0 = rho0;
 * if ( n < 0 ) {
 * rrho0 * = - 1.0;
 * fromX * = - 1.0;
 * fromY * = - 1.0;
 * double yd = rrho0 - fromY ;
 * double rho = Math . sqrt ( fromX * fromX + yd * yd ) ;
 * double theta = Math . atan2 ( fromX , yd ) ;
 * if ( n < 0 ) {
 * rho * = - 1.0;
 * toLat = Math . toDegrees ( Math . asin ( ( C - Math . pow ( ( rho * n / EARTH _ RADIUS ) , 2 ) ) / ( 2 * n ) ) ) ;
 * toLon = Math . toDegrees ( theta / n + lon0 ) ;
 * result . setLatitude ( toLat ) ;
 * result . setLongitude ( toLon ) ;
 * return result ;
 * public Point2D . Double projectInverse ( double xyx , double xyy , Point2D . Double out ) {
 * double rho ;
 * if ( ( rho = MapMath . distance ( xyx , xyy = rho0 - xyy ) ) ! = 0 ) {
 * double lpphi , lplam ;
 * if ( n < 0 . ) {
 * rho = - rho ;
 * xyx = - xyx ;
 * xyy = - xyy ;
 * lpphi = rho / dd ;
 * if ( ! spherical ) {
 * lpphi = ( c - lpphi * lpphi ) / n ;
 * if ( Math . abs ( ec - Math . abs ( lpphi ) ) > TOL7 ) {
 * if ( ( lpphi = phi1 _ ( lpphi , e , one _ es ) ) = = Double . MAX _ VALUE )
 * throw new ProjectionException ( " I " ) ;
 * } else
 * lpphi = lpphi < 0 . ? - MapMath . HALFPI : MapMath . HALFPI ;
 * } else if ( Math . abs ( out . y = ( c - lpphi * lpphi ) / n2 ) < = 1 . )
 * lpphi = Math . asin ( lpphi ) ;
 * else
 * lpphi = lpphi < 0 . ? - MapMath . HALFPI : MapMath . HALFPI ;
 * lplam = Math . atan2 ( xyx , xyy ) / n ;
 * out . x = lplam ;
 * out . y = lpphi ;
 * } else {
 * out . x = 0 . ;
 * out . y = n > 0 . ? MapMath . HALFPI : - MapMath . HALFPI ;
 * return out ; */
public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { } }

implementation:
double toLat , toLon ; double fromX = ( world . getX ( ) - falseEasting ) / totalScale ; // assumes cartesion coords in km
double fromY = ( world . getY ( ) - falseNorthing ) / totalScale ; fromY = rho0 - fromY ; double rho = MapMath . distance ( fromX , fromY ) ; if ( rho == 0.0 ) { toLon = 0.0 ; toLat = n > 0.0 ? MapMath . HALFPI : - MapMath . HALFPI ; } else { if ( n < 0.0 ) { rho = - rho ; fromX = - fromX ; fromY = - fromY ; } double lpphi = rho / dd ; if ( ! earth . isSpherical ( ) ) { lpphi = ( c - lpphi * lpphi ) / n ; if ( Math . abs ( ec - Math . abs ( lpphi ) ) > TOL7 ) { if ( Math . abs ( lpphi ) > 2.0 ) throw new IllegalArgumentException ( "AlbersEqualAreaEllipse x,y=" + world ) ; lpphi = phi1_ ( lpphi , e , one_es ) ; if ( lpphi == Double . MAX_VALUE ) throw new RuntimeException ( "I" ) ; } else { lpphi = ( lpphi < 0. ) ? - MapMath . HALFPI : MapMath . HALFPI ; } } else { // spherical case
lpphi = ( c - lpphi * lpphi ) / n2 ; if ( Math . abs ( lpphi ) <= 1.0 ) { lpphi = Math . asin ( lpphi ) ; } else { lpphi = ( lpphi < 0. ) ? - MapMath . HALFPI : MapMath . HALFPI ; } } toLon = Math . atan2 ( fromX , fromY ) / n ; // coverity [ swapped _ arguments ]
toLat = lpphi ; } result . setLatitude ( Math . toDegrees ( toLat ) ) ; result . setLongitude ( Math . toDegrees ( toLon ) + lon0deg ) ; return result ;


signature:
public class Dap2Parse { /** * / * Parse invocation interface */
public int dapparse ( String text , DDS dds , DAS das , DAP2Exception err ) throws ParseException { } }

implementation:
// setDebugLevel ( 1 ) ;
ddsobject = dds ; dasobject = das ; errobject = ( err == null ? new DAP2Exception ( ) : err ) ; dapdebug = getDebugLevel ( ) ; Boolean accept = parse ( text ) ; if ( ! accept ) throw new ParseException ( "Dap2 Parser returned false" ) ; return parseClass ;


signature:
public class Dap2Parse { /** * Call this to parse a DDS */
public int ddsparse ( String text , DDS dds ) throws ParseException { } }

implementation: return dapparse ( text , dds , null , null ) ;


signature:
public class Dap2Parse { /** * Call this to parse a DAS */
public int dasparse ( String text , DAS das ) throws ParseException { } }

implementation: return dapparse ( text , null , das , null ) ;


signature:
public class Dap2Parse { /** * Call this to parse an error { } body */
public int errparse ( String text , DAP2Exception err ) throws ParseException { } }

implementation: return dapparse ( text , null , null , err ) ;


signature:
public class Dap2Parse { /** * / * Use the initial keyword to indicate what we are parsing */
void tagparse ( Dap2Parse parsestate , int kind ) throws ParseException { } }

implementation:
/* Create the storage object corresponding to what we are parsing */
String expected = parseactual ( ) ; switch ( kind ) { case SCAN_DATASET : parseClass = DapDDS ; if ( ddsobject == null ) throw new ParseException ( "DapParse: found DDS, expected " + expected ) ; break ; case SCAN_ATTR : parseClass = DapDAS ; if ( dasobject == null ) throw new ParseException ( "DapParse: found DAS, expected " + parseactual ( ) ) ; lexstate . dassetup ( ) ; break ; case SCAN_ERROR : parseClass = DapERR ; if ( errobject == null ) throw new ParseException ( "DapParse: found error{}, expected " + parseactual ( ) ) ; break ; default : throw new ParseException ( "Unknown tag argument: " + kind ) ; }


signature:
public class Dap2Parse { /** * / * Since there is no common parent class for BaseType , Attribute ,
 * and AttributeTable , provide a type specific name getter . */
String extractname ( Object o ) throws ParseException { } }

implementation: if ( o instanceof BaseType ) return ( ( BaseType ) o ) . getClearName ( ) ; if ( o instanceof Attribute ) return ( ( Attribute ) o ) . getClearName ( ) ; if ( o instanceof AttributeTable ) return ( ( AttributeTable ) o ) . getClearName ( ) ; throw new ParseException ( "extractname: illegal object class: " + o ) ;


signature:
public class McIDASGridReader { /** * Initialize the file , read in all the metadata ( ala DM _ OPEN )
 * @ param fullCheck for a full check reading grids
 * @ param raf RandomAccessFile to read .
 * @ throws IOException problem reading file */
public final boolean init ( RandomAccessFile raf , boolean fullCheck ) throws IOException { } }

implementation: rf = raf ; raf . order ( RandomAccessFile . BIG_ENDIAN ) ; return init ( fullCheck ) ;


signature:
public class McIDASGridReader { /** * Initialize this reader . Get the Grid specific info
 * @ param fullCheck for a full check reading grids
 * @ return true if successful , false if not a mcidas grid file
 * @ throws IOException problem reading the data */
protected boolean init ( boolean fullCheck ) throws IOException { } }

implementation:
if ( rf == null ) { logError ( "File is null" ) ; return false ; } gridIndex = new GridIndex ( rf . getLocation ( ) ) ; rf . order ( RandomAccessFile . BIG_ENDIAN ) ; if ( rf . length ( ) < 44 ) return false ; int numEntries = Math . abs ( readInt ( 10 ) ) ; if ( numEntries > 1000000 ) { needToSwap = true ; numEntries = Math . abs ( McIDASUtil . swbyt4 ( numEntries ) ) ; } if ( numEntries > MAX_GRIDS ) { return false ; } // System . out . println ( " need to Swap = " + needToSwap ) ;
// System . out . println ( " number entries = " + numEntries ) ;
// go back to the beginning
rf . seek ( 0 ) ; // read the fileheader
String label = rf . readString ( 32 ) ; // GEMPAK too closely like McIDAS
if ( label . contains ( "GEMPAK DATA MANAGEMENT FILE" ) ) { logError ( "label indicates this is a GEMPAK grid" ) ; return false ; } else { // check that they are all printable ASCII chars
for ( int i = 0 ; i < label . length ( ) ; i ++ ) { String s0 = label . substring ( i , i + 1 ) ; if ( ! ( 0 <= s0 . compareTo ( " " ) && s0 . compareTo ( "~" ) <= 0 ) ) { logError ( "bad label, not a McIDAS grid" ) ; return false ; } } } // System . out . println ( " label = " + label ) ;
// int project = readInt ( 8 ) ;
// System . out . println ( " Project = " + project ) ;
int date = readInt ( 9 ) ; // dates are supposed to be yyyddd , but account for ccyyddd up to year 4000
if ( ( date < 10000 ) || ( date > 400000 ) ) { logError ( "date wrong, not a McIDAS grid" ) ; return false ; } // System . out . println ( " date = " + date ) ;
if ( rf . length ( ) < 4 * ( numEntries + 12 ) ) return false ; int [ ] entries = new int [ numEntries ] ; for ( int i = 0 ; i < numEntries ; i ++ ) { entries [ i ] = readInt ( i + 11 ) ; // sanity check that this is indeed a McIDAS Grid file
if ( entries [ i ] < - 1 ) { logError ( "bad grid offset " + i + ": " + entries [ i ] ) ; return false ; } } if ( ! fullCheck ) { return true ; } // Don ' t swap :
rf . order ( RandomAccessFile . BIG_ENDIAN ) ; for ( int i = 0 ; i < numEntries ; i ++ ) { if ( entries [ i ] == - 1 ) { continue ; } int [ ] header = new int [ 64 ] ; rf . seek ( entries [ i ] * 4 ) ; rf . readInt ( header , 0 , 64 ) ; if ( needToSwap ) { swapGridHeader ( header ) ; } try { McIDASGridRecord gr = new McIDASGridRecord ( entries [ i ] , header ) ; // if ( gr . getGridDefRecordId ( ) . equals ( " CONF X : 93 Y : 65 " ) ) {
// if ( gr . getGridDefRecordId ( ) . equals ( " CONF X : 54 Y : 47 " ) ) {
// figure out how to handle Mercator projections
// if ( ! ( gr . getGridDefRecordId ( ) . startsWith ( " MERC " ) ) ) {
gridIndex . addGridRecord ( gr ) ; if ( gdsMap . get ( gr . getGridDefRecordId ( ) ) == null ) { McGridDefRecord mcdef = gr . getGridDefRecord ( ) ; // System . out . println ( " new nav " + mcdef . toString ( ) ) ;
gdsMap . put ( mcdef . toString ( ) , mcdef ) ; gridIndex . addHorizCoordSys ( mcdef ) ; } } catch ( McIDASException me ) { logError ( "problem creating grid dir" ) ; return false ; } } // check to see if there are any grids that we can handle
if ( gridIndex . getGridRecords ( ) . isEmpty ( ) ) { logError ( "no grids found" ) ; return false ; } return true ;


signature:
public class McIDASGridReader { /** * Swap the grid header , avoiding strings
 * @ param gh grid header to swap */
private void swapGridHeader ( int [ ] gh ) { } }

implementation: McIDASUtil . flip ( gh , 0 , 5 ) ; McIDASUtil . flip ( gh , 7 , 7 ) ; McIDASUtil . flip ( gh , 9 , 10 ) ; McIDASUtil . flip ( gh , 12 , 14 ) ; McIDASUtil . flip ( gh , 32 , 51 ) ;


signature:
public class McIDASGridReader { /** * Read the grid
 * @ param gr the grid record
 * @ return the data */
public float [ ] readGrid ( McIDASGridRecord gr ) throws IOException { } }

implementation:
float [ ] data ; // try {
int te = ( gr . getOffsetToHeader ( ) + 64 ) * 4 ; int rows = gr . getRows ( ) ; int cols = gr . getColumns ( ) ; rf . seek ( te ) ; float scale = ( float ) gr . getParamScale ( ) ; data = new float [ rows * cols ] ; rf . order ( needToSwap ? RandomAccessFile . LITTLE_ENDIAN : RandomAccessFile . BIG_ENDIAN ) ; // int n = 0;
// store such that 0,0 is in lower left corner . . .
for ( int nc = 0 ; nc < cols ; nc ++ ) { for ( int nr = 0 ; nr < rows ; nr ++ ) { int temp = rf . readInt ( ) ; // check for missing value
data [ ( rows - nr - 1 ) * cols + nc ] = ( temp == McIDASUtil . MCMISSING ) ? Float . NaN : ( ( float ) temp ) / scale ; } } rf . order ( RandomAccessFile . BIG_ENDIAN ) ; // } catch ( Exception esc ) {
// System . out . println ( esc ) ;
return data ;


signature:
public class McIDASGridReader { /** * Read an integer
 * @ param word word in file ( 0 based ) to read
 * @ return int read
 * @ throws IOException problem reading file */
public int readInt ( int word ) throws IOException { } }

implementation:
if ( rf == null ) { throw new IOException ( "no file to read from" ) ; } rf . seek ( word * 4 ) ; // set the order
if ( needToSwap ) { rf . order ( RandomAccessFile . LITTLE_ENDIAN ) ; // swap
} else { rf . order ( RandomAccessFile . BIG_ENDIAN ) ; } int idata = rf . readInt ( ) ; rf . order ( RandomAccessFile . BIG_ENDIAN ) ; return idata ;


signature:
public class McIDASGridReader { /** * for testing purposes
 * @ param args file name
 * @ throws IOException problem reading file */
public static void main ( String [ ] args ) throws IOException { } }

implementation: String file = "GRID2001" ; if ( args . length > 0 ) { file = args [ 0 ] ; } McIDASGridReader mg = new McIDASGridReader ( file ) ; GridIndex gridIndex = mg . getGridIndex ( ) ; List grids = gridIndex . getGridRecords ( ) ; System . out . println ( "found " + grids . size ( ) + " grids" ) ; int num = Math . min ( grids . size ( ) , 10 ) ; for ( int i = 0 ; i < num ; i ++ ) { System . out . println ( grids . get ( i ) ) ; }