public static NetcdfFile openFile(String location, ucar.nc2.util.CancelTask cancelTask) throws IOException {
    DatasetUrl durl = DatasetUrl.findDatasetUrl(location);
    return openOrAcquireFile(null, null, null, durl, -1, cancelTask, null);
  }

public static NetcdfFile openFile ( String location , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { DatasetUrl durl = DatasetUrl . findDatasetUrl ( location ) ; return openOrAcquireFile ( null , null , null , durl , - 1 , cancelTask , null ) ; }

Factory method for opening a NetcdfFile through the netCDF API.

@param location   location of dataset.
@param cancelTask use to allow task to be cancelled; may be null.
@return NetcdfFile object
@throws java.io.IOException on read error

Factory method for opening a NetcdfFile through the netCDF API .


public void clearCoordinateSystems() {
    coordSys = new ArrayList<>();
    coordAxes = new ArrayList<>();
    coordTransforms = new ArrayList<>();

    for (Variable v : getVariables()) {
      VariableEnhanced ve = (VariableEnhanced) v;
      ve.clearCoordinateSystems(); // ??
    }

    enhanceMode.remove(Enhance.CoordSystems);
  }

public
void
clearCoordinateSystems
(
)
{
coordSys
=
new
ArrayList
<>
(
)
;
coordAxes
=
new
ArrayList
<>
(
)
;
coordTransforms
=
new
ArrayList
<>
(
)
;
for
(
Variable
v
:
getVariables
(
)
)
{
VariableEnhanced
ve
=
(
VariableEnhanced
)
v
;
ve
.
clearCoordinateSystems
(
)
;
// ??
}
enhanceMode
.
remove
(
Enhance
.
CoordSystems
)
;
}

Clear Coordinate System metadata, to allow them to be redone

Clear Coordinate System metadata to allow them to be redone


public CoordinateAxis findCoordinateAxis(AxisType type) {
    if (type == null) return null;
    for (CoordinateAxis v : coordAxes) {
      if (type == v.getAxisType())
        return v;
    }
    return null;
  }

public CoordinateAxis findCoordinateAxis ( AxisType type ) { if ( type == null ) return null ; for ( CoordinateAxis v : coordAxes ) { if ( type == v . getAxisType ( ) ) return v ; } return null ; }

Retrieve the CoordinateAxis with the specified Axis Type.

@param type axis type
@return the first CoordinateAxis that has that type, or null if not found

Retrieve the CoordinateAxis with the specified Axis Type .


public CoordinateAxis findCoordinateAxis(String fullName) {
    if (fullName == null) return null;
    for (CoordinateAxis v : coordAxes) {
      if (fullName.equals(v.getFullName()))
        return v;
    }
    return null;
  }

public CoordinateAxis findCoordinateAxis ( String fullName ) { if ( fullName == null ) return null ; for ( CoordinateAxis v : coordAxes ) { if ( fullName . equals ( v . getFullName ( ) ) ) return v ; } return null ; }

Retrieve the CoordinateAxis with the specified type.

@param fullName full escaped name of the coordinate axis
@return the CoordinateAxis, or null if not found

Retrieve the CoordinateAxis with the specified type .


public CoordinateSystem findCoordinateSystem(String name) {
    if (name == null) return null;
    for (CoordinateSystem v : coordSys) {
      if (name.equals(v.getName()))
        return v;
    }
    return null;
  }

public CoordinateSystem findCoordinateSystem ( String name ) { if ( name == null ) return null ; for ( CoordinateSystem v : coordSys ) { if ( name . equals ( v . getName ( ) ) ) return v ; } return null ; }

Retrieve the CoordinateSystem with the specified name.

@param name String which identifies the desired CoordinateSystem
@return the CoordinateSystem, or null if not found

Retrieve the CoordinateSystem with the specified name .


public CoordinateTransform findCoordinateTransform(String name) {
    if (name == null) return null;
    for (CoordinateTransform v : coordTransforms) {
      if (name.equals(v.getName()))
        return v;
    }
    return null;
  }

public CoordinateTransform findCoordinateTransform ( String name ) { if ( name == null ) return null ; for ( CoordinateTransform v : coordTransforms ) { if ( name . equals ( v . getName ( ) ) ) return v ; } return null ; }

Retrieve the CoordinateTransform with the specified name.

@param name String which identifies the desired CoordinateSystem
@return the CoordinateSystem, or null if not found

Retrieve the CoordinateTransform with the specified name .


public boolean enhanceNeeded(Set<Enhance> want) throws IOException {
    if (want == null) return false;
    for (Enhance mode : want) {
      if (!this.enhanceMode.contains(mode)) return true;
    }
    return false;
  }

public boolean enhanceNeeded ( Set < Enhance > want ) throws IOException { if ( want == null ) return false ; for ( Enhance mode : want ) { if ( ! this . enhanceMode . contains ( mode ) ) return true ; } return false ; }

is this enhancement already done ?

@param want enhancements wanted
@return true if wanted enhancement is not done
@throws java.io.IOException on error


public void setValues(Variable v, int npts, double start, double incr) {
    if (npts != v.getSize())
      throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize());
    Array data = Array.makeArray(v.getDataType(), npts, start, incr);
    if (v.getRank() != 1)
      data = data.reshape(v.getShape());
    v.setCachedData(data, true);
  }

public
void
setValues
(
Variable
v
,
int
npts
,
double
start
,
double
incr
)
{
if
(
npts
!=
v
.
getSize
(
)
)
throw
new
IllegalArgumentException
(
"bad npts = "
+
npts
+
" should be "
+
v
.
getSize
(
)
)
;
Array
data
=
Array
.
makeArray
(
v
.
getDataType
(
)
,
npts
,
start
,
incr
)
;
if
(
v
.
getRank
(
)
!=
1
)
data
=
data
.
reshape
(
v
.
getShape
(
)
)
;
v
.
setCachedData
(
data
,
true
)
;
}

Generate the list of values from a starting value and an increment.
Will reshape to variable if needed.

@param v     for this variable
@param npts  number of values, must = v.getSize()
@param start starting value
@param incr  increment
@deprecated use Variable.setValues()

Generate the list of values from a starting value and an increment . Will reshape to variable if needed .


public void setValues(Variable v, List<String> values) throws IllegalArgumentException {
    Array data = Array.makeArray(v.getDataType(), values);

    if (data.getSize() != v.getSize())
      throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + v.getFullName() +
              " needed= " + v.getSize() + " given=" + data.getSize());

    if (v.getRank() != 1) // dont have to reshape for rank 1
      data = data.reshape(v.getShape());

    v.setCachedData(data, true);
  }

Set the data values from a list of Strings.

@param v      for this variable
@param values list of Strings
@throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
@deprecated use Variable.setValues()

Set the data values from a list of Strings .


static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException {
    return Array.makeArray(dtype, stringValues);
  }

static public Array makeArray ( DataType dtype , List < String > stringValues ) throws NumberFormatException { return Array . makeArray ( dtype , stringValues ) ; }

Make a 1D array from a list of strings.

@param dtype        data type of the array.
@param stringValues list of strings.
@return resulting 1D array.
@throws NumberFormatException if string values not parssable to specified data type
@deprecated use Array#makeArray directly

Make a 1D array from a list of strings .


public long
    index()
    {
        long offset = 0;
        for(int i = 0; i < this.indices.length; i++) {
            offset *= this.dimsizes[i];
            offset += this.indices[i];
        }
        return offset;
    }

public long index ( ) { long offset = 0 ; for ( int i = 0 ; i < this . indices . length ; i ++ ) { offset *= this . dimsizes [ i ] ; offset += this . indices [ i ] ; } return offset ; }

Compute the linear index
from the current odometer indices.

Compute the linear index from the current odometer indices .


static public MFileOS7 getExistingFile(String filename) throws IOException {
    if (filename == null) return null;
    Path path = Paths.get(filename);
    if (Files.exists(path)) return new MFileOS7(path);
    return null;
  }

static public MFileOS7 getExistingFile ( String filename ) throws IOException { if ( filename == null ) return null ; Path path = Paths . get ( filename ) ; if ( Files . exists ( path ) ) return new MFileOS7 ( path ) ; return null ; }

Make MFileOS7 if file exists, otherwise return null
@param filename full path name
@return MFileOS or null

Make MFileOS7 if file exists otherwise return null


public List<EsriFeature> getFeatures(Rectangle2D bBox) {
    if (bBox == null)
      return features;

    List<EsriFeature> list = new ArrayList<>();
    for (EsriFeature gf : features) {
      if (gf.getBounds2D().intersects(bBox))
        list.add(gf);
    }
    return list;
  }

public List < EsriFeature > getFeatures ( Rectangle2D bBox ) { if ( bBox == null ) return features ; List < EsriFeature > list = new ArrayList <> ( ) ; for ( EsriFeature gf : features ) { if ( gf . getBounds2D ( ) . intersects ( bBox ) ) list . add ( gf ) ; } return list ; }

Get a List of all the features in the shapefile that intersect
the specified bounding box.  This requires testing every
feature in the List created at construction, so it's faster to
just give a bounding box o the constructor if you will only do
this once.

@param bBox specifying the bounding box with which all
the returned features bounding boxes have a non-empty
intersection.
@return a new list of features in the shapefile whose bounding
boxes intersect the specified bounding box.

Get a List of all the features in the shapefile that intersect the specified bounding box . This requires testing every feature in the List created at construction so it s faster to just give a bounding box o the constructor if you will only do this once .


private void discretize(double[] d, int n) {
    if (coarseness == 0.0)
      return;
    for (int i = 0; i < n; i++) {
      d[i] = (Math.rint(resolution * d[i]) / resolution);
    }
  }

private void discretize ( double [ ] d , int n ) { if ( coarseness == 0.0 ) return ; for ( int i = 0 ; i < n ; i ++ ) { d [ i ] = ( Math . rint ( resolution * d [ i ] ) / resolution ) ; } }

Discretize elements of array to a lower resolution.  For
example, if resolution = 100., the value 3.14159265358979 will
be changed to 3.14.

@param d array of values to discretize to lower resolution
@param n number of values in array to discretize

Discretize elements of array to a lower resolution . For example if resolution = 100 . the value 3 . 14159265358979 will be changed to 3 . 14 .


public void add(ThreddsMetadata tmd, boolean includeInherited) {
    creators.addAll(tmd.getCreators());
    contributors.addAll(tmd.getContributors());
    dates.addAll(tmd.getDates());
    docs.addAll(tmd.getDocumentation());
    keywords.addAll(tmd.getKeywords());
    projects.addAll(tmd.getProjects());
    properties.addAll(tmd.getProperties());
    publishers.addAll(tmd.getPublishers());
    variables.addAll(tmd.getVariables());

    if (includeInherited)
      metadata.addAll(tmd.getMetadata());
    else {
      for (InvMetadata mdata : tmd.getMetadata() ) {
        if (!mdata.isInherited())
          metadata.add(mdata);
      }
    }

    // LOOK! should be copies ??!!
    if (gc == null) gc = tmd.getGeospatialCoverage();
    if (timeCoverage == null) timeCoverage = tmd.getTimeCoverage();
    if (serviceName == null) serviceName = tmd.getServiceName();
    if (dataType == null) dataType = tmd.getDataType();
    if (dataSize == 0.0) dataSize = tmd.getDataSize();
    if (dataFormat == null) dataFormat = tmd.getDataFormatType();
    if (authorityName == null) authorityName = tmd.getAuthority();
    if (variableMapLink == null) variableMapLink = tmd.getVariableMap();
  }

public
void
add
(
ThreddsMetadata
tmd
,
boolean
includeInherited
)
{
creators
.
addAll
(
tmd
.
getCreators
(
)
)
;
contributors
.
addAll
(
tmd
.
getContributors
(
)
)
;
dates
.
addAll
(
tmd
.
getDates
(
)
)
;
docs
.
addAll
(
tmd
.
getDocumentation
(
)
)
;
keywords
.
addAll
(
tmd
.
getKeywords
(
)
)
;
projects
.
addAll
(
tmd
.
getProjects
(
)
)
;
properties
.
addAll
(
tmd
.
getProperties
(
)
)
;
publishers
.
addAll
(
tmd
.
getPublishers
(
)
)
;
variables
.
addAll
(
tmd
.
getVariables
(
)
)
;
if
(
includeInherited
)
metadata
.
addAll
(
tmd
.
getMetadata
(
)
)
;
else
{
for
(
InvMetadata
mdata
:
tmd
.
getMetadata
(
)
)
{
if
(
!
mdata
.
isInherited
(
)
)
metadata
.
add
(
mdata
)
;
}
}
// LOOK! should be copies ??!!
if
(
gc
==
)
gc
=
tmd
.
getGeospatialCoverage
(
)
;
if
(
timeCoverage
==
)
timeCoverage
=
tmd
.
getTimeCoverage
(
)
;
if
(
serviceName
==
)
serviceName
=
tmd
.
getServiceName
(
)
;
if
(
dataType
==
)
dataType
=
tmd
.
getDataType
(
)
;
if
(
dataSize
==
0.0
)
dataSize
=
tmd
.
getDataSize
(
)
;
if
(
dataFormat
==
)
dataFormat
=
tmd
.
getDataFormatType
(
)
;
if
(
authorityName
==
)
authorityName
=
tmd
.
getAuthority
(
)
;
if
(
variableMapLink
==
)
variableMapLink
=
tmd
.
getVariableMap
(
)
;
}

