Last modified: Mon, 04/03/2017 - 17:29
To make the system as flexible as possible you use a template to build the constraint expression that will applied to your DRDS request based on the user selections from the User Interface.
When a user selects a sub-region of the globe and a time range, the Dapper service uses a template to translate those selections into aconstraint expression on the Dapper OPeNDAP URL. (See the Veloicty User's Guidefor more information on the Velocity Template Language and syntax.) The use of this a template language means that these Dapper constraint expressions can beconstructed based on information available in the complete LAS request.
All dapper templates must be located in: $LAS_HOME/JavaSource/resources/dapper/templates/
The dapper.vm file in this directory shows how to build the constraint expression for server we're using in our example:
## Velocity info: http://velocity.apache.org/engine/devel/user-guide.html#about_this_guide
## Dapper docs: http://www.epic.noaa.gov/epic/software/dapper/dapperdocs/conventions/
## This sample url doesn't work in a browser, only via opendap library:
## url=http://las.pfeg.noaa.gov/dods/ndbc/all_noaa_time_series.cdp?location.LON,location.LAT,
## location.DEPTH,location.profile.TIME,location.profile.WSPD1,location.profile.BAR1
## &location.LON>=235.45001&location.LON<=235.47&location.LAT>=40.77&location.LAT<=40.789997
## &location.profile.TIME>=1072915199999&location.profile.TIME<=1072918800001
##
## Set the XYZT and data variable names. These are listed first on the OPeNDAP request URL.
#set($x=$dapperBackendRequest.getDatabaseProperty("longitude"))
#set($y=$dapperBackendRequest.getDatabaseProperty("latitude"))
#set($z=$dapperBackendRequest.getDatabaseProperty("depth"))
#set($t=$dapperBackendRequest.getDatabaseProperty("time"))
#set($v=$dapperBackendRequest.getVariablesAsString())
#set($pre="$x,$y,$z,$t,$v")
##
## Get the X range. There maybe 0 ranges if X is not constrained, or 1
## if the region lies on one side of the date line, or 2 if the request
## crosses the date line.
## xRange may have 0,1,2 values; the others are "" or a constraint
#set($xRange=$dapperBackendRequest.getAxisConstraintArrayList("x"))
## Set the Y, Z and T ranges
#set($yRange=$dapperBackendRequest.getAxisConstraint("y"))
#set($zRange=$dapperBackendRequest.getAxisConstraint("z"))
#set($tRange=$dapperBackendRequest.getAxisConstraint("t"))
#set($post="$yRange$zRange$tRange")
## Append the X ranges.
#if ($xRange.size() == 0)
$pre$post
#elseif ($xRange.size() == 1)
$pre$xRange.get(0)$post
#elseif ($xRange.size() == 2)
$pre$xRange.get(0)$post
$pre$xRange.get(1)$post
#end
N.B.
- ## 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.
- allother lines are (conditionally executed) build the actual constraintexpressions (after Velocity replaces the contents of the Velocityreferences)
Once processed the resulting expression might look something like this example:
location.LON,location.LAT,location.DEPTH,location.profile.TIME,ATMP&location.LON>=230.0&location.LON<=239.0&location.LAT>=32.43&location.LAT<=41.43&location.profile.TIME>=3.8016E11&location.profile.TIME<=4.090392E11