| Title: | Read and Write CCTV Inspection Data According to Norm EN13508-2 |
|---|---|
| Description: | functions to read and write CCTV inspections according to EN13508-2. |
| Authors: | Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Kompetenzzentrum Wasser Berlin gGmbH [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-05-22 09:30:43 UTC |
| Source: | https://github.com/KWB-R/kwb.en13508.2 |
Generate List With EU Header Information
euCodedFileHeader( separator = ";", decimal = ".", quote = "\"", encoding = "ISO-8859-1", language = "en", year = 2010L )euCodedFileHeader( separator = ";", decimal = ".", quote = "\"", encoding = "ISO-8859-1", language = "en", year = 2010L )
separator |
default: ";" |
decimal |
default: "." |
quote |
default: '"' |
encoding |
default: "ISO-8859-1" |
language |
default: "en" |
year |
default: 2010 |
list with elements separator, decimal, quote,
encoding, language, year
Extract Lines Between #C-Header and #Z End Tag
extractObservationBlocks(text, headerInfo, uniqueKey)extractObservationBlocks(text, headerInfo, uniqueKey)
text |
text lines read from EN13508.2-coded file |
headerInfo |
data frame with information about header lines |
uniqueKey |
identifier of C-header row, as given in
|
list of vectors of character representing the "body" lines
below the #C-headers of type specified in uniqueKey
Extract Observations from EN13508.2-coded file
extractObservationData_2( text, headerInfo, header.info, file = "", as.text = FALSE, dbg = TRUE )extractObservationData_2( text, headerInfo, header.info, file = "", as.text = FALSE, dbg = TRUE )
text |
text lines read from EN13508.2-coded file |
headerInfo |
data frame with information about header lines |
header.info |
list as returned by
|
file |
optional. Name of the file from which |
as.text |
whether or not to keep columns in their original (character)
type. The default is |
dbg |
whether or not to show debug messages |
data frame with columns A, B, C, ... as defined
in EN13508.2 and a column inspno referring to the inspection number.
Get a data frame containing EU codes and their meaning in different languages
getCodes(table = NULL, fields = NULL)getCodes(table = NULL, fields = NULL)
table |
name or vector of names of tables in the EU norm for which to
get field information. Use |
fields |
set to a vector of field (column) names to restrict the columns returned |
data frame
Get Header Lines From Header Info
getHeaderLinesFromHeaderInfo(header.info)getHeaderLinesFromHeaderInfo(header.info)
header.info |
list with elements |
Get Information on Line Damages
getLineDamageInfo( observations, I = observations$I, J = observations$J, inspno = observations$inspno, dbg = TRUE )getLineDamageInfo( observations, I = observations$I, J = observations$J, inspno = observations$inspno, dbg = TRUE )
observations |
data frame with observations. Required columns: |
I |
Numeric vector of positions of observations |
J |
Vector of character of same length as |
inspno |
vector of inspection identifiers of same length as |
dbg |
if |
data frame with columns ino (inspection number), ldno
(line damage number), beg.at, end.at, beg.x (position
of line damage begin), end.x (position of line damage end),
length (length of line damage)
Merge inspections and observations provided in a list
mergeInspectionData(x, warn = FALSE, naToEmpty = TRUE)mergeInspectionData(x, warn = FALSE, naToEmpty = TRUE)
x |
list of elements each of which represents inspection data read from
an EN13508.2-encoded file by means of |
warn |
logical indicating whether to warn about different header information. By default, warnings are not shown. |
naToEmpty |
logical indicating whether or not to replace |
list with elements header.info, inspections,
observations.
Get number of inspections from list of inspection data
numberOfInspections(x)numberOfInspections(x)
x |
list of inspection data elements each of which was read from an EN
13508-2-coded file by means of |
vector of integer representing the number of inspections in each
element of inspectionDataList
Plot Observations per Pipe
plotObservations(survey, to_pdf = TRUE, matrix_dim = c(7, 1))plotObservations(survey, to_pdf = TRUE, matrix_dim = c(7, 1))
survey |
list with elements |
to_pdf |
if |
matrix_dim |
vector of two specifying the number of rows and columns, respectivly of the matrix in which to arrange the single plots. |
# Install packages if not yet installed ## Not run: install.packages("ggplot2") devtools::install_github("guiastrennec/ggplus") ## End(Not run) # Get example data that are contained in the package survey <- kwb.en13508.2:::getExampleData() # Create one plot per inspection in "survey" kwb.en13508.2::plotObservations(survey, to_pdf = FALSE)# Install packages if not yet installed ## Not run: install.packages("ggplot2") devtools::install_github("guiastrennec/ggplus") ## End(Not run) # Get example data that are contained in the package survey <- kwb.en13508.2:::getExampleData() # Create one plot per inspection in "survey" kwb.en13508.2::plotObservations(survey, to_pdf = FALSE)
Read files in EN13508.2-format using readEuCodedFiles and merge
them by means of mergeInspectionData
readAndMergeEuCodedFiles( input.files, dbg = FALSE, name.convention = "norm", ..., add.inspid = FALSE, project = NULL, default.time = "22:22", error.file = NULL )readAndMergeEuCodedFiles( input.files, dbg = FALSE, name.convention = "norm", ..., add.inspid = FALSE, project = NULL, default.time = "22:22", error.file = NULL )
input.files |
full path to text file containing CCTV inspection results in the format described in DIN EN 13508-2 |
dbg |
if |
name.convention |
passed to |
... |
further arguments passed to |
add.inspid |
if |
project |
name of project to which the data are related, such as: "Lausanne" |
default.time |
passed to |
error.file |
optional. Path to error file, passed to
|
Read CCTV inspection data from file coded according to EN13508-2
readEuCodedFile( input.file, encoding = "unknown", file.encoding = NULL, read.inspections = TRUE, name.convention = c("norm", "camel", "snake")[1L], simple.algorithm = TRUE, warn = TRUE, dbg = TRUE, check.encoding = TRUE, ... )readEuCodedFile( input.file, encoding = "unknown", file.encoding = NULL, read.inspections = TRUE, name.convention = c("norm", "camel", "snake")[1L], simple.algorithm = TRUE, warn = TRUE, dbg = TRUE, check.encoding = TRUE, ... )
input.file |
full path to text file containing CCTV inspection results in the format described in DIN EN 13508-2 |
encoding |
default: "unknown", passed to |
file.encoding |
Encoding to be assumed for the |
read.inspections |
if |
name.convention |
one of |
simple.algorithm |
if |
warn |
if |
dbg |
if |
check.encoding |
logical indicating whether or not to check if the
encoding string that is given in the |
... |
further arguments to be passed to
|
list with elements header.info, inspections,
observations
Read CCTV inspection data from multiple files coded according to EN13508-2
readEuCodedFiles(input.files, dbg = TRUE, append.file.names = TRUE, ...)readEuCodedFiles(input.files, dbg = TRUE, append.file.names = TRUE, ...)
input.files |
vector of character paths to input files |
dbg |
if |
append.file.names |
if TRUE (default) the filename will be provided in
column |
... |
arguments passed to |
list of sublists each of which is the result of a call to
readEuCodedFile. The names of the list elements are
constructed from the file names of the input files. Special characters
in the file names are replaced with underscore. Names will get a preceding
letter "x" if they start with a digit or with underscore. If files could
not be read correctly, their indices are returnded in attribute
which_failed.
Read CSV File from Package's extdata Folder
readPackageFile(file, ...)readPackageFile(file, ...)
file |
file name (without path) |
... |
additional arguments passed to |
data frame representing the content of file
Replace values in columns inspection_id
replaceInspectionId(inspection.data, new_ids)replaceInspectionId(inspection.data, new_ids)
inspection.data |
list with inspections data frame in element
|
new_ids |
vector of as many inspection ids as there are rows in
|
list with data frames in elements inspections and
observations. In each data frame the values in column
inspection_id are updated according to the new_ids.
inspection.data <- list( inspections = data.frame( inspection_id = 1:3, pipe_id = 1:3 ), observations = data.frame( inspection_id = c(1, 1, 2, 2, 3, 3), observation = c("start", "end", "start", "end", "start", "end") ) ) replaceInspectionId(inspection.data, new_ids = paste0("id_", 1:3))inspection.data <- list( inspections = data.frame( inspection_id = 1:3, pipe_id = 1:3 ), observations = data.frame( inspection_id = c(1, 1, 2, 2, 3, 3), observation = c("start", "end", "start", "end", "start", "end") ) ) replaceInspectionId(inspection.data, new_ids = paste0("id_", 1:3))
Convert inspections numbers (inspno) 1,2,3,... to globally unique identifiers (inspid), such as "e4b48d86"
setGlobalInspectionID( inspection.data, project = NULL, default.time = "22:22", name.convention = "norm", error.file = NULL )setGlobalInspectionID( inspection.data, project = NULL, default.time = "22:22", name.convention = "norm", error.file = NULL )
inspection.data |
list with elements |
project |
name of project to which the data are related, such as: "Lausanne" |
default.time |
default time string to use if column <inspection-time> is not available. Default: "22:22". A random number will be generated for the seconds, just to increase the chance that setting the time is enough to generate a unique key. |
name.convention |
one of |
error.file |
optional. Path to file to which duplicates are are written
(if any). Default: |
list with the same elements as in inspection.data but with
columns inspid being added to the data frames "inspections" and
"observations"
Generate Lines in EU Export Format
toEuFormat(inspection.data, version = 3L, ..., dbg = TRUE)toEuFormat(inspection.data, version = 3L, ..., dbg = TRUE)
inspection.data |
inspection data as retrieved by e.g.
|
version |
version of implementation. One of |
... |
passed to |
dbg |
whether or not to show debug messages |
Generate lines in EU export format (version 1: slow)
toEuFormat_v1(header.info, inspections, observations, dbg = TRUE)toEuFormat_v1(header.info, inspections, observations, dbg = TRUE)
header.info |
according to list element "header.info" of list returned
by |
inspections |
according to list element "inspections" of list returned
by |
observations |
according to list element "observations" of list returned
by |
dbg |
whether or not to show debug messages |
Generate lines in EU export format (version 2: faster than version 1)
toEuFormat_v2(inspection.data, mycsv, ..., dbg = TRUE)toEuFormat_v2(inspection.data, mycsv, ..., dbg = TRUE)
inspection.data |
inspection data as retrieved by e.g.
|
mycsv |
logical. If TRUE "my" version of writing CSV is used (fast), otherwise CSV is written by means of write.table (slow) |
... |
further arguments passed to dataFrameContentToTextLines |
dbg |
whether or not to show debug messages |
Values to CSV
valuesToCsv( x, dec = ".", sep = ",", na = "", qchar = "\"", qmethod = c("double", "escape")[1] )valuesToCsv( x, dec = ".", sep = ",", na = "", qchar = "\"", qmethod = c("double", "escape")[1] )
x |
vector of values representing a row in a CSV file |
dec |
decimal character |
sep |
field separating character |
na |
text to be used in case of NA values |
qchar |
quoting character to be used to surround text fields containing the field separator |
qmethod |
method used to indicate that a quoting character within a quoted text field is not the ending quote. Either "double" (double the quote character) or "escape" (backslash in front of the quoting character). |
Write Inspection Data to File in EU Format
writeEuCodedFile( inspection.data, output.file = NULL, version = 3L, dbg = TRUE, ... )writeEuCodedFile( inspection.data, output.file = NULL, version = 3L, dbg = TRUE, ... )
inspection.data |
inspection data as retrieved by e.g.
|
output.file |
full path to output file |
version |
version of implementation. One of |
dbg |
if |
... |
passed to |
if output.file is given, the path to the output file is
returned, otherwise (output.file = NULL) the file content is
returned as a vector of character representing the lines of the file.
Write inspection data to files in EU format with each file containing data of a fix number (default: 100) of inspections
writeEuCodedFiles(survey, file, blocksize = 100, dbg = TRUE)writeEuCodedFiles(survey, file, blocksize = 100, dbg = TRUE)
survey |
list with elements |
file |
Full path to output file. The file name must end with ".txt" which will be replaced with "_<i>_<j>.txt" with i and j being the number of the first and last inspection, respectively, contained in the file. |
blocksize |
number of inspections to be written to one file. Default: 100 |
dbg |
if TRUE (default) debug messages are shown. |