Add all the content from another ThreddsMetadata

@param tmd              get content from here
@param includeInherited if false, dont add inherited InvMetadata


public void addDocumentation(String type, String content) {
    if (content == null) {
      removeDocumentation(type);
      return;
    }

    content = content.trim();
    for (InvDocumentation doc : getDocumentation()) {
      String dtype = doc.getType();
      if ((dtype != null) && dtype.equalsIgnoreCase(type)) {
        doc.setInlineContent(content);
        return;
      }
    }
    if (content.length() > 0)
      addDocumentation(new InvDocumentation(null, null, null, type, content));
  }

public void addDocumentation ( String type , String content ) { if ( content == null ) { removeDocumentation ( type ) ; return ; } content = content . trim ( ) ; for ( InvDocumentation doc : getDocumentation ( ) ) { String dtype = doc . getType ( ) ; if ( ( dtype != null ) && dtype . equalsIgnoreCase ( type ) ) { doc . setInlineContent ( content ) ; return ; } } if ( content . length ( ) > 0 ) addDocumentation ( new InvDocumentation ( null , null , null , type , content ) ) ; }

set specified type of documentation

@param type    type of documentation
@param content documentation contenet


public void removeDocumentation(String type) {
    Iterator iter = docs.iterator();
    while (iter.hasNext()) {
      InvDocumentation doc = (InvDocumentation) iter.next();
      String dtype = doc.getType();
      if ((dtype != null) && dtype.equalsIgnoreCase(type))
        iter.remove();
    }
  }

public void removeDocumentation ( String type ) { Iterator iter = docs . iterator ( ) ; while ( iter . hasNext ( ) ) { InvDocumentation doc = ( InvDocumentation ) iter . next ( ) ; String dtype = doc . getType ( ) ; if ( ( dtype != null ) && dtype . equalsIgnoreCase ( type ) ) iter . remove ( ) ; } }

remove all instances of specified type of documentation
@param type type of documentation


private int getMaxBytes(long start) {
    int segno = 0;
    while (start >= segMax[segno]) segno++;
    return (int) (segMax[segno] - start);
  }

private int getMaxBytes ( long start ) { int segno = 0 ; while ( start >= segMax [ segno ] ) segno ++ ; return ( int ) ( segMax [ segno ] - start ) ; }

how many more bytes are in this segment ?


public static boolean isMine(NetcdfFile ncfile) {
    String cs = ncfile.findAttValueIgnoreCase(null, CDM.CONVENTIONS, null);
    if (cs != null) return false;

    String s = ncfile.findAttValueIgnoreCase(null, "DataType", null);
    if ((s == null) || !(s.equalsIgnoreCase("LatLonGrid") || s.equalsIgnoreCase("LatLonHeightGrid")))
      return false;

    if ((null == ncfile.findGlobalAttribute("Latitude")) ||
        (null == ncfile.findGlobalAttribute("Longitude")) ||
        (null == ncfile.findGlobalAttribute("LatGridSpacing")) ||
        (null == ncfile.findGlobalAttribute("LonGridSpacing")) ||
        (null == ncfile.findGlobalAttribute("Time")))
      return false;

    return !(null == ncfile.findDimension("Lat") ||
            null == ncfile.findDimension("Lon"));

  }

public static boolean isMine ( NetcdfFile ncfile ) { String cs = ncfile . findAttValueIgnoreCase ( null , CDM . CONVENTIONS , null ) ; if ( cs != null ) return false ; String s = ncfile . findAttValueIgnoreCase ( null , "DataType" , null ) ; if ( ( s == null ) || ! ( s . equalsIgnoreCase ( "LatLonGrid" ) || s . equalsIgnoreCase ( "LatLonHeightGrid" ) ) ) return false ; if ( ( null == ncfile . findGlobalAttribute ( "Latitude" ) ) || ( null == ncfile . findGlobalAttribute ( "Longitude" ) ) || ( null == ncfile . findGlobalAttribute ( "LatGridSpacing" ) ) || ( null == ncfile . findGlobalAttribute ( "LonGridSpacing" ) ) || ( null == ncfile . findGlobalAttribute ( "Time" ) ) ) return false ; return ! ( null == ncfile . findDimension ( "Lat" ) || null == ncfile . findDimension ( "Lon" ) ) ; }

Is this my file?

@param ncfile test this NetcdfFile
@return true if we think this is a NsslRadarMosaicConvention file.


@Override
  public void getDataset(Dataset ds, Object context) {
    if (ds.hasAccess()) {
      DataFactory tdataFactory = new DataFactory();
      Access access = tdataFactory.chooseDatasetAccess(ds.getAccess());
      if (access == null) throw new IllegalStateException();
      MFileRemote mfile = new MFileRemote(access);
      if (mfile.getPath().endsWith(".xml")) return; // eliminate latest.xml  LOOK kludge-o-rama
      mfiles.add(mfile);
      if (debug) System.out.format("add %s %n", mfile.getPath());
    }
  }


static public List<String> breakupConventionNames(String convAttValue) {
    List<String> names = new ArrayList<>();

    if ((convAttValue.indexOf(',') > 0) || (convAttValue.indexOf(';') > 0)) {
      StringTokenizer stoke = new StringTokenizer(convAttValue, ",;");
      while (stoke.hasMoreTokens()) {
        String name = stoke.nextToken();
        names.add(name.trim());
      }
    } else if ((convAttValue.indexOf('/') > 0)) {
      StringTokenizer stoke = new StringTokenizer(convAttValue, "/");
      while (stoke.hasMoreTokens()) {
        String name = stoke.nextToken();
        names.add(name.trim());
      }
    } else {
      StringTokenizer stoke = new StringTokenizer(convAttValue, " ");
      while (stoke.hasMoreTokens()) {
        String name = stoke.nextToken();
        names.add(name.trim());
      }
    }
    return names;
  }

static
public
List
<
String
>
breakupConventionNames
(
String
convAttValue
)
{
List
<
String
>
names
=
new
ArrayList
<>
(
)
;
if
(
(
convAttValue
.
indexOf
(
'
'
)
>
0
)
||
(
convAttValue
.
indexOf
(
'
'
)
>
0
)
)
{
StringTokenizer
stoke
=
new
StringTokenizer
(
convAttValue
,
",;"
)
;
while
(
stoke
.
hasMoreTokens
(
)
)
{
String
name
=
stoke
.
nextToken
(
)
;
names
.
add
(
name
.
trim
(
)
)
;
}
}
else
if
(
(
convAttValue
.
indexOf
(
'
'
)
>
0
)
)
{
StringTokenizer
stoke
=
new
StringTokenizer
(
convAttValue
,
"/"
)
;
while
(
stoke
.
hasMoreTokens
(
)
)
{
String
name
=
stoke
.
nextToken
(
)
;
names
.
add
(
name
.
trim
(
)
)
;
}
}
else
{
StringTokenizer
stoke
=
new
StringTokenizer
(
convAttValue
,
" "
)
;
while
(
stoke
.
hasMoreTokens
(
)
)
{
String
name
=
stoke
.
nextToken
(
)
;
names
.
add
(
name
.
trim
(
)
)
;
}
}
return
names
;
}

Breakup list of Convention names in the Convention attribute in CF compliant way.

@param convAttValue original value of Convention attribute
@return list of Convention names

Breakup list of Convention names in the Convention attribute in CF compliant way .


static public String buildConventionAttribute(String mainConv, String... convAtts) {
    List<String> result = new ArrayList<>();
    result.add(mainConv);
    for (String convs : convAtts) {
      if (convs == null) continue;
      List<String> ss = breakupConventionNames(convs); // may be a list
      for (String s : ss) {
        if (matchConvention(s) == null)  // only add extra ones, not ones that compete with mainConv
          result.add(s);
      }
    }

    // now form comma separated result
    boolean start = true;
    Formatter f = new Formatter();
    for (String s : result) {
      if (start)
        f.format("%s", s);
      else
        f.format(", %s", s);
      start = false;
    }
    return f.toString();
  }

Build a list of Conventions

@param mainConv this is the main convention
@param convAtts list of others, onbly use "extra" Conventions
@return comma separated list of Conventions


@Override
  public void buildCoordinateSystems(NetcdfDataset ncDataset) {
    // put status info into parseInfo that can be shown to someone trying to debug this process
    parseInfo.format("Parsing with Convention = %s%n", conventionName);

    // Bookkeeping info for each variable is kept in the VarProcess inner class
    addVariables(ncDataset, ncDataset.getVariables(), varList);

    // identify which variables are coordinate axes
    findCoordinateAxes(ncDataset);
    // identify which variables are used to describe coordinate system
    findCoordinateSystems(ncDataset);
    // identify which variables are used to describe coordinate transforms
    findCoordinateTransforms(ncDataset);
    // turn Variables into CoordinateAxis objects
    makeCoordinateAxes(ncDataset);
    // make Coordinate Systems for all Coordinate Systems Variables
    makeCoordinateSystems(ncDataset);

    // assign explicit CoordinateSystem objects to variables
    assignCoordinateSystemsExplicit(ncDataset);

    // assign implicit CoordinateSystem objects to variables
    makeCoordinateSystemsImplicit(ncDataset);

    // optionally assign implicit CoordinateSystem objects to variables that dont have one yet
    if (useMaximalCoordSys)
      makeCoordinateSystemsMaximal(ncDataset);

    // make Coordinate Transforms
    makeCoordinateTransforms(ncDataset);

    // assign Coordinate Transforms
    assignCoordinateTransforms(ncDataset);

    if (debug) System.out.println("parseInfo = \n" + parseInfo.toString());
  }

Heres where the work is to identify coordinate axes and coordinate systems.

@param ncDataset modify this dataset

Heres where the work is to identify coordinate axes and coordinate systems .


protected void findCoordinateAxes(NetcdfDataset ncDataset) {
    for (VarProcess vp : varList) {
      if (vp.coordAxes != null)
        findCoordinateAxes(vp, vp.coordAxes);
      if (vp.coordinates != null)
        findCoordinateAxes(vp, vp.coordinates);
    }
  }

protected void findCoordinateAxes ( NetcdfDataset ncDataset ) { for ( VarProcess vp : varList ) { if ( vp . coordAxes != null ) findCoordinateAxes ( vp , vp . coordAxes ) ; if ( vp . coordinates != null ) findCoordinateAxes ( vp , vp . coordinates ) ; } }

Identify coordinate axes, set VarProcess.isCoordinateAxis = true.
Default is to look for those referenced by _CoordinateAxes attribute.
Note coordinate variables are already identified.

@param ncDataset why

Identify coordinate axes set VarProcess . isCoordinateAxis = true . Default is to look for those referenced by _CoordinateAxes attribute . Note coordinate variables are already identified .


protected void findCoordinateSystems(NetcdfDataset ncDataset) {
    for (VarProcess vp : varList) {
      if (vp.coordSys != null) {
        StringTokenizer stoker = new StringTokenizer(vp.coordSys);
        while (stoker.hasMoreTokens()) {
          String vname = stoker.nextToken();
          VarProcess ap = findVarProcess(vname, vp);
          if (ap != null) {
            if (!ap.isCoordinateSystem)
              parseInfo.format(" CoordinateSystem = %s added; referenced from var= %s%n", vname, vp.v.getFullName());
            ap.isCoordinateSystem = true;
          } else {
            parseInfo.format("***Cant find coordSystem %s referenced from var= %s%n", vname, vp.v.getFullName());
            userAdvice.format("***Cant find coordSystem %s referenced from var= %s%n", vname, vp.v.getFullName());
          }
        }
      }
    }
  }

Identify coordinate systems, set VarProcess.isCoordinateSystem = true.
Default is to look for those referenced by _CoordinateSystems attribute.

@param ncDataset why

Identify coordinate systems set VarProcess . isCoordinateSystem = true . Default is to look for those referenced by _CoordinateSystems attribute .


protected void makeCoordinateSystems(NetcdfDataset ncDataset) {
    for (VarProcess vp : varList) {
      if (vp.isCoordinateSystem) {
        vp.makeCoordinateSystem();
      }
    }
  }

