Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
b5f0cb04
Commit
b5f0cb04
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] 7 Added parameters
parent
9e6a576d
No related branches found
No related tags found
2 merge requests
!4
7 parameter
,
!2
Basic import and export functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/prj_parameter.R
+113
-25
113 additions, 25 deletions
R/prj_parameter.R
with
113 additions
and
25 deletions
R/prj_parameter.R
+
113
−
25
View file @
b5f0cb04
...
...
@@ -3,21 +3,34 @@
#'r2ogs6_parameter
#'@description S3 class describing a .prj parameter
#'@param name The parameter name
#'@param type The parameter type
#'@param values Optional: string | numeric: Parameter values
#'@description tag: parameter
#'@param name string:
#'@param type string:
#'@param value Optional: string | double: Parameter value
#'@param values Optional: string | double: Parameter values
#'@param curve Optional: string:
#'@param parameter Optional: string:
#'@param group_id_property Optional: string:
#'@param index_values Optional: list:
#'@param field_name Optional: string:
#'@param mesh Optional: string:
#'@param expression Optional: string:
#'@param time_series Optional: list:
#'@param use_local_coordinate_system Optional: string, "true" | "false":
#'@export
r2ogs6_parameter
<-
function
(
name
,
type
,
value
=
NULL
,
values
=
NULL
,
value
=
NULL
)
{
if
(
!
is.null
(
values
)
&&
!
is.null
(
value
)){
stop
(
paste
(
"r2ogs6_parameter: Use either 'values' or 'value'"
,
"parameter (XOR)"
),
call.
=
FALSE
)
}
curve
=
NULL
,
parameter
=
NULL
,
group_id_property
=
NULL
,
index_values
=
NULL
,
field_name
=
NULL
,
mesh
=
NULL
,
expression
=
NULL
,
time_series
=
NULL
,
use_local_coordinate_system
=
NULL
)
{
#Coerce input
value
<-
coerce_string_to_numeric
(
value
)
...
...
@@ -25,32 +38,107 @@ r2ogs6_parameter <- function(name,
new_r2ogs6_parameter
(
name
,
type
,
value
,
values
,
value
)
curve
,
parameter
,
group_id_property
,
index_values
,
field_name
,
mesh
,
expression
,
time_series
,
use_local_coordinate_system
)
}
new_r2ogs6_parameter
<-
function
(
name
,
type
,
values
,
value
)
{
value
=
NULL
,
values
=
NULL
,
curve
=
NULL
,
parameter
=
NULL
,
group_id_property
=
NULL
,
index_values
=
NULL
,
field_name
=
NULL
,
mesh
=
NULL
,
expression
=
NULL
,
time_series
=
NULL
,
use_local_coordinate_system
=
NULL
)
{
assertthat
::
assert_that
(
assertthat
::
is.string
(
name
))
assertthat
::
assert_that
(
assertthat
::
is.string
(
type
))
validate_is_null_or_numeric
(
values
)
validate_is_null_or_number
(
value
)
validate_is_null_or_numeric
(
values
)
validate_is_null_or_string
(
curve
,
parameter
,
group_id_property
,
field_name
,
mesh
,
expression
)
validate_is_null_or_str_flag
(
use_local_coordinate_system
)
structure
(
list
(
name
=
name
,
type
=
type
,
values
=
values
,
value
=
value
,
is_subclass
=
FALSE
,
attr_names
=
character
(),
flatten_on_exp
=
c
(
"values"
)
),
class
=
"r2ogs6_parameter"
index_values
<-
validate_index_values
(
index_values
)
if
(
!
is.null
(
time_series
)){
assertthat
::
assert_that
(
is.list
(
time_series
))
names
(
time_series
)
<-
rep
(
"pair"
,
length
(
time_series
))
for
(
i
in
seq_len
(
length
(
time_series
))){
time_series
[[
i
]]
<-
validate_param_list
(
time_series
[[
i
]],
c
(
"time"
,
"parameter_name"
))
}
}
structure
(
list
(
name
=
name
,
type
=
type
,
value
=
value
,
values
=
values
,
curve
=
curve
,
parameter
=
parameter
,
group_id_property
=
group_id_property
,
index_values
=
index_values
,
field_name
=
field_name
,
mesh
=
mesh
,
expression
=
expression
,
time_series
=
time_series
,
use_local_coordinate_system
=
use_local_coordinate_system
,
is_subclass
=
TRUE
,
attr_names
=
character
(),
flatten_on_exp
=
c
(
"values"
)
),
class
=
"r2ogs6_parameter"
)
}
#===== validation utility =====
validate_index_values
<-
function
(
index_values
){
if
(
!
is.null
(
index_values
)){
assertthat
::
assert_that
(
is.list
(
index_values
))
assertthat
::
assert_that
(
length
(
index_values
==
2
))
#Coerce index
index_values
[[
1
]]
<-
coerce_string_to_numeric
(
index_values
[[
1
]])
names
(
index_values
)[[
1
]]
<-
"index"
#Coerce value / values
index_values
[[
2
]]
<-
coerce_string_to_numeric
(
index_values
[[
2
]],
TRUE
)
if
(
length
(
index_values
[[
2
]])
>
1
){
names
(
index_values
)[[
2
]]
<-
"values"
}
else
{
names
(
index_values
)[[
2
]]
<-
"value"
}
}
return
(
invisible
(
index_values
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment