From 27403edcf18dc4ae77649f7653f6569fb9aee6a0 Mon Sep 17 00:00:00 2001 From: Tobias Pilz Date: Mon, 12 Apr 2021 09:54:57 +0200 Subject: [PATCH] FIX: cas_lineadapt(): always start a new line for full value when line is too long --- NEWS.md | 2 ++ TODO.md | 1 + src/helper.cpp | 27 ++++++++++++++++----------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6e47bd2..0614de4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/TODO.md b/TODO.md index a3a302f..001e1e6 100644 --- a/TODO.md +++ b/TODO.md @@ -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) diff --git a/src/helper.cpp b/src/helper.cpp index 9848800..e26c764 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -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;