protected void makeCoordinateSystems ( NetcdfDataset ncDataset ) { for ( VarProcess vp : varList ) { if ( vp . isCoordinateSystem ) { vp . makeCoordinateSystem ( ) ; } } }

Take all previously identified Coordinate Systems and create a
CoordinateSystem object.

@param ncDataset why

Take all previously identified Coordinate Systems and create a CoordinateSystem object .


protected void makeCoordinateSystemsMaximal(NetcdfDataset ncDataset) {

    boolean requireCompleteCoordSys = !ncDataset.getEnhanceMode().contains(NetcdfDataset.Enhance.IncompleteCoordSystems);

    for (VarProcess vp : varList) {
      VariableEnhanced ve = (VariableEnhanced) vp.v;

      if (vp.hasCoordinateSystem() || !vp.isData()) continue;

      // look through all axes that fit
      List<CoordinateAxis> axisList = new ArrayList<>();
      List<CoordinateAxis> axes = ncDataset.getCoordinateAxes();
      for (CoordinateAxis axis : axes) {
        if (isCoordinateAxisForVariable(axis, ve))
          axisList.add(axis);
      }

      if (axisList.size() < 2) continue;

      String csName = CoordinateSystem.makeName(axisList);
      CoordinateSystem cs = ncDataset.findCoordinateSystem(csName);
      boolean okToBuild = false;

      // do coordinate systems need to be complete?
      // default enhance mode is yes, they must be complete
      if (requireCompleteCoordSys) {
        if (cs != null) {
          // only build if coordinate system is complete
          okToBuild = cs.isComplete(ve);
        }
      } else {
        // coordinate system can be incomplete, so we're ok to build if we find something
        okToBuild = true;
      }

      if (cs != null && okToBuild) {
        ve.addCoordinateSystem(cs);
        parseInfo.format(" assigned maximal CoordSystem '%s' for var= %s%n", cs.getName(), ve.getFullName());

      } else {
        CoordinateSystem csnew = new CoordinateSystem(ncDataset, axisList, null);
        // again, do coordinate systems need to be complete?
        // default enhance mode is yes, they must be complete
        if (requireCompleteCoordSys) {
          // only build if new coordinate system is complete
          okToBuild = csnew.isComplete(ve);
        }
        if (okToBuild) {
          csnew.setImplicit(true);
          ve.addCoordinateSystem(csnew);
          ncDataset.addCoordinateSystem(csnew);
          parseInfo.format(" created maximal CoordSystem '%s' for var= %s%n", csnew.getName(), ve.getFullName());
        }
      }
    }
  }

If a variable still doesnt have a coordinate system, use hueristics to try to find one that was probably forgotten.
Examine existing CS. create a subset of axes that fits the variable. Choose the one with highest rank.
It must have X,Y or lat,lon. If so, add it.

@param ncDataset need this to see if incomplete coordinate systems are allowed

If a variable still doesnt have a coordinate system use hueristics to try to find one that was probably forgotten . Examine existing CS . create a subset of axes that fits the variable . Choose the one with highest rank . It must have X Y or lat lon . If so add it .


protected boolean isCoordinateAxisForVariable(Variable axis, VariableEnhanced v) {
    List<Dimension> varDims = v.getDimensionsAll();
    List<Dimension> axisDims = axis.getDimensionsAll();

    // a CHAR variable must really be a STRING, so leave out the last (string length) dimension
    int checkDims = axisDims.size();
    if (axis.getDataType() == DataType.CHAR)
      checkDims--;

    for (int i = 0; i < checkDims; i++) {
      Dimension axisDim = axisDims.get(i);
      if (!varDims.contains(axisDim)) {
        return false;
      }
    }
    return true;
  }

Does this axis "fit" this variable.
True if all of the dimensions in the axis also appear in the variable.
If char variable, last dimension is left out.

@param axis check if this axis is ok for the given variable
@param v    the given variable
@return true if all of the dimensions in the axis also appear in the variable.

Does this axis fit this variable . True if all of the dimensions in the axis also appear in the variable . If char variable last dimension is left out .


protected void addCoordinateVariable(Dimension dim, VarProcess vp) {
    List<VarProcess> list = coordVarMap.get(dim);
    if (list == null) {
      list = new ArrayList<>();
      coordVarMap.put(dim, list);
    }
    if (!list.contains(vp))
      list.add(vp);
  }

protected void addCoordinateVariable ( Dimension dim , VarProcess vp ) { List < VarProcess > list = coordVarMap . get ( dim ) ; if ( list == null ) { list = new ArrayList <> ( ) ; coordVarMap . put ( dim , list ) ; } if ( ! list . contains ( vp ) ) list . add ( vp ) ; }


public void subset(InvDataset ds) {
    InvDatasetImpl dataset = (InvDatasetImpl) ds;

    // Make all inherited metadata local.
    dataset.transferMetadata(dataset, true);

    topDataset = dataset;
    datasets.clear(); // throw away the rest
    datasets.add(topDataset);

    // parent lookups need to be local
    //InvService service = dataset.getServiceDefault();
    //if (service != null) LOOK
    //  dataset.serviceName = service.getName();
    dataset.dataType = dataset.getDataType();

    // all properties need to be local
    // LOOK dataset.setPropertiesLocal( new ArrayList(dataset.getProperties()));

    // next part requires this before it
    dataset.setCatalog(this);
    dataset.parent = null;

    // any referenced services need to be local
    List<InvService> services = new ArrayList<InvService>(dataset.getServicesLocal());
    findServices(services, dataset);
    dataset.setServicesLocal(services);

    finish();
  }

Munge this catalog so the given dataset is the top catalog.

@param ds make this top; must be existing dataset in this catalog.

@deprecated in favor of thredds.catalog.util.DeepCopyUtils.subsetCatalogOnDataset

Munge this catalog so the given dataset is the top catalog .


public void filter(DatasetFilter filter) {
    mark(filter, topDataset);
    delete(topDataset);
    this.filter = filter;
  }

public void filter ( DatasetFilter filter ) { mark ( filter , topDataset ) ; delete ( topDataset ) ; this . filter = filter ; }

Munge this catalog to remove any dataset that doesnt pass through the filter.

@param filter remove datasets that dont pass this filter.

Munge this catalog to remove any dataset that doesnt pass through the filter .


private boolean mark(DatasetFilter filter, InvDatasetImpl ds) {
    if (ds instanceof InvCatalogRef) {
      InvCatalogRef catRef = (InvCatalogRef) ds;
      if (!catRef.isRead()) return false;
    }

    // recurse into nested datasets first
    boolean allMarked = true;
    for (InvDataset nested : ds.getDatasets()) {
      allMarked &= mark(filter, (InvDatasetImpl) nested);
    }
    if (!allMarked) return false;

    if (filter.accept(ds) >= 0)
      return false;

    // mark for deletion
    ds.setMark(true);
    if (debugFilter) System.out.println(" mark " + ds.getName());
    return true;
  }

private
boolean
mark
(
DatasetFilter
filter
,
InvDatasetImpl
ds
)
{
if
(
ds
instanceof
InvCatalogRef
)
{
InvCatalogRef
catRef
=
(
InvCatalogRef
)
ds
;
if
(
!
catRef
.
isRead
(
)
)
return
false
;
}
// recurse into nested datasets first
boolean
allMarked
=
true
;
for
(
InvDataset
nested
:
ds
.
getDatasets
(
)
)
{
allMarked
&=
mark
(
filter
,
(
InvDatasetImpl
)
nested
)
;
}
if
(
!
allMarked
)
return
false
;
if
(
filter
.
accept
(
ds
)
>=
0
)
return
false
;
// mark for deletion
ds
.
setMark
(
true
)
;
if
(
debugFilter
)
System
.
out
.
println
(
" mark "
+
ds
.
getName
(
)
)
;
return
true
;
}


private void delete(InvDatasetImpl ds) {
    if (ds instanceof InvCatalogRef) {
      InvCatalogRef catRef = (InvCatalogRef) ds;
      if (!catRef.isRead()) return;
    }

    Iterator iter = ds.getDatasets().iterator();
    while (iter.hasNext()) {
      InvDatasetImpl nested = (InvDatasetImpl) iter.next();
      if (nested.getMark()) {
        iter.remove();
        if (debugFilter) System.out.println(" remove " + nested.getName());
      } else
        delete(nested);
    }
  }

private
void
delete
(
InvDatasetImpl
ds
)
{
if
(
ds
instanceof
InvCatalogRef
)
{
InvCatalogRef
catRef
=
(
InvCatalogRef
)
ds
;
if
(
!
catRef
.
isRead
(
)
)
return
;
}
Iterator
iter
=
ds
.
getDatasets
(
)
.
iterator
(
)
;
while
(
iter
.
hasNext
(
)
)
{
InvDatasetImpl
nested
=
(
InvDatasetImpl
)
iter
.
next
(
)
;
if
(
nested
.
getMark
(
)
)
{
iter
.
remove
(
)
;
if
(
debugFilter
)
System
.
out
.
println
(
" remove "
+
nested
.
getName
(
)
)
;
}
else
delete
(
nested
)
;
}
}


public void initOnce(HttpServletRequest req)
            throws SendError
    {
        if(once)
            return;
        once = true;
        log.info(getClass().getName() + " GET initialization");
        if(this.tdsContext == null)
            throw new SendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Cannot find TDS Context");
        // Get server host + port name
        StringBuilder buf = new StringBuilder();
        buf.append(req.getServerName());
        int port = req.getServerPort();
        if(port > 0) {
            buf.append(":");
            buf.append(port);
        }
        this.server = buf.toString();

        // Obtain servlet path info
        String tmp = HTTPUtil.canonicalpath(req.getContextPath());
        this.threddsname = HTTPUtil.nullify(HTTPUtil.relpath(tmp));
        tmp = HTTPUtil.canonicalpath(req.getServletPath());
        this.requestname = HTTPUtil.nullify(HTTPUtil.relpath(tmp));

        if(this.threddsname == null)
            this.threddsname = DEFAULTSERVLETNAME;

        // Get the upload dir
        File updir = tdsContext.getUploadDir();
        if(updir == null) {
            log.warn("No tds.upload.dir specified");
            this.uploaddir = null;
        } else
            this.uploaddir = HTTPUtil.canonicalpath(updir.getAbsolutePath());
        // Get the download dir
        File downdir = tdsContext.getDownloadDir();
        if(downdir == null) {
            log.warn("No tds.download.dir specified");
            this.downloaddir = null;
        } else
            this.downloaddir = HTTPUtil.canonicalpath(downdir.getAbsolutePath());

    }

public
void
initOnce
(
HttpServletRequest
req
)
throws
SendError
{
if
(
once
)
return
;
once
=
true
;
log
.
info
(
getClass
(
)
.
getName
(
)
+
" GET initialization"
)
;
if
(
this
.
tdsContext
==
)
throw
new
SendError
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"Cannot find TDS Context"
)
;
// Get server host + port name
StringBuilder
buf
=
new
StringBuilder
(
)
;
buf
.
append
(
req
.
getServerName
(
)
)
;
int
port
=
req
.
getServerPort
(
)
;
if
(
port
>
0
)
{
buf
.
append
(
":"
)
;
buf
.
append
(
port
)
;
}
this
.
server
=
buf
.
toString
(
)
;
// Obtain servlet path info
String
tmp
=
HTTPUtil
.
canonicalpath
(
req
.
getContextPath
(
)
)
;
this
.
threddsname
=
HTTPUtil
.
nullify
(
HTTPUtil
.
relpath
(
tmp
)
)
;
tmp
=
HTTPUtil
.
canonicalpath
(
req
.
getServletPath
(
)
)
;
this
.
requestname
=
HTTPUtil
.
nullify
(
HTTPUtil
.
relpath
(
tmp
)
)
;
if
(
this
.
threddsname
==
)
this
.
threddsname
=
DEFAULTSERVLETNAME
;
// Get the upload dir
File
updir
=
tdsContext
.
getUploadDir
(
)
;
if
(
updir
==
)
{
log
.
warn
(
"No tds.upload.dir specified"
)
;
this
.
uploaddir
=
;
}
else
this
.
uploaddir
=
HTTPUtil
.
canonicalpath
(
updir
.
getAbsolutePath
(
)
)
;
// Get the download dir
File
downdir
=
tdsContext
.
getDownloadDir
(
)
;
if
(
downdir
==
)
{
log
.
warn
(
"No tds.download.dir specified"
)
;
this
.
downloaddir
=
;
}
else
this
.
downloaddir
=
HTTPUtil
.
canonicalpath
(
downdir
.
getAbsolutePath
(
)
)
;
}

Invoked on first get so that everything is available,
especially Spring stuff.

Invoked on first get so that everything is available especially Spring stuff .


public boolean count(String name, Comparable value) {
    Counter counter = map.get(name);
    if (counter == null) {
      counter = add(name);
    }
    return counter.count(value);
  }

