Learn R Programming

sos4R (version 0.4.2)

Defaults: Default Parameter Settings and Handling Functions

Description

These values are default parameters and handling functions for connections and requests to, as well as response processing of answers from, Sensor Observation Services. These allow to simplify a SOS connection for the most common use cases and non-expert users.

Usage

SosDefaultBinding()

SosParsingFunctions(..., include = character(0), exclude = character(0)) SosEncodingFunctions(..., include = character(0), exclude = character(0)) SosDataFieldConvertingFunctions(..., include = character(0), exclude = character(0))

SosDisabledParsers()

SosDefaults()

SosResetParsingFunctions(sos)

SosDefaultDCPs()

SosDefaultParsingOptions()

Arguments

Named references to functions to be used for the respective element during parsing, encoding or conversion, e.g. "myUnit" = myUnitParser.

include

A list of names of elements whose functions shall be included in the returned list, e.g. include = c("GetObservation", "DescribeSensor"). This inclusion is done after replacing the default functions based on the ... argument.

exclude

A list of names of elements whose functions shall be excluded in the returned list, e.g. exclude = c("DescribeSensor"). This exclusion is done after replacing the default functions based on the ... argument.

sos

An object of class SOS.

Value

The default value of the respective setting or parameter. This can be a list, especially a named list of functions.

Details

The default values are strongly related to what is actually implemented in the package, but also often resemble the (hopefully) most common use cases.

Some defaults are accessed directly, others should be accessed using a function. The latter is required for cases where a runtime evaluation is needed, e.g. for default values of construction functions.

A special case are the functions to access the default functions for specific purposes, which are the parsing functions, the encoding functions and the field converting functions. See the examples on how to use them.

The function SosDisabledParsers can be used to use no parsing at all (despite the parsing for the capabilities response, which is required for establishing a connection to a SOS. This function is helpful to inspect the unprocessed responses from a service.

The function SosResetParsingFunctions can be used to replace the included parsing functions of a SOS object with the default ones. This is even useful for development of the default parsing functions.

The default parameter values are:

sosDefaultCharacterEncoding

\Sexpr[results=verbatim,stage=render]{sosDefaultCharacterEncoding}

% "UTF-8"
sosDefaultDescribeSensorOutputFormat

\Sexpr[results=text,stage=render]{sosDefaultDescribeSensorOutputFormat}

sosDefaultGetCapSections

\Sexpr[results=text,stage=render]{sosDefaultGetCapSections}

% c("All")
sosDefaultGetCapAcceptFormats

\Sexpr[results=text,stage=render]{sosDefaultGetCapAcceptFormats}

% c("text/xml")
sosDefaultGetCapOwsVersion

\Sexpr[results=text,stage=render]{sosDefaultGetCapOwsVersion}

% "1.1.0"
sosDefaultGetObsResponseFormat

\Sexpr[results=text,stage=render]{sosDefaultGetObsResponseFormat}

sosDefaultTimeFormat

\Sexpr[results=text,stage=render]{sosDefaultTimeFormat}

% "%Y-%m-%dT%H:%M:%OS"
sosDefaultFilenameTimeFormat

\Sexpr[results=text,stage=render]{sosDefaultFilenameTimeFormat}

%
sosDefaultTempOpPropertyName

\Sexpr[results=text,stage=render]{sosDefaultTempOpPropertyName}

% "om:samplingTime"
sosDefaultTemporalOperator

\Sexpr[results=text,stage=render]{sosDefaultTemporalOperator}

% SosSupportedTemporalOperators()[[ogcTempOpTMDuringName]]
sosDefaultSpatialOpPropertyName

\Sexpr[results=text,stage=render]{sosDefaultSpatialOpPropertyName}

% "urn:ogc:data:location"

The default parsing functions can be replaced for a variety of XML elements, so that you only need to replace the parts of the parsing that really must be changed. Be aware that inclusion and exclusion are performed after merging the given functions with the defaults!

Example Services: This list contains a few SOS instances that were tested (to different degress) with sos4R. The package authors do not maintain these services, so no guarantee can be given that these are usable.

References

Constants

Examples

Run this code
# NOT RUN {
# simple default values
show(sosDefaultCharacterEncoding)
show(sosDefaultDescribeSensorOutputFormat)
show(sosDefaultGetCapAcceptFormats)
show(sosDefaultGetCapOwsVersion)
show(sosDefaultGetCapSections)
show(sosDefaultGetObsResponseFormat)
show(sosDefaultSpatialOpPropertyName)
show(sosDefaultTempOpPropertyName)
show(sosDefaultTemporalOperator)
show(sosDefaultTimeFormat)
SosDefaultBinding()

# }
# NOT RUN {
# usage of defaults in construction method for SOS class
sos <- SOS("http://mysos.com/sos", binding = SosDefaultBinding(),
		timeFormat = sosDefaultTimeFormat)

# functions to disable all parsing
SosDisabledParsers()
# }
# NOT RUN {

# Replace a parsing function
myER <- function(xml) {
	return("EXCEPTION!!!11")
}
myParsingFunctions <- SosParsingFunctions("ExceptionReport" = myER)

# use inclusion and exclusion, important: even the just added function needs to
# be included manually!
myParsingFunctions <- SosParsingFunctions("ExceptionReport" = myER,
	include = c("GetObservation", "DescribeSensor", "ExceptionReport"))

myParsingFunctions <- SosParsingFunctions(exclude = c("GetObservation", "DescribeSensor"))

# }
# NOT RUN {
# Replace an encoding function
myEncoding <- function(object, v) {
	return(utils::str(object))
}

sos = SOS(url = "http://mysos.com/sos",
		encoders = SosEncodingFunctions("POST" = myPostEncoding))


# Use custom converting function and connection method. This mechanism works the
# same for encoders and decoders.
myConverters <- SosDataFieldConvertingFunctions(
	"myNumericUnit" = sosConvertDouble)
mySos <- SOS(sos.url, binding = "KVP", dataFieldConverters = myConverters)
sosDataFieldConverters(mySos)

# inspecting XML using dummy parsing function
sos = SOS(url = "http://mysos.com/sos", parsers = SosDisabledParsers)
describeSensor(sos, sosProcedures(sos)[[1]])

# replace the parsing functions with the default ones
sos <- SosResetParsingFunctions(sos)

# }
# NOT RUN {
# a named list of all defaults
SosDefaults()

# parsing options used by xml2
SosDefaultParsingOptions()
# }

Run the code above in your browser using DataLab