Skip to content

Commit

Permalink
FIX: cas_lineadapt(): always start a new line for full value when lin…
Browse files Browse the repository at this point in the history
…e is too long
  • Loading branch information
tpilz committed Apr 12, 2021
1 parent cfb8e26 commit 27403ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
## Fixes
- `tin()`
- check of curve orientation of outer boundary
- `cas_lineadapt()`
- break of line within keyword or filename caused TELEMAC error

# version 0.1.0, Feb 2021, first release
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- support holes (inner boundaries) in TIN generation (so far only outer boundary and breaklines)
- Gmsh support: add function to prepare Gmsh input (geometry file as in pputils gis2gmsh.py)
- line_spacing(): works for segments, should also work for closed boundaries (distance between first and last point should match)
- cas_lineadapt(): needs more sophisticated workaround to work in all situations (see comments)

# CRAN submission (general)
- In case of incompatible licence of a package in `Imports`: move package to `Suggests` (in case the package is not fundamentally required, in such a case an own implementation would be required)
Expand Down
27 changes: 16 additions & 11 deletions src/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ DataFrame cas_lineadapt(DataFrame df, int sep_len) {
do {
p = len_excess_i[i] + h + 1;
st = value[p-1]; // value string to be split
// if there is a slash only one line possible
grp = grepl("/", st);
if (grp[0]) {
si = ""; // first part empty
sp = st; // second part: whole string in new line
if (sp.length() > 72)
stop("Steering parameter values containing a slash '/' character must not be longer than 72 characters!");
} else {
si = st.substr(0, 72 - len_key_max); // first part of value string
sp = st.substr(72 - len_key_max, st.length() - si.length()); // second part
}
// // if there is a slash only one line possible
// grp = grepl("/", st);
// if (grp[0]) {
// si = ""; // first part empty
// sp = st; // second part: whole string in new line
// if (sp.length() > 72)
// stop("Steering parameter values containing a slash '/' character must not be longer than 72 characters!");
// } else {
// si = st.substr(0, 72 - len_key_max); // first part of value string
// sp = st.substr(72 - len_key_max, st.length() - si.length()); // second part
// }
// linbreaks seem to be only allowed within '' and between array elements (in keywords a space is inserted).
// Maybe the following is just enough in practice?!
// Ensuring the above requirements would require a more complex workaround...
si = "";
sp = st;
// update key and value
key.insert(key.begin() + p, "");
value[p-1] = si;
Expand Down

0 comments on commit 27403ed

Please sign in to comment.