public boolean count ( String name , Comparable value ) { Counter counter = map . get ( name ) ; if ( counter == null ) { counter = add ( name ) ; } return counter . count ( value ) ; }

Add value to the named counter.
Add counter if it doesnt already exist.
@return true if its a new value, not seen before.

Add value to the named counter . Add counter if it doesnt already exist .


private void add(final String name, final String symbol,
                   final double definition) throws PrefixExistsException {
    addName(name, definition);
    addSymbol(symbol, definition);
  }

private void add ( final String name , final String symbol , final double definition ) throws PrefixExistsException { addName ( name , definition ) ; addSymbol ( symbol , definition ) ; }

Adds a prefix to the database.

@param name       The name of the prefix.
@param symbol     The symbol for the prefix.
@param definition The numeric value of the prefix.
@throws PrefixExistsException Attempt to redefine an existing prefix.


public int compare( TableRow other, int col) {
    String s1 = getValueAt(col).toString();
    String s2 = other.getValueAt(col).toString();
    int ret = s1.compareToIgnoreCase( s2);

    // break ties
    if (ret == 0)
      return compareTie( other, col);
    return ret;
  }

public
int
compare
(
TableRow
other
,
int
col
)
{
String
s1
=
getValueAt
(
col
)
.
toString
(
)
;
String
s2
=
other
.
getValueAt
(
col
)
.
toString
(
)
;
int
ret
=
s1
.
compareToIgnoreCase
(
s2
)
;
// break ties
if
(
ret
==
0
)
return
compareTie
(
other
,
col
)
;
return
ret
;
}

for other behavior, override this; use compareXXX routines.

for other behavior override this ; use compareXXX routines .


protected int compareBoolean(TableRow other,  int col, boolean b1, boolean b2) {
    // break ties
    if (b1 == b2)
      return compareTie( other, col);
    return b1 ? 1 : -1;
  }

protected
int
compareBoolean
(
TableRow
other
,
int
col
,
boolean
b1
,
boolean
b2
)
{
// break ties
if
(
b1
==
b2
)
return
compareTie
(
other
,
col
)
;
return
b1
1
:
1
;
}


DapGroup
    getGroupScope()
            throws DapException
    {
        DapGroup gscope = (DapGroup) searchScope(DapSort.GROUP, DapSort.DATASET);
        if(gscope == null) throw new DapException("Undefined Group Scope");
        return gscope;
    }

DapGroup
getGroupScope
(
)
throws
DapException
{
DapGroup
gscope
=
(
DapGroup
)
searchScope
(
DapSort
.
GROUP
,
DapSort
.
DATASET
)
;
if
(
gscope
==
)
throw
new
DapException
(
"Undefined Group Scope"
)
;
return
gscope
;
}


void
    passReserved(XMLAttributeMap map, DapNode node)
            throws ParseException
    {
	try {
           DapAttribute attr = null;
           for(Map.Entry<String, SaxEvent> entry : map.entrySet()) {
                SaxEvent event = entry.getValue();
		String key = entry.getKey();
		String value = event.value;
		if(isReserved(key))
		    node.addXMLAttribute(key,value);
           }
       } catch (DapException de) {
           throw new ParseException(de);
       }
    }

void passReserved ( XMLAttributeMap map , DapNode node ) throws ParseException { try { DapAttribute attr = null ; for ( Map . Entry < String , SaxEvent > entry : map . entrySet ( ) ) { SaxEvent event = entry . getValue ( ) ; String key = entry . getKey ( ) ; String value = event . value ; if ( isReserved ( key ) ) node . addXMLAttribute ( key , value ) ; } } catch ( DapException de ) { throw new ParseException ( de ) ; } }

add any reserved xml attributes to a node unchanged


private boolean hasValidDateRange(String time_start, String time_end, String time_duration) {
    // no range
    if ((null == time_start) && (null == time_end) && (null == time_duration))
      return false;

    if ((null != time_start) && (null != time_end))
      return true;

    if ((null != time_start) && (null != time_duration))
      return true;

    if ((null != time_end) && (null != time_duration))
      return true;

    // misformed range
    // errs.append("Must have 2 of 3 parameters: time_start, time_end, time_duration\n");
    return false;
  }

Determine if a valid date range was specified

@return true if there is a valid date range, false if not.


@Override
    public boolean hasNext()
    {
        switch (state) {
        case INITIAL:
            return (slice.getFirst() < slice.getStop());
        case STARTED:
            return (this.index < slice.getLast());
        case DONE:
        }
        return false;
    }

@ Override public boolean hasNext ( ) { switch ( state ) { case INITIAL : return ( slice . getFirst ( ) < slice . getStop ( ) ) ; case STARTED : return ( this . index < slice . getLast ( ) ) ; case DONE : } return false ; }


synchronized public void register(String className, boolean last)
            throws DapException
    {
        try {
            Class<? extends DSP> klass = (Class<? extends DSP>) loader.loadClass(className);
            register(klass, last);
        } catch (ClassNotFoundException e) {
            throw new DapException(e);
        }
    }

synchronized public void register ( String className , boolean last ) throws DapException { try { Class < ? extends DSP > klass = ( Class < ? extends DSP > ) loader . loadClass ( className ) ; register ( klass , last ) ; } catch ( ClassNotFoundException e ) { throw new DapException ( e ) ; } }

Register a DSP, using its class string name.

@param className Name of class that implements DSP.
@throws IllegalAccessException if class is not accessible.
@throws InstantiationException if class doesnt have a no-arg constructor.
@throws ClassNotFoundException if class not found.

Register a DSP using its class string name .


synchronized public void
    register(Class<? extends DSP> klass, boolean last)
    {
        // is this already defined?
        if(registered(klass)) return;
        if(last)
            registry.add(new Registration(klass));
        else
            registry.add(0, new Registration(klass));
    }

synchronized
public
void
register
(
Class
<
extends
DSP
>
klass
,
boolean
last
)
{
// is this already defined?
if
(
registered
(
klass
)
)
return
;
if
(
last
)
registry
.
add
(
new
Registration
(
klass
)
)
;
else
registry
.
add
(
0
,
new
Registration
(
klass
)
)
;
}

Register a DSP class.

@param klass Class that implements DSP.
@param last  true=>insert at the end of the list; otherwise front
@throws IllegalAccessException if class is not accessible.
@throws InstantiationException if class doesnt have a no-arg constructor.
@throws ClassCastException     if class doesnt implement DSP interface.


synchronized public boolean
    registered(Class<? extends DSP> klass)
    {
        for(Registration r : registry) {
            if(r.dspclass == klass) return true;
        }
        return false;
    }

synchronized public boolean registered ( Class < ? extends DSP > klass ) { for ( Registration r : registry ) { if ( r . dspclass == klass ) return true ; } return false ; }

See if a specific DSP is registered

@param klass Class for which to search


synchronized public void
    unregister(Class<? extends DSP> klass)
    {
        for(int i = 0; i < registry.size(); i++) {
            if(registry.get(i).dspclass == klass) {
                registry.remove(i);
                break;
            }
        }
    }

synchronized public void unregister ( Class < ? extends DSP > klass ) { for ( int i = 0 ; i < registry . size ( ) ; i ++ ) { if ( registry . get ( i ) . dspclass == klass ) { registry . remove ( i ) ; break ; } } }

Unregister dsp.

@param klass Class for which to search


public static Grib2Tables factory(int center, int subCenter, int masterVersion, int localVersion, int genProcessId) {
    Grib2TablesId id = new Grib2TablesId(center, subCenter, masterVersion, localVersion, genProcessId);
    Grib2Tables cust = tables.get(id);
    if (cust != null) return cust;

    // note that we match on id, so same Grib2Customizer may be mapped to multiple id's (eg match on -1)
    Grib2TableConfig config = Grib2TableConfig.matchTable(id);
    cust = build(config);

    tables.put(id, cust);
    return cust;
  }


public double getForecastTimeIntervalSizeInHours(Grib2Pds pds) {
    Grib2Pds.PdsInterval pdsIntv = (Grib2Pds.PdsInterval) pds;
    int timeUnitOrg = pds.getTimeUnit();

    // calculate total "range" in units of timeUnit
    int range = 0;
    for (Grib2Pds.TimeInterval ti : pdsIntv.getTimeIntervals()) {
      if (ti.timeRangeUnit == 255)
        continue;
      if ((ti.timeRangeUnit != timeUnitOrg) || (ti.timeIncrementUnit != timeUnitOrg && ti.timeIncrementUnit != 255 && ti.timeIncrement != 0)) {
        logger.warn("TimeInterval(2) has different units timeUnit org=" + timeUnitOrg + " TimeInterval=" + ti.timeIncrementUnit);
        throw new RuntimeException("TimeInterval(2) has different units");
      }

      range += ti.timeRangeLength;
      if (ti.timeIncrementUnit != 255) range += ti.timeIncrement;
    }

    // now convert that range to units of the requested period.
    CalendarPeriod timeUnitPeriod = Grib2Utils.getCalendarPeriod(convertTimeUnit(timeUnitOrg));
    if (timeUnitPeriod == null) return GribNumbers.UNDEFINEDD;
    if (timeUnitPeriod.equals(CalendarPeriod.Hour)) return range;

    double fac;
    if (timeUnitPeriod.getField() == CalendarPeriod.Field.Month) {
      fac = 30.0 * 24.0;  // nominal hours in a month
    } else if (timeUnitPeriod.getField() == CalendarPeriod.Field.Year) {
      fac = 365.0 * 24.0; // nominal hours in a year
    } else {
      fac = CalendarPeriod.Hour.getConvertFactor(timeUnitPeriod);
    }
    return fac * range;
  }

Get interval size in units of hours.
Only use in GribVariable to decide on variable identity when intvMerge = false.
@param pds must be a Grib2Pds.PdsInterval
@return interval size in units of hours

Get interval size in units of hours . Only use in GribVariable to decide on variable identity when intvMerge = false .


@Nullable
  public int[] getForecastTimeIntervalOffset(Grib2Record gr) {
    TimeCoordIntvDateValue tinvd = getForecastTimeInterval(gr);
    if (tinvd == null) return null;

    Grib2Pds pds = gr.getPDS();
    int unit = convertTimeUnit(pds.getTimeUnit());
    TimeCoordIntvValue tinv = tinvd.convertReferenceDate(gr.getReferenceDate(), Grib2Utils.getCalendarPeriod(unit));
    if (tinv == null) return null;
    int[] result = new int[2];
    result[0] = tinv.getBounds1();
    result[1] = tinv.getBounds2();
    return result;
  }

@ Nullable public int [ ] getForecastTimeIntervalOffset ( Grib2Record gr ) { TimeCoordIntvDateValue tinvd = getForecastTimeInterval ( gr ) ; if ( tinvd == null ) return null ; Grib2Pds pds = gr . getPDS ( ) ; int unit = convertTimeUnit ( pds . getTimeUnit ( ) ) ; TimeCoordIntvValue tinv = tinvd . convertReferenceDate ( gr . getReferenceDate ( ) , Grib2Utils . getCalendarPeriod ( unit ) ) ; if ( tinv == null ) return null ; int [ ] result = new int [ 2 ] ; result [ 0 ] = tinv . getBounds1 ( ) ; result [ 1 ] = tinv . getBounds2 ( ) ; return result ; }

If this has a time interval coordinate, get time interval

@param gr from this record
@return time interval in units of pds.getTimeUnit(), or null if not a time interval

If this has a time interval coordinate get time interval


@Override
  public VertCoordType getVertUnit(int code) {
    //     VertCoordType(int code, String desc, String abbrev, String units, String datum, boolean isPositiveUp, boolean isLayer)
    switch (code) {

      case 11:
      case 12:
        return new VertCoordType(code, "m", null, true);

      case 20:
        return new VertCoordType(code, "K", null, false);

      case 100:
        return new VertCoordType(code, "Pa", null, false);

      case 102:
        return new VertCoordType(code, "m", "mean sea level", true);

      case 103:
        return new VertCoordType(code, "m", "ground", true);

      case 104:
      case 105:
        return new VertCoordType(code, "sigma", null, false); // positive?

      case 106:
        return new VertCoordType(code, "m", "land surface", false);

      case 107:
        return new VertCoordType(code, "K", null, true); // positive?

      case 108:
        return new VertCoordType(code, "Pa", "ground", true);

      case 109:
        return new VertCoordType(code, "K m2 kg-1 s-1", null, true); // positive?

      case 114:
        return new VertCoordType(code, "numeric", null, false);

      case 117:
        return new VertCoordType(code, "m", null, true);

      case 119:
        return new VertCoordType(code, "Pa", null, false); // ??

      case 160:
        return new VertCoordType(code, "m", "sea level", false);

      case 161:
        return new VertCoordType(code, "m", "water surface", false);

      // LOOK NCEP specific
      case 235:
        return new VertCoordType(code, "0.1 C", null, true);

      case 237:
        return new VertCoordType(code, "m", null, true);

      case 238:
        return new VertCoordType(code, "m", null, true);

      default:
        return new VertCoordType(code, null, null, true);
    }
  }

