irisws-queryconstruction: Constructs a query function

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Constructs a query function

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
constructor(..., service = c("timeseries", "distaz", "traveltime",
  "flinnengdahl", "resp"), ws.version = c("1", "2"), query.field = "query?")

constructor2(...)

## Default S3 method:
constructor2(..., service = c("timeseries", "distaz",
  "tt.deg", "tt.km", "tt.llpairs", "resp", "flinnengdahl"),
  list.fields.only = FALSE, ws.version = "1")

params2queryparams(..., defaults, exclude.empty.options = TRUE,
  exclude.null.fields = TRUE)

Arguments

...

query parameters. For constructor these are comma-separated character strings ("a=1", "b=2" etc) For constructor2 these are comma-separated arguments (a=1, b=2 etc)

service

character; the type of web service to construct for.

ws.version

character; corresponds to the documentation version (See [1]).

query.field

character; the user should not need to change this (it only exists to give the function wider applicability).

list.fields.only

logical; return names of default arguments

defaults

list; the parameters to merge ... with

exclude.empty.options

logical; should the result not contain optional arguments which were not specified?

exclude.null.fields

logical; should NULL fields in ... or defaults be removed prior to operations?

Details

These functions form correctly formatted queries for IRIS WS.

constructor is a basic constructor which simply collapses the arguments into a single query.

constructor2 also does this, but enforces parameter inputs so the query at least has a chance for success.

params2queryparams is a function to collapse arguments into a single query string

Value

character string(s)

Author(s)

A.J. Barbour; and, see [2]

References

[1] http://service.iris.edu/irisws/

[2] http://pages.stern.nyu.edu/~dbackus/BCH/data/FRED/fredplot.R was the motivation for params2queryparams.

See Also

iris.query to query IRIS WS

irisws-wadl for using .wadl files

irisws-package

Other Utilities: irisws-package, irisws-timeutilities, irisws-wadl, query.iris

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
# Basic construction:
constructor()
constructor("net=1","sta=2")
#
# parameter flattening
params2queryparams(net=1,sta=2)
params2queryparams(net=1,sta=NULL)
# this only adds parameters
params2queryparams(a=1, b=2, defaults=c(a=1, b=1,c=2))
# this adds mandatory/optional (TRUE/FALSE) parameters:
params2queryparams(a=1, b=2, defaults=c(a=TRUE, b=FALSE))
# missing optionals are excluded by default
params2queryparams(a=1, defaults=c(a=TRUE, b=FALSE, c=TRUE))
# include them:
params2queryparams(a=1, defaults=c(a=TRUE, b=FALSE, c=TRUE), exclude.empty.options=FALSE)
#
# Constrained construction:
Q <- constructor2(net=1, sta=2) 
print(Q)  # note the 'MISSING.MANDATORY' field values
# check that it's valid:
try(check.query(Q))  # it's not.
#
# Another... Distaz
# What needs to be given though??
constructor2(service="distaz", list.fields.only=TRUE)
# fill them in...
Q <- constructor2(stalat=45, stalon=-120, evtlat=30.0, evtlon=-100.0, service="distaz")
print(Q)
# check that it's valid:
try(check.query(Q))  # it is.
#
# 'endtime' is an optional default, by default, and also 
not recognized if it is NULL
all.equal(constructor2(), constructor2(endtime=NULL))

## End(Not run)

abarbour/irisws documentation built on May 10, 2019, 4:07 a.m.