From b6e7a8026a0a92854ad259c0439428ee6afda1e6 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Fri, 24 Nov 2023 14:47:27 +0100 Subject: [PATCH] KP: Guess output dimensionality Make KP guess the required number of output dimensions, by matching the number of input dimensions --- ruminations/003-rumination.md | 78 +++++++++++++++++++---------------- src/bin/kp.rs | 49 ++++++++++++++++++---- 2 files changed, 83 insertions(+), 44 deletions(-) diff --git a/ruminations/003-rumination.md b/ruminations/003-rumination.md index adde94d..b685c08 100644 --- a/ruminations/003-rumination.md +++ b/ruminations/003-rumination.md @@ -4,13 +4,13 @@ Thomas Knudsen -2021-08-28. Last [revision](#document-history) 2023-11-20 +2021-08-28. Last [revision](#document-history) 2023-11-24 ### Abstract -```sh +```console $ echo 55 12 | kp "geo:in | utm zone=32" -> 691875.6321 6098907.8250 0.0000 0.0000 +> 691875.6321 6098907.8250 ``` --- @@ -27,20 +27,23 @@ For many years, Poder was in charge of the GI department for computational geode The basic operation of `kp` is very simple. Any complexity in `kp` usage is related to the description of the operation to carry out, which is the subject of [Rumination 002](/ruminations/002-rumination.md). The `kp` command line syntax is: -```sh -kp "operation" file1 file2 ... +```console +$ kp "operation" file1 file2 ... +> ... ``` or, with input from `stdin`: -```sh -echo coordinate | kp "operation" +```console +$ echo coordinate | kp "operation" +> ... ``` or, with output to the file `result`: -```sh -kp -o result "operation" file1 file2 ... +```console +$ kp -o result "operation" file1 file2 ... +> ... ``` ### Examples @@ -49,39 +52,40 @@ Convert the coordinate tuple (55 N, 12 E) from geographical coordinates on the ```sh $ echo 55 12 0 0 | kp "geo:in | utm zone=32" -> 691875.6321 6098907.8250 0.0000 0.0000 +> 691875.6321 6098907.8250 ``` -While RG coordinates are always 4D, `kp` will provide zero-values for any left-out postfix dimensions: +While RG coordinates are always 4D, `kp` will provide zero-values for any left-out postfix dimensions, and try to guess a proper number of output dimensions (unless the `-D n` option is given): -```sh +```console $ echo 55 12 | kp "geo:in | utm zone=32" -> 691875.6321 6098907.8250 0.0000 0.0000 +> 691875.6321 6098907.8250 + +$ echo 55 12 | kp -D3 "geo:in | utm zone=32" +> 691875.6321 6098907.8250 0.0000 + +$ echo 55 | kp "curvature mean" +> 6385431.75306 + +$ echo 55 | kp -D4 "curvature mean" +> 6385431.75306 0.00000 0.00000 NaN ``` The `roundtrip` option measures the roundtrip accuracy of a transformation (i.e. how close to the origin you end up after a forward+inverse dance). Knud Poder championed this practise with his ingeniously constructed *Poder dual autochecking* method, which was essential at a time where computers were less robust than today (more about that [below](#a-few-more-words-about-knud-poder)). -```sh +```console $ echo 55 12 | kp --roundtrip "geo:in | utm zone=32" -> 55 12: d = 0.05 mm +> -0.0000000000 -0.0000000000 ``` The `inv` option runs the specified pipeline inversely: -```sh +```console $ echo 691875.6321 6098907.8250 | kp --inv "geo:in | utm zone=32" > 54.9999999996 11.9999999994 0.00000 0.00000 ``` -The `inv` and `roundtrip` options are mutually exclusive: - -```txt -$ echo 691875.6321 6098907.8250 | kp --inv --roundtrip "geo:in | utm zone=32" -> Options `inverse` and `roundtrip` are mutually exclusive -> error: process didn't exit successfully: ... -``` - ### Options The `help` option gives the list of options: @@ -98,18 +102,19 @@ Arguments: [ARGS]... The files to operate on Options: - --inv Inverse operation - -z, --height Specify a fixed height for all coordinates - -t, --time