Unit of vertical coordinate.
from Grib2 code table 4.5.
Only levels with units get a dimension added

@param code code from table 4.5
@return level unit, default is empty unit string

Unit of vertical coordinate . from Grib2 code table 4 . 5 . Only levels with units get a dimension added


public void finish()
    {
        if(this.finished)
            return;
        if(this.ce == null)
            this.visiblenodes = nodelist;
        else {
            this.visiblenodes = new ArrayList<DapNode>(nodelist.size());
            for(int i = 0; i < nodelist.size(); i++) {
                DapNode node = nodelist.get(i);
                if(ce.references(node))
                    visiblenodes.add(node);
            }
        }
        this.topvariables = new ArrayList<DapVariable>();
        this.allvariables = new ArrayList<DapVariable>();
        this.allgroups = new ArrayList<DapGroup>();
        this.allenums = new ArrayList<DapEnumeration>();
        this.allcompounds = new ArrayList<DapStructure>();
        this.alldimensions = new ArrayList<DapDimension>();
        finishR(this);
    }

public void finish ( ) { if ( this . finished ) return ; if ( this . ce == null ) this . visiblenodes = nodelist ; else { this . visiblenodes = new ArrayList < DapNode > ( nodelist . size ( ) ) ; for ( int i = 0 ; i < nodelist . size ( ) ; i ++ ) { DapNode node = nodelist . get ( i ) ; if ( ce . references ( node ) ) visiblenodes . add ( node ) ; } } this . topvariables = new ArrayList < DapVariable > ( ) ; this . allvariables = new ArrayList < DapVariable > ( ) ; this . allgroups = new ArrayList < DapGroup > ( ) ; this . allenums = new ArrayList < DapEnumeration > ( ) ; this . allcompounds = new ArrayList < DapStructure > ( ) ; this . alldimensions = new ArrayList < DapDimension > ( ) ; finishR ( this ) ; }


public void
    sort()
    {
        List<DapNode> sorted = new ArrayList<DapNode>();
        sortR(this, sorted);
        // Assign indices
        for(int i = 0; i < sorted.size(); i++) {
            sorted.get(i).setIndex(i);
        }
        this.nodelist = sorted;
    }

public
void
sort
(
)
{
List
<
DapNode
>
sorted
=
new
ArrayList
<
DapNode
>
(
)
;
sortR
(
this
,
sorted
)
;
// Assign indices
for
(
int
i
=
0
;
i
<
sorted
.
size
(
)
;
i
++
)
{
sorted
.
get
(
i
)
.
setIndex
(
i
)
;
}
this
.
nodelist
=
sorted
;
}

Sort the nodelist into prefix left to right order


RandomAccessFile getRaf(int partno, int fileno) throws IOException {
    Partition part = getPartition(partno);
    try (GribCollectionImmutable gc = part.getGribCollection()) {
      return gc.getDataRaf(fileno);
    }
  }

RandomAccessFile getRaf ( int partno , int fileno ) throws IOException { Partition part = getPartition ( partno ) ; try ( GribCollectionImmutable gc = part . getGribCollection ( ) ) { return gc . getDataRaf ( fileno ) ; } }


static public VarAtt findVariableWithAttribute(NetcdfDataset ds, String attName) {
    for (Variable v : ds.getVariables()) {
      Attribute att = v.findAttributeIgnoreCase(attName);
      if (att != null) return new VarAtt(v, att);
    }

    // descend into structures
    for (Variable v : ds.getVariables()) {
      if (v instanceof Structure) {
        Structure s = (Structure) v;
        for (Variable vs : s.getVariables()) {
          Attribute att = vs.findAttributeIgnoreCase(attName);
          if (att != null) return new VarAtt(vs, att);
        }
      }
    }
    return null;
  }

static
public
VarAtt
findVariableWithAttribute
(
NetcdfDataset
ds
,
String
attName
)
{
for
(
Variable
v
:
ds
.
getVariables
(
)
)
{
Attribute
att
=
v
.
findAttributeIgnoreCase
(
attName
)
;
if
(
att
!=
)
return
new
VarAtt
(
v
,
att
)
;
}
// descend into structures
for
(
Variable
v
:
ds
.
getVariables
(
)
)
{
if
(
v
instanceof
Structure
)
{
Structure
s
=
(
Structure
)
v
;
for
(
Variable
vs
:
s
.
getVariables
(
)
)
{
Attribute
att
=
vs
.
findAttributeIgnoreCase
(
attName
)
;
if
(
att
!=
)
return
new
VarAtt
(
vs
,
att
)
;
}
}
}
return
;
}

Find first variable with given attribute name

@param ds      in this dataset
@param attName attribute name, case insensitive
@return first variable with given attribute name, or null


static public Variable findVariableWithAttributeValue(NetcdfDataset ds, String attName, String attValue) {
    for (Variable v : ds.getVariables()) {
      String haveValue = ds.findAttValueIgnoreCase(v, attName, null);
      if ((haveValue != null) && haveValue.equals(attValue))
        return v;
    }

    // descend into structures
    for (Variable v : ds.getVariables()) {
      if (v instanceof Structure) {
        Variable vn = findVariableWithAttributeValue((Structure) v, attName, attValue);
        if (null != vn) return vn;
      }
    }
    return null;
  }

static
public
Variable
findVariableWithAttributeValue
(
NetcdfDataset
ds
,
String
attName
,
String
attValue
)
{
for
(
Variable
v
:
ds
.
getVariables
(
)
)
{
String
haveValue
=
ds
.
findAttValueIgnoreCase
(
v
,
attName
,
)
;
if
(
(
haveValue
!=
)
&&
haveValue
.
equals
(
attValue
)
)
return
v
;
}
// descend into structures
for
(
Variable
v
:
ds
.
getVariables
(
)
)
{
if
(
v
instanceof
Structure
)
{
Variable
vn
=
findVariableWithAttributeValue
(
(
Structure
)
v
,
attName
,
attValue
)
;
if
(
!=
vn
)
return
vn
;
}
}
return
;
}

Find first variable with given attribute name and value.
If not found, search one level into structures.

@param ds       in this dataset
@param attName  attribute name, case insensitive
@param attValue attribute value, case sensitive
@return first variable with given attribute name and value, or null

Find first variable with given attribute name and value . If not found search one level into structures .


static public String findNameOfVariableWithAttributeValue(NetcdfDataset ds, String attName, String attValue) {
    Variable v = findVariableWithAttributeValue(ds, attName, attValue);
    return (v == null) ? null : v.getShortName();
  }

static public String findNameOfVariableWithAttributeValue ( NetcdfDataset ds , String attName , String attValue ) { Variable v = findVariableWithAttributeValue ( ds , attName , attValue ) ; return ( v == null ) ? null : v . getShortName ( ) ; }

Find first variable with given attribute name and value

@param ds       in this dataset
@param attName  attribute name, case insensitive
@param attValue attribute value, case sensitive
@return name of first variable with given attribute name and value, or null


static public Variable findVariableWithAttributeValue(Structure struct, String attName, String attValue) {
    for (Variable v : struct.getVariables()) {
      Attribute att = v.findAttributeIgnoreCase(attName);
      if ((att != null) && att.getStringValue().equals(attValue))
        return v;
    }
    return null;
  }

static public Variable findVariableWithAttributeValue ( Structure struct , String attName , String attValue ) { for ( Variable v : struct . getVariables ( ) ) { Attribute att = v . findAttributeIgnoreCase ( attName ) ; if ( ( att != null ) && att . getStringValue ( ) . equals ( attValue ) ) return v ; } return null ; }

Find first member variable in this struct with given attribute name and value

@param struct   in this structure
@param attName  attribute name, case insensitive
@param attValue attribute value, case sensitive
@return first member variable with given attribute name and value, or null


static public Structure findNestedStructure(Structure s) {
    for (Variable v : s.getVariables()) {
      if ((v instanceof Structure))
        return (Structure) v;
    }
    return null;
  }

static public Structure findNestedStructure ( Structure s ) { for ( Variable v : s . getVariables ( ) ) { if ( ( v instanceof Structure ) ) return ( Structure ) v ; } return null ; }

Find first nested structure
@param s in this structure
@return first nested structure or null


static public boolean hasNetcdf3RecordStructure(NetcdfDataset ds) {
    Variable v = ds.findVariable("record");
    return (v != null) && (v.getDataType() == DataType.STRUCTURE);
  }

static public boolean hasNetcdf3RecordStructure ( NetcdfDataset ds ) { Variable v = ds . findVariable ( "record" ) ; return ( v != null ) && ( v . getDataType ( ) == DataType . STRUCTURE ) ; }

Does this dataset have a record structure? netcdf-3 specific
@param ds in this dataset
@return true if record structure exists

Does this dataset have a record structure? netcdf - 3 specific


static public String getLiteral(NetcdfDataset ds, String key, Formatter errlog) {
    if (key.startsWith(":")) {
      String val = ds.findAttValueIgnoreCase(null, key.substring(1), null);
      if ((val == null) && (errlog != null))
        errlog.format(" Cant find global attribute %s%n", key);
      return val;
    }

    return key;
  }

static
public
String
getLiteral
(
NetcdfDataset
ds
,
String
key
,
Formatter
errlog
)
{
if
(
key
.
startsWith
(
":"
)
)
{
String
val
=
ds
.
findAttValueIgnoreCase
(
,
key
.
substring
(
1
)
,
)
;
if
(
(
val
==
)
&&
(
errlog
!=
)
)
errlog
.
format
(
" Cant find global attribute %s%n"
,
key
)
;
return
val
;
}
return
key
;
}

Translate key to value

@param ds     search in this dataset
@param key    if starts with ":", search for global attribute
@param errlog error messages here
@return return global attribute value or the key itself


static public FeatureType getFeatureType(NetcdfDataset ds, String key, Formatter errlog) {
    FeatureType ft = null;
    String fts = getLiteral(ds, key, errlog);
    if (fts != null) {
      ft = FeatureType.valueOf(fts.toUpperCase());
      if ((ft == null) && (errlog != null))
        errlog.format(" Cant find Feature type %s from %s%n", fts, key);
    }
    return ft;
  }

static
public
FeatureType
getFeatureType
(
NetcdfDataset
ds
,
String
key
,
Formatter
errlog
)
{
FeatureType
ft
=
;
String
fts
=
getLiteral
(
ds
,
key
,
errlog
)
;
if
(
fts
!=
)
{
ft
=
FeatureType
.
valueOf
(
fts
.
toUpperCase
(
)
)
;
if
(
(
ft
==
)
&&
(
errlog
!=
)
)
errlog
.
format
(
" Cant find Feature type %s from %s%n"
,
fts
,
key
)
;
}
return
ft
;
}

Turn the key into a String and return the corresponding featureType, if any.

@param ds     look in this datset
@param key    if starts with ":", replace with value of global attribute
@param errlog error messages here
@return featureType, or null

Turn the key into a String and return the corresponding featureType if any .


static public String getVariableName(NetcdfDataset ds, String key, Formatter errlog) {
    Variable v = null;
    String vs = getLiteral(ds, key, errlog);
    if (vs != null) {
      v = ds.findVariable(vs);
      if ((v == null) && (errlog != null))
        errlog.format(" Cant find Variable %s from %s%n", vs, key);
    }
    return v == null ? null : v.getShortName();
  }

static
public
String
getVariableName
(
NetcdfDataset
ds
,
String
key
,
Formatter
errlog
)
{
Variable
v
=
;
String
vs
=
getLiteral
(
ds
,
key
,
errlog
)
;
if
(
vs
!=
)
{
v
=
ds
.
findVariable
(
vs
)
;
if
(
(
v
==
)
&&
(
errlog
!=
)
)
errlog
.
format
(
" Cant find Variable %s from %s%n"
,
vs
,
key
)
;
}
return
v
==
:
v
.
getShortName
(
)
;
}

Find the variable pointed to by key

@param ds     in this dataset
@param key    may be variable name or ":gatt" where gatt is local attribute whose value is the variable name
@param errlog error messages here
@return name of variable or null if not exist


public double getCoordValue(int j, int i) {
    if (coords == null) doRead();
    return coords.get(j, i);
  }

public double getCoordValue ( int j , int i ) { if ( coords == null ) doRead ( ) ; return coords . get ( j , i ) ; }

Get the coordinate value at the i, j index.

@param i index 0 (fastest varying, right-most)
@param j index 1
@return midpoint.get(j, i).

