When a user selects a sub-region of the globe and a time range, the DRDS service uses a template to translate those selections into a constraint expression on the DRDS OPeNDAP URL. (See the Veloicty User's Guidefor more information on the Velocity templating language and syntax.) The use of this templating language means that these DRDS constraint expressions can beconstructed based on information available in the complete LAS request.
All drds templates must be located in: $LAS_HOME/JavaSource/resources/drds/templates/
The drds.vm file in this directory shows how to build the constraint expression for this server :
## armstrong/JavaSource/resources/drds/templates/drds.vm
##
## Default DRDS template.
## <database_access> properties defined in the dataset configuration file
## Extract the names of the database table/sequence and the for XYZT variables
#set($table=$las_backendrequest.getDatabaseProperty("db_table"))
#set($time=$las_backendrequest.getDatabaseProperty("time"))
#set($lat=$las_backendrequest.getDatabaseProperty("latitude"))
#set($lon=$las_backendrequest.getDatabaseProperty("longitude"))
#set($depth=$las_backendrequest.getDatabaseProperty("depth"))
## Extract the name(s) of the LAS variables that were selected
## on the LAS Variables page for this request
#set($var = $las_backendrequest.getVariablesAsString())
## Extract the each potential constraint on the data selection.
## Any one of these constraints could be blank
## Get the requested time range (only one allowed)
#set($time_range = $las_backendrequest.getAxisAsDRDSConstraint("t").get(0))
## Get the requested z range (only one allowed)
#set($depth_range = $las_backendrequest.getAxisAsDRDSConstraint("z").get(0))
## Get the x range. (A list with 0, 1 or 2 X constraints)
#set($x_range = $las_backendrequest.getAxisAsDRDSConstraint("x"))
## A constraint on the variable(s) selected (Could be empty)
#set($con = $las_backendrequest.getDRDSVariableConstraintString("$var"))
#if ( $x_range.size() == 0 )
#if ( $con == "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range
#elseif ( $con != "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$con
#elseif ( $con == "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range
#elseif ( $con != "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con
#end
#elseif ( $x_range.size() == 1 )
#if ( $con == "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$x_range.get(0)
#elseif ( $con != "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$con&$x_range.get(0)
#elseif ( $con == "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$x_range.get(0)
#elseif ( $con != "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con&$x_range.get(0)
#end
#else
#if ( $con == "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range$x_range.get(0)
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range$x_range.get(1)
#elseif ( $con != "" && $depth_range == "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$con&$x_range.get(0)
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$con&$x_range.get(1)
#elseif ( $con == "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$x_range.get(0)
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$x_range.get(1)
#elseif ( $con != "" && $depth_range != "" )
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con&$x_range.get(0)
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con&$x_range.get(1)
#end
#end
The most important items to note are
- ## begins a Velocity comment
- # begins a Velocity statement (See the Veloicty User's Guide)
- $ begins a Velocity reference
- $las_backendrequest is a Velocity reference whose methods are documented here.
- all other lines are (conditionally executed) the actual constraint expressions (after Velocity replaces the contents of the Velocity references)
The block sets the up that names of the XYZ and T variables and the data variables. The next block sets the values of the various potential contraints. These might be blank (if the user choose not to apply that particular constraint). Then the rest of the code sets up the list of variables to extract (always the XYZ and T variables and the data variables (the $table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var section)). The section following the "&" is the actual constraints on the data to be selected. For example, if two X ranges are needed to get the data from the edges of the domain, and a depth and time range restriction are applied and the actual value of the data variable has been constrainted, the very last to constraint expression will be the ones used:
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con&$x_range.get(0)
$table.$time,$table.$depth,$table.$lon,$table.$lat,$table.$var&$time_range&$depth_range&$con&$x_range.get(1)
Once processed, these might look like:
adcp98.yearday,adcp98.Z,adcp98.X,adcp98.Y,adcp98.EV&adcp98.yearday>=187.0&adcp98.yearday<=192.95833333333334&adcp98.Z>=22&adcp98.Z<=78&adcp98.EV<.8&adcp98.X>=180.0
adcp98.yearday,adcp98.Z,adcp98.X,adcp98.Y,adcp98.EV&adcp98.yearday>=187.0&adcp98.yearday<=192.95833333333334&adcp98.Z>=22&adcp98.Z<=78&adcp98.EV<.8&adcp98.X<=-106.0
Which would result in these two OPeNDAP URLs being accessed
http://nwioos.coas.oregonstate.edu:8080/dods/drds/1998%20Hake%20Survey%20ADCP.dods?adcp98.yearday,adcp98.Z,adcp98.X,adcp98.Y,adcp98.EV&adcp98.yearday>=187.0&adcp98.yearday<=192.95833333333334&adcp98.Z>=22&adcp98.Z<=78&adcp98.EV<.8&adcp98.X>=180.0
http://nwioos.coas.oregonstate.edu:8080/dods/drds/1998%20Hake%20Survey%20ADCP.dods?adcp98.yearday,adcp98.Z,adcp98.X,adcp98.Y,adcp98.EV&adcp98.yearday>=187.0&adcp98.yearday<=192.95833333333334&adcp98.Z>=22&adcp98.Z<=78&adcp98.EV<.8&adcp98.X<=-106.0
and the data returned from each would be appended together into a single netCDF file.