Get the coordinate value at the i j index .


static private double connectLon(double connect, double val) {
    if (Double.isNaN(connect)) return val;
    if (Double.isNaN(val)) return val;

    double diff = val - connect;
    if (Math.abs(diff) < MAX_JUMP) return val; // common case fast
    // we have to add or subtract 360
    double result = diff > 0 ? val - 360 : val + 360;
    double diff2 = connect - result;
    if ((Math.abs(diff2)) < Math.abs(diff))
      val = result;
    return val;
  }

static
private
double
connectLon
(
double
connect
,
double
val
)
{
if
(
Double
.
isNaN
(
connect
)
)
return
val
;
if
(
Double
.
isNaN
(
val
)
)
return
val
;
double
diff
=
val
connect
;
if
(
Math
.
abs
(
diff
)
<
MAX_JUMP
)
return
val
;
// common case fast
// we have to add or subtract 360
double
result
=
diff
>
0
val
360
:
val
+
360
;
double
diff2
=
connect
result
;
if
(
(
Math
.
abs
(
diff2
)
)
<
Math
.
abs
(
diff
)
)
val
=
result
;
return
val
;
}


public double[] getCoordValues() {
    if (coords == null) doRead();
    if (!isNumeric())
      throw new UnsupportedOperationException("CoordinateAxis2D.getCoordValues() on non-numeric");
    return (double[]) coords.get1DJavaArray(DataType.DOUBLE);
  }

Get the coordinate values as a 1D double array, in canonical order.

@return coordinate values
@throws UnsupportedOperationException if !isNumeric()

Get the coordinate values as a 1D double array in canonical order .


public CoordinateAxis2D section(Range r1, Range r2) throws InvalidRangeException {
    List<Range> section = new ArrayList<>();
    section.add(r1);
    section.add(r2);
    return (CoordinateAxis2D) section(section);
  }

public CoordinateAxis2D section ( Range r1 , Range r2 ) throws InvalidRangeException { List < Range > section = new ArrayList <> ( ) ; section . add ( r1 ) ; section . add ( r2 ) ; return ( CoordinateAxis2D ) section ( section ) ; }

Create a new CoordinateAxis2D as a section of this CoordinateAxis2D.

@param r1 the section on the first index
@param r2 the section on the second index
@return a section of this CoordinateAxis2D
@throws InvalidRangeException if specified Ranges are invalid

Create a new CoordinateAxis2D as a section of this CoordinateAxis2D .


private int findClosest(ArrayDouble.D2 boundsForRun , double target) {
    double minDiff =  Double.MAX_VALUE;
    int idxFound = -1;
    int n = boundsForRun.getShape()[0];
    for (int i = 0; i < n; i++) {
      double midpoint = (boundsForRun.get(i,0) + boundsForRun.get(i,1))/2.0;
      double diff =  Math.abs(midpoint - target);
      if (diff < minDiff) {
        minDiff = diff;
        idxFound = i;
      }
    }
    return idxFound;
  }

private int findClosest ( ArrayDouble . D2 boundsForRun , double target ) { double minDiff = Double . MAX_VALUE ; int idxFound = - 1 ; int n = boundsForRun . getShape ( ) [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { double midpoint = ( boundsForRun . get ( i , 0 ) + boundsForRun . get ( i , 1 ) ) / 2.0 ; double diff = Math . abs ( midpoint - target ) ; if ( diff < minDiff ) { minDiff = diff ; idxFound = i ; } } return idxFound ; }


@Deprecated
    public String getName()
    {
        switch (sort) {
        case ATTRIBUTE:
        case DIMENSION:
        case ENUMERATION:
            // for these cases, getName is getShortName
            return getShortName();

        case VARIABLE: // Atomic
        case SEQUENCE:
        case STRUCTURE:
        case GROUP:
            // for these cases, getName is getFullName
            return getFullName();
        default:
            break;
        }
        return getShortName(); // default
    }

getName is deprecated because, as the code below shows,
it has no consistent meaning. Sometimes it returns
the short name, sometimes it returns the full name.

@deprecated Replaced by {@link #getShortName()} and {@link #getFullName()}

getName is deprecated because as the code below shows it has no consistent meaning . Sometimes it returns the short name sometimes it returns the full name .


public void addAction( String menuName, Action act) {
    act.putValue( Action.NAME, menuName);
    super.add(act);
  }

public void addAction ( String menuName , Action act ) { act . putValue ( Action . NAME , menuName ) ; super . add ( act ) ; }

Add an action to the popup menu.
Note that the menuName is made the NAME value of the action.
@param menuName name of the action on the menu.
@param act the Action.

Add an action to the popup menu . Note that the menuName is made the NAME value of the action .


public Match match( String path) {
    SortedMap<String, Match> tail = treeMap.tailMap( path);
    if (tail.isEmpty()) return null;
    String after = tail.firstKey();
    //System.out.println("  "+path+"; after="+afterPath);
    if (path.startsWith( after)) // common case
      return treeMap.get( after);

    // have to check more, until no common starting chars
    for (String key : tail.keySet()) {
      if (path.startsWith(key))
        return treeMap.get(key);
      // terminate when there's no match at all.
      if (StringUtil2.match(path, key) == 0)
        break;
    }

    return null;
  }

Find the longest match.
@param path find object with longest match where path.startsWith( key)
@return the value whose key is the longest that matches path, or null if none


public static void main(String[] args) {
    ProjectionManager d = new ProjectionManager(null, null);
    d.setVisible();
  }

public static void main ( String [ ] args ) { ProjectionManager d = new ProjectionManager ( null , null ) ; d . setVisible ( ) ; }


public int indexOf(byte[] data, int start, int max) {
    int j = 0;
    if (data.length == 0) return -1;
    if (start + max > data.length)
      System.out.println("HEY KMPMatch");

    for (int i = start; i < start + max; i++) {
      while (j > 0 && match[j] != data[i])
        j = failure[j - 1];

      if (match[j] == data[i])
        j++;

      if (j == match.length)
        return i - match.length + 1;

    }
    return -1;
  }

public
int
indexOf
(
byte
[
]
data
,
int
start
,
int
max
)
{
int
j
=
0
;
if
(
data
.
length
==
0
)
return
1
;
if
(
start
+
max
>
data
.
length
)
System
.
out
.
println
(
"HEY KMPMatch"
)
;
for
(
int
i
=
start
;
i
<
start
+
max
;
i
++
)
{
while
(
j
>
0
&&
match
[
j
]
!=
data
[
i
]
)
j
=
failure
[
j
1
]
;
if
(
match
[
j
]
==
data
[
i
]
)
j
++
;
if
(
j
==
match
.
length
)
return
i
match
.
length
+
1
;
}
return
1
;
}

Finds the first occurrence of match in data.
@param data search in this byte block
@param start start at data[start]
@param max end at data[start+max]
@return index into data[] of first match, else -1 if not found.

Finds the first occurrence of match in data .


public static synchronized void add( URL url, SourcePicture sp ) {
		Tools.log("PictureCache.add: " + url.toString() );
		if ( sp.getSourceBufferedImage() == null ) {
			Tools.log ("PictureCache.add: invoked with a null picture! Not cached!");
			return;
		}

		if ( ( maxCache < 1 ) ) {
			Tools.log("PictureCache.add: cache is diabled. Not adding picture.");
			return;
		}

		if ( isInCache( url ) ) {
			Tools.log( "Picture " + url.toString() + " is already in the cache. Not adding again.");
			return;
		}

		if ( pictureCache.size() >= maxCache )
			removeLeastPopular();

		if ( pictureCache.size() < maxCache )
			pictureCache.put( url.toString(), sp );

		//reportCache();
	}

store an image in the cache
@param url	The URL of the picture
@param sp	The picture to be stored


public static synchronized void reportCache() {
		Tools.log("   PictureCache.reportCache: cache contains: "
			+ Integer.toString( pictureCache.size() )
			+ " max: "
			+ Integer.toString( maxCache ) );
		//Tools.freeMem();
		Enumeration e = pictureCache.keys();
		while ( e.hasMoreElements() ) {
			Tools.log("   Cache contains: " + ((String) e.nextElement()) );
		}
		Tools.log("  End of cache contents");
	}


public static void stopBackgroundLoading() {
		Enumeration e = cacheLoadsInProgress.elements();
		while ( e.hasMoreElements() ) {
			((SourcePicture) e.nextElement()).stopLoading();
		}
	}

public static void stopBackgroundLoading ( ) { Enumeration e = cacheLoadsInProgress . elements ( ) ; while ( e . hasMoreElements ( ) ) { ( ( SourcePicture ) e . nextElement ( ) ) . stopLoading ( ) ; } }


public static boolean stopBackgroundLoadingExcept( URL exemptionURL ) {
		SourcePicture sp;
		String exemptionURLString = exemptionURL.toString();
		Enumeration e = cacheLoadsInProgress.elements();
		boolean inProgress = false;
		while ( e.hasMoreElements() ) {
			sp = ((SourcePicture) e.nextElement());
			if ( ! sp.getUrlString().equals( exemptionURLString ) )
				sp.stopLoading();
			else {
				Tools.log( "PictureCache.stopBackgroundLoading: picture was already loading");
				inProgress = true;
			}
		}
		return inProgress;
	}

method to stop all background loading except the indicated file. Returns whether the
image is already being loaded. True = loading in progress, False = not in progress.

method to stop all background loading except the indicated file . Returns whether the image is already being loaded . True = loading in progress False = not in progress .


static public HTTPMethod Get(HTTPSession session, String legalurl) throws HTTPException
    {
        return makemethod(HTTPSession.Methods.Get, session, legalurl);
    }

static public HTTPMethod Get ( HTTPSession session , String legalurl ) throws HTTPException { return makemethod ( HTTPSession . Methods . Get , session , legalurl ) ; }

Static factory methods for creating HTTPMethod instances


static protected HTTPMethod makemethod(HTTPSession.Methods m, HTTPSession session, String url)
            throws HTTPException
    {
        HTTPMethod meth = null;
        if(MOCKMETHODCLASS == null) { // do the normal case
            meth = new HTTPMethod(m, session, url);
        } else {//(MOCKMETHODCLASS != null)
            java.lang.Class methodcl = MOCKMETHODCLASS;
            Constructor<HTTPMethod> cons = null;
            try {
                cons = methodcl.getConstructor(HTTPSession.Methods.class, HTTPSession.class, String.class);
            } catch (Exception e) {
                throw new HTTPException("HTTPFactory: no proper HTTPMethod constructor available", e);
            }
            try {
                meth = cons.newInstance(m, session, url);
            } catch (Exception e) {
                throw new HTTPException("HTTPFactory: HTTPMethod constructor failed", e);
            }
        }
        return meth;
    }

Common method creation code so we can isolate mocking

@param session
@return
@throws HTTPException


public Object
    nextFloat(DapType basetype)
            throws DapException
    {
        TypeSort atomtype = basetype.getTypeSort();
        switch (atomtype) {
        case Float32:
            return new float[]{random.nextFloat()};
        case Float64:
            return new double[]{random.nextDouble()};
        default:
            break;
        }
        throw new DapException("Unexpected type: " + basetype);
    }

public
Object
nextFloat
(
DapType
basetype
)
throws
DapException
{
TypeSort
atomtype
=
basetype
.
getTypeSort
(
)
;
switch
(
atomtype
)
{
case
Float32
:
return
new
float
[
]
{
random
.
nextFloat
(
)
}
;
case
Float64
:
return
new
double
[
]
{
random
.
nextDouble
(
)
}
;
default
:
break
;
}
throw
new
DapException
(
"Unexpected type: "
+
basetype
)
;
}


public int
    nextCount(int max)
            throws DapException
    {
        int min = 1;
        if(max < min || min < 1)
            throw new DapException("bad range");
        int range = (max + 1) - min;  // min..max+1 -> 0..(max+1)-min
        int n = random.nextInt(range);   //  0..(max+1)-min
        n = n + min;   // min..(max+1)
        if(DEBUG)
            System.err.println("RandomValue.nextCount: " + n);
        return n;
    }

public
int
nextCount
(
int
max
)
throws
DapException
{
int
min
=
1
;
if
(
max
<
min
||
min
<
1
)
throw
new
DapException
(
"bad range"
)
;
int
range
=
(
max
+
1
)
min
;
// min..max+1 -> 0..(max+1)-min
int
n
=
random
.
nextInt
(
range
)
;
//  0..(max+1)-min
n
=
n
+
min
;
// min..(max+1)
if
(
DEBUG
)
System
.
err
.
println
(
"RandomValue.nextCount: "
+
n
)
;
return
n
;
}

Return an integer in range 1..max inclusive.

@param max
@return random integer in range
@throws DapException

Return an integer in range 1 .. max inclusive .


@Override
    protected Array
    readData(Variable cdmvar, Section section)
            throws IOException, InvalidRangeException
    {
        // The section is applied wrt to the DataDMR, so it
        // takes into account any constraint used in forming the dataDMR.
        // We use the Section to produce a view of the underlying variable array.

        assert this.dsp != null;
        Array result = arraymap.get(cdmvar);
        if(result == null)
            throw new IOException("No data for variable: " + cdmvar.getFullName());
        if(section != null) {
            if(cdmvar.getRank() != section.getRank())
                throw new InvalidRangeException(String.format("Section rank != %s rank", cdmvar.getFullName()));
            List<Range> ranges = section.getRanges();
            // Case out the possibilities
            if(CDMUtil.hasVLEN(ranges)) {
                ranges = ranges.subList(0, ranges.size() - 1);// may produce empty list
            }
            if(ranges.size() > 0 && !CDMUtil.isWhole(ranges, cdmvar))
                result = result.sectionNoReduce(ranges);
        }
        return result;
    }

Primary read entry point.
This is the primary implementor of Variable.read.

@param cdmvar  A top-level variable
@param section the section of databuffer to read.
There must be a Range for each Dimension in the variable,
in order. Note: no nulls allowed.
@return An Array object for accessing the databuffer
@throws IOException           if read error
@throws InvalidRangeException if invalid section

Primary read entry point . This is the primary implementor of Variable . read .


private static FileSystemProvider getProvider(URI uri) throws IOException {
        if(fsproviders.containsKey(uri.getScheme())) {
            return fsproviders.get(uri.getScheme());
        } else {
            FileSystem fs;
            try {
                fs = FileSystems.newFileSystem(uri,
                        new HashMap<String, Object>(),
                        Thread.currentThread().getContextClassLoader());
            } catch (FileSystemAlreadyExistsException e) {
                fs = FileSystems.getFileSystem(uri);
            }
            fsproviders.put(uri.getScheme(), fs.provider());
            return fs.provider();
        }
    }

private static FileSystemProvider getProvider ( URI uri ) throws IOException { if ( fsproviders . containsKey ( uri . getScheme ( ) ) ) { return fsproviders . get ( uri . getScheme ( ) ) ; } else { FileSystem fs ; try { fs = FileSystems . newFileSystem ( uri , new HashMap < String , Object > ( ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } catch ( FileSystemAlreadyExistsException e ) { fs = FileSystems . getFileSystem ( uri ) ; } fsproviders . put ( uri . getScheme ( ) , fs . provider ( ) ) ; return fs . provider ( ) ; } }

filesystem can t be re - created either .


private static void readStationTable() throws IOException {
    stationTableHash = new HashMap<String,Station>();

    ClassLoader cl = Level2VolumeScan.class.getClassLoader();
    InputStream is = cl.getResourceAsStream("resources/nj22/tables/nexrad.tbl");

    List<TableParser.Record> recs = TableParser.readTable(is, "3,15,46, 54,60d,67d,73d", 50000);
    for (TableParser.Record record : recs) {
      Station s = new Station();
      s.id = "K" + record.get(0);
      s.name = record.get(2) + " " + record.get(3);
      s.lat = (Double) record.get(4) * .01;
      s.lon = (Double) record.get(5) * .01;
      s.elev = (Double) record.get(6);

      stationTableHash.put(s.id, s);
      if (showStations) System.out.println(" station= " + s);
    }
  }

private
static
void
readStationTable
(
)
throws
IOException
{
stationTableHash
=
new
HashMap
<
String
,
Station
>
(
)
;
ClassLoader
cl
=
Level2VolumeScan
.
class
.
getClassLoader
(
)
;
InputStream
is
=
cl
.
getResourceAsStream
(
"resources/nj22/tables/nexrad.tbl"
)
;
List
<
TableParser
.
Record
>
recs
=
TableParser
.
readTable
(
is
,
"3,15,46, 54,60d,67d,73d"
,
50000
)
;
for
(
TableParser
.
Record
record
:
recs
)
{
Station
s
=
new
Station
(
)
;
s
.
id
=
"K"
+
record
.
get
(
0
)
;
s
.
name
=
record
.
get
(
2
)
+
" "
+
record
.
get
(
3
)
;
s
.
lat
=
(
Double
)
record
.
get
(
4
)
*
.01
;
s
.
lon
=
(
Double
)
record
.
get
(
5
)
*
.01
;
s
.
elev
=
(
Double
)
record
.
get
(
6
)
;
stationTableHash
.
put
(
s
.
id
,
s
)
;
if
(
showStations
)
System
.
out
.
println
(
" station= "
+
s
)
;
}
}

this is the old Gempak table, not as precise

this is the old Gempak table not as precise


@Override
  public int getIndex(T gr) {
    Integer result =  valMap.get( extract(gr));
    return (result == null) ? 0 : result;
  }

@ Override public int getIndex ( T gr ) { Integer result = valMap . get ( extract ( gr ) ) ; return ( result == null ) ? 0 : result ; }

Used by CoordinateND.makeSparseArray; not used by CoordinateTime2D

Used by CoordinateND . makeSparseArray ; not used by CoordinateTime2D


protected void removeDataVariable( String varName) {
    Iterator iter = dataVariables.iterator();
    while (iter.hasNext()) {
      VariableSimpleIF v = (VariableSimpleIF) iter.next();
      if (v.getShortName().equals( varName) )
        iter.remove();
    }
  }

protected void removeDataVariable ( String varName ) { Iterator iter = dataVariables . iterator ( ) ; while ( iter . hasNext ( ) ) { VariableSimpleIF v = ( VariableSimpleIF ) iter . next ( ) ; if ( v . getShortName ( ) . equals ( varName ) ) iter . remove ( ) ; } }


private String cloud_hgt2_meters(String height) {

        if (height.equals("999")) {
            return "30000";
        } else {
//		$meters = 30 * $height ;
            return Integer.toString(30 * Integer.parseInt(height));
        }
    }

private
String
cloud_hgt2_meters
(
String
height
)
{
if
(
height
.
equals
(
"999"
)
)
{
return
"30000"
;
}
else
{
//		$meters = 30 * $height ;
return
Integer
.
toString
(
30
*
Integer
.
parseInt
(
height
)
)
;
}
}


@Override
    public Array reallyRead(Variable mainv, Section section, CancelTask cancelTask) throws IOException, InvalidRangeException {
      FmrcInvLite.Gridset.Grid gridLite = (FmrcInvLite.Gridset.Grid) mainv.getSPobject();

      // read the original type - if its been promoted to a new type, the conversion happens after this read
      DataType dtype = (mainv instanceof VariableDS) ? ((VariableDS) mainv).getOriginalDataType() : mainv.getDataType();

      Array allData = Array.factory(dtype, section.getShape());
      int destPos = 0;

      // assumes the first two dimensions are runtime and time: LOOK: ensemble ??
      List<Range> ranges = section.getRanges();
      Range runRange = ranges.get(0);
      Range timeRange = ranges.get(1);
      List<Range> innerSection = ranges.subList(2, ranges.size());

      // keep track of open file - must be local variable for thread safety
      HashMap<String, NetcdfDataset> openFilesRead = new HashMap<>();
      try {

        // iterate over the desired runs
        for (int runIdx : runRange) {
          //Date runDate = vstate.runTimes.get(runIdx);

          // iterate over the desired forecast times
          for (int timeIdx : timeRange) {
            Array result = null;

            // find the inventory for this grid, runtime, and hour
            TimeInventory.Instance timeInv = gridLite.getInstance(runIdx, timeIdx);
            if (timeInv != null) {
              if (debugRead) System.out.printf("HIT %d %d ", runIdx, timeIdx);
              result = read(timeInv, gridLite.name, innerSection, openFilesRead); // may return null
              result = MAMath.convert(result, dtype); // just in case it need to be converted
            }

            // missing data
            if (result == null) {
              int[] shape = new Section(innerSection).getShape();
              result = ((VariableDS) mainv).getMissingDataArray(shape); // fill with missing values
              if (debugRead) System.out.printf("MISS %d %d ", runIdx, timeIdx);
            }

            if (debugRead)
              System.out.printf("%d %d reallyRead %s %d bytes start at %d total size is %d%n",
                      runIdx, timeIdx, mainv.getFullName(), result.getSize(), destPos, allData.getSize());

            Array.arraycopy(result, 0, allData, destPos, (int) result.getSize());
            destPos += result.getSize();
          }
        }
        return allData;

      } finally {
        // close any files used during this operation
        closeAll(openFilesRead);
      }
    }


public void setNumColors(int n) {
    if (n != ncolors) {
      colors = new Color[n];
      int prevn = Math.min(ncolors, n);
      System.arraycopy(useColors, 0, colors, 0, prevn);
      for (int i = ncolors; i < n; i++)
        colors[i] = Color.white;

      useColors = colors;
      ncolors = n;
      edge = new double[ ncolors];
      hist = new int[ ncolors + 1];
    }
  }

public void setNumColors ( int n ) { if ( n != ncolors ) { colors = new Color [ n ] ; int prevn = Math . min ( ncolors , n ) ; System . arraycopy ( useColors , 0 , colors , 0 , prevn ) ; for ( int i = ncolors ; i < n ; i ++ ) colors [ i ] = Color . white ; useColors = colors ; ncolors = n ; edge = new double [ ncolors ] ; hist = new int [ ncolors + 1 ] ; } }

Set the number of colors in the colorscale.

Set the number of colors in the colorscale .


private AffineTransform calcTransform(Rectangle2D screen, Bounds world) {
    // scale to limiting dimension
    double xs = screen.getWidth() / (world.getRight() - world.getLeft());
    double ys = screen.getHeight() / (world.getLower() - world.getUpper());

    AffineTransform cat = new AffineTransform();
    cat.setToScale(xs, ys);
    cat.translate(-world.getLeft(), -world.getUpper());

    if (debugTransform) {
      System.out.println("TPanel calcTransform = ");
      System.out.println("  screen = " + screen);
      System.out.println("  world = " + world);

      System.out.println("  transform = " + cat.getScaleX() + " " + cat.getShearX() + " " + cat.getTranslateX());
      System.out.println("              " + cat.getShearY() + " " + cat.getScaleY() + " " + cat.getTranslateY());

      Point2D src = new Point2D.Double(world.getLeft(), world.getUpper());
      Point2D dst = new Point2D.Double(0.0, 0.0);

      System.out.println("  upper left pt = " + src);
      System.out.println("  transform = " + cat.transform(src, dst));

      src = new Point2D.Double(world.getRight(), world.getLower());
      System.out.println("  lower right pt = " + src);
      System.out.println("  transform = " + cat.transform(src, dst));
    }
    return cat;
  }

private
AffineTransform
calcTransform
(
Rectangle2D
screen
,
Bounds
world
)
{
// scale to limiting dimension
double
xs
=
screen
.
getWidth
(
)
/
(
world
.
getRight
(
)
world
.
getLeft
(
)
)
;
double
ys
=
screen
.
getHeight
(
)
/
(
world
.
getLower
(
)
world
.
getUpper
(
)
)
;
AffineTransform
cat
=
new
AffineTransform
(
)
;
cat
.
setToScale
(
xs
,
ys
)
;
cat
.
translate
(
world
.
getLeft
(
)
,
world
.
getUpper
(
)
)
;
if
(
debugTransform
)
{
System
.
out
.
println
(
"TPanel calcTransform = "
)
;
System
.
out
.
println
(
"  screen = "
+
screen
)
;
System
.
out
.
println
(
"  world = "
+
world
)
;
System
.
out
.
println
(
"  transform = "
+
cat
.
getScaleX
(
)
+
" "
+
cat
.
getShearX
(
)
+
" "
+
cat
.
getTranslateX
(
)
)
;
System
.
out
.
println
(
"              "
+
cat
.
getShearY
(
)
+
" "
+
cat
.
getScaleY
(
)
+
" "
+
cat
.
getTranslateY
(
)
)
;
Point2D
src
=
new
Point2D
.
Double
(
world
.
getLeft
(
)
,
world
.
getUpper
(
)
)
;
Point2D
dst
=
new
Point2D
.
Double
(
0.0
,
0.0
)
;
System
.
out
.
println
(
"  upper left pt = "
+
src
)
;
System
.
out
.
println
(
"  transform = "
+
cat
.
transform
(
src
,
dst
)
)
;
src
=
new
Point2D
.
Double
(
world
.
getRight
(
)
,
world
.
getLower
(
)
)
;
System
.
out
.
println
(
"  lower right pt = "
+
src
)
;
System
.
out
.
println
(
"  transform = "
+
cat
.
transform
(
src
,
dst
)
)
;
}
return
cat
;
}

map world coords to screen coords.

@param world  world coordinate rectangle
@param screen screen coordinate rectangle
@return AffineTransform for converting world to screen.


static AuthScope
    uriToAuthScope(URI uri)
    {
        assert (uri != null);
        return new AuthScope(uri.getHost(), uri.getPort(), AuthScope.ANY_REALM, uri.getScheme());
    }

static AuthScope uriToAuthScope ( URI uri ) { assert ( uri != null ) ; return new AuthScope ( uri . getHost ( ) , uri . getPort ( ) , AuthScope . ANY_REALM , uri . getScheme ( ) ) ; }

Create an AuthScope from a URI; remove any principal

@param uri to convert
@returns an AuthScope instance

Create an AuthScope from a URI ; remove any principal


public void finish() {
    if (gcs.size() == 1)
      return;
    if (gcs.size() == 2) {
      List hcs = getHorizCoordSys();
      GridDefRecord.compare((GridDefRecord) hcs.get(0), (GridDefRecord) hcs.get(1));
    }
  }

public void finish ( ) { if ( gcs . size ( ) == 1 ) return ; if ( gcs . size ( ) == 2 ) { List hcs = getHorizCoordSys ( ) ; GridDefRecord . compare ( ( GridDefRecord ) hcs . get ( 0 ) , ( GridDefRecord ) hcs . get ( 1 ) ) ; } }


public boolean isReciprocalOf(final Factor that) {
		return getBase().equals(that.getBase())
				&& getExponent() == -that.getExponent();
	}

public boolean isReciprocalOf ( final Factor that ) { return getBase ( ) . equals ( that . getBase ( ) ) && getExponent ( ) == - that . getExponent ( ) ; }

Indicates if this Factor is the reciprocal of another Factor.

@param that
The other factor.
@return true if and only if this Factor is the reciprocal of
that.

Indicates if this Factor is the reciprocal of another Factor .


public InvCatalog getDirCatalog( File directory, String filterPattern, boolean sortInIncreasingOrder, boolean addDatasetSize )
  {
    return( this.getDirCatalog( directory, filterPattern, sortInIncreasingOrder, null, addDatasetSize, null, null, null) );
  }

public InvCatalog getDirCatalog ( File directory , String filterPattern , boolean sortInIncreasingOrder , boolean addDatasetSize ) { return ( this . getDirCatalog ( directory , filterPattern , sortInIncreasingOrder , null , addDatasetSize , null , null , null ) ) ; }

Return a catalog for the given directory.

@param directory - the directory to represent as a catalog.
@param filterPattern
@param sortInIncreasingOrder
@return An InvCatalog that represents the given directory of datasets.

@throws NullPointerException if the given directory is null.
@throws IllegalArgumentException if the given directory is not actually a directory or if it is not under the service base URL directory.

Return a catalog for the given directory .


public int findIdx(int want) {
    if (isConstant) return (want == start)  ? 0 : -1;
    if (isSequential) return want - start;
    if (isSorted) {
      return Arrays.binarySearch(raw, want);
    }
    // linear search
    for (int i=0; i<raw.length; i++)
      if (raw[i] == want) return i;
    return -1;
  }

public
int
findIdx
(
int
want
)
{
if
(
isConstant
)
return
(
want
==
start
)
0
:
1
;
if
(
isSequential
)
return
want
start
;
if
(
isSorted
)
{
return
Arrays
.
binarySearch
(
raw
,
want
)
;
}
// linear search
for
(
int
i
=
0
;
i
<
raw
.
length
;
i
++
)
if
(
raw
[
i
]
==
want
)
return
i
;
return
1
;
}

Find which index holds the value want
@param want  value wanted
@return < 0 if not found, else the index. If duplicates, then return any match


private Object readMetadataContentFromURL( InvDataset dataset, String urlString)
    throws java.net.MalformedURLException, java.io.IOException
  {
    // @todo This isn't used anywhere. Remove?
    Document doc;
    try
    {
      SAXBuilder builder = new SAXBuilder( true);
      doc = builder.build( urlString);
    } catch ( JDOMException e)
    {
      log.error( "CatGenConfigMetadataFactory parsing error= \n" + e.getMessage());
      throw new java.io.IOException( "CatGenConfigMetadataFactory parsing error= " + e.getMessage());
    }

    if (showParsedXML)
    {
      XMLOutputter xmlOut = new XMLOutputter( Format.getPrettyFormat() );
      System.out.println ("*** catalog/showParsedXML = \n"+xmlOut.outputString(doc)+"\n*******");
    }

    return( readMetadataContentJdom( dataset, doc.getRootElement()));
  }

Create an InvMetadata content object from an XML document at a named URL.
The content object is an ArrayList of CatalogGenConfig instances.

@param dataset - the containing dataset
@param urlString - the URL where the XML doc is located.
@return
@throws java.net.MalformedURLException if given URL is malformed.
@throws java.io.IOException if problems reading from given URL

Create an InvMetadata content object from an XML document at a named URL . The content object is an ArrayList of CatalogGenConfig instances .


public Object readMetadataContent( InvDataset dataset, org.jdom2.Element mdataElement )
  {
    log.debug( "readMetadataContent(): ." );

    // convert to JDOM element
    //Element mdataElement = builder.build( mdataDomElement );
    return readMetadataContentJdom( dataset, mdataElement );
  }

Create an InvMetadata content object from an org.w3c.dom.Element.
The content object is an ArrayList of CatalogGenConfig instances.

@param dataset - the containing dataset
@param mdataElement - the metadata element as an org.w3c.dom.Element
@return an object representing the metadata which is an ArrayList of CatalogGenConfig instances.

Create an InvMetadata content object from an org . w3c . dom . Element . The content object is an ArrayList of CatalogGenConfig instances .


public void addMetadataContent( org.jdom2.Element mdataJdomElement, Object contentObject )
  {
    // convert to JDOM element
    //Element mdataJdomElement = builder.build( mdataElement );

    ArrayList catGenConfigList = (ArrayList) contentObject;
    Iterator iter = catGenConfigList.iterator();
    while ( iter.hasNext())
    {
      CatalogGenConfig cgc = (CatalogGenConfig) iter.next();
      mdataJdomElement.addContent( createCatGenConfigElement( cgc));
    }
  }

Serialize the InvMetadata content object to a org.w3c.dom.Element

@param mdataJdomElement - add content to this org.w3c.dom.Element
@param contentObject - the content model

Serialize the InvMetadata content object to a org . w3c . dom . Element


public boolean validateMetadataContent( Object contentObject, StringBuilder out)
  {
    boolean ok = true;
    ArrayList catGenConfigList = (ArrayList) contentObject;
    Iterator iter = catGenConfigList.iterator();
    while ( iter.hasNext()) {
      CatalogGenConfig catGenConf = (CatalogGenConfig) iter.next();
      ok &= catGenConf.validate( out);
    }
    return ok;

  }

public boolean validateMetadataContent ( Object contentObject , StringBuilder out ) { boolean ok = true ; ArrayList catGenConfigList = ( ArrayList ) contentObject ; Iterator iter = catGenConfigList . iterator ( ) ; while ( iter . hasNext ( ) ) { CatalogGenConfig catGenConf = ( CatalogGenConfig ) iter . next ( ) ; ok &= catGenConf . validate ( out ) ; } return ok ; }


private CatalogGenConfig readCatGenConfigElement(
    InvDataset parentDataset, Element catGenConfElement)
  {

    String type = catGenConfElement.getAttributeValue("type");

    CatalogGenConfig catGenConf = new CatalogGenConfig( parentDataset, type);

    // get any datasetSource elements
    java.util.List list = catGenConfElement.getChildren( "datasetSource", catGenConfElement.getNamespace() );
    for (int i=0; i< list.size(); i++)
    {
      Element dsSourceElement = (Element) list.get(i);

      catGenConf.setDatasetSource( readDatasetSourceElement( parentDataset,
                                                             dsSourceElement));
    }

    // @todo Start only allowing datasetSource elements in catalogGenConfig elements.
//    // get any datasetNamer elements
//    list = catGenConfElement.getChildren( "datasetNamer", catGenConfElement.getNamespace() );
//    for (int i=0; i< list.size(); i++)
//    {
//      Element dsNamerElement = (Element) list.get(i);
//
//      catGenConf.addDatasetNamer( readDatasetNamerElement( parentDataset,
//                                                           dsNamerElement));
//    }

    return( catGenConf);
  }

//    for (int i=0; i< list.size(); i++)

//                                                           dsNamerElement));

Return a CatalogGenConfig when given a 'catalogGenConfig' JDOM element.

Return a CatalogGenConfig when given a catalogGenConfig JDOM element .


private DatasetSource readDatasetSourceElement( InvDataset parentDataset,
                                                  Element dsSourceElement)
  {
    String name = dsSourceElement.getAttributeValue( "name");
    String type = dsSourceElement.getAttributeValue( "type");
    String structure = dsSourceElement.getAttributeValue( "structure");
    String accessPoint = dsSourceElement.getAttributeValue( "accessPoint");
    String createCatalogRefs = dsSourceElement.getAttributeValue( "createCatalogRefs");

    // get the resultService element
    Element resultServiceElement = dsSourceElement.getChild( "resultService", dsSourceElement.getNamespace() );
    ResultService resultService = readResultServiceElement( parentDataset,
                                                         resultServiceElement);

    DatasetSource dsSource = DatasetSource.newDatasetSource( name,
                                                    DatasetSourceType.getType( type),
                                                    DatasetSourceStructure.getStructure( structure),
                                                    accessPoint, resultService);
    if ( createCatalogRefs != null)
    {
      dsSource.setCreateCatalogRefs( Boolean.valueOf( createCatalogRefs).booleanValue());
    }

    // get any datasetNamer elements
    java.util.List list = dsSourceElement.getChildren( "datasetNamer", dsSourceElement.getNamespace() );
    for (int i=0; i< list.size(); i++)
    {
      Element dsNamerElement = (Element) list.get(i);

      dsSource.addDatasetNamer( readDatasetNamerElement( parentDataset,
                                                         dsNamerElement));
    }

    // get any datasetFilter elements
    list = dsSourceElement.getChildren( "datasetFilter", dsSourceElement.getNamespace() );
    for (int i=0; i< list.size(); i++)
    {
      Element dsFilterElement = (Element) list.get(i);

      dsSource.addDatasetFilter( readDatasetFilterElement( dsSource,
                                                           dsFilterElement));
    }

    return( dsSource);
  }

private
DatasetSource
readDatasetSourceElement
(
InvDataset
parentDataset
,
Element
dsSourceElement
)
{
String
name
=
dsSourceElement
.
getAttributeValue
(
"name"
)
;
String
type
=
dsSourceElement
.
getAttributeValue
(
"type"
)
;
String
structure
=
dsSourceElement
.
getAttributeValue
(
"structure"
)
;
String
accessPoint
=
dsSourceElement
.
getAttributeValue
(
"accessPoint"
)
;
String
createCatalogRefs
=
dsSourceElement
.
getAttributeValue
(
"createCatalogRefs"
)
;
// get the resultService element
Element
resultServiceElement
=
dsSourceElement
.
getChild
(
"resultService"
,
dsSourceElement
.
getNamespace
(
)
)
;
ResultService
resultService
=
readResultServiceElement
(
parentDataset
,
resultServiceElement
)
;
DatasetSource
dsSource
=
DatasetSource
.
newDatasetSource
(
name
,
DatasetSourceType
.
getType
(
type
)
,
DatasetSourceStructure
.
getStructure
(
structure
)
,
accessPoint
,
resultService
)
;
if
(
createCatalogRefs
!=
)
{
dsSource
.
setCreateCatalogRefs
(
Boolean
.
valueOf
(
createCatalogRefs
)
.
booleanValue
(
)
)
;
}
// get any datasetNamer elements
java
.
util
.
List
list
=
dsSourceElement
.
getChildren
(
"datasetNamer"
,
dsSourceElement
.
getNamespace
(
)
)
;
for
(
int
i
=
0
;
i
<
list
.
size
(
)
;
i
++
)
{
Element
dsNamerElement
=
(
Element
)
list
.
get
(
i
)
;
dsSource
.
addDatasetNamer
(
readDatasetNamerElement
(
parentDataset
,
dsNamerElement
)
)
;
}
// get any datasetFilter elements
list
=
dsSourceElement
.
getChildren
(
"datasetFilter"
,
dsSourceElement
.
getNamespace
(
)
)
;
for
(
int
i
=
0
;
i
<
list
.
size
(
)
;
i
++
)
{
Element
dsFilterElement
=
(
Element
)
list
.
get
(
i
)
;
dsSource
.
addDatasetFilter
(
readDatasetFilterElement
(
dsSource
,
dsFilterElement
)
)
;
}
return
(
dsSource
)
;
}

Return a DatasetSource when given a 'datasetSource' JDOM element.

Return a DatasetSource when given a datasetSource JDOM element .