Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cct: Forward non-coordinate input to output #918

Closed
kbevers opened this issue Apr 3, 2018 · 4 comments
Closed

cct: Forward non-coordinate input to output #918

kbevers opened this issue Apr 3, 2018 · 4 comments

Comments

@kbevers
Copy link
Member

kbevers commented Apr 3, 2018

Say I have a file with the following content:

VAGT, 10736, 20101004, 3566244.16681, 699724.21743, 5223954.52103, 4
FROE, 10738, 20101030, 3569937.45201, 691670.67895, 5222502.53386, 4
FRGB, 29182, 20121003, 3383059.35548, 629918.91897, 5352213.94102, 3
BUDD, 74435, 20110715, 3513649.22391, 778954.85318, 5248202.02568, 7
LIND, 102048, 20111003, 3529554.52560, 745900.73158, 5242315.87890, 4
VAEG, 246606, 20081130, 3612854.89379, 763382.51902, 5183133.86368, 6
...

I can use that in a transformation with cct by specifying which columns the data is located in with

cct -c 4,5,6,3 +proj=...

The ouput will then be something like:

  633190.4711   6136231.7651       54.7020     2010.7562
  624658.5185   6133442.3240       45.3132     2010.8274
  592904.9081   6366960.6848       39.9896     2012.7541
  719704.1352   6182565.5292       87.9395     2011.5342
  684549.3135   6170540.7564       45.4444     2011.7534

Here it would be useful to also have the data from the non-coordinate columns, similar to what proj and cs2cs does. This can be done in a number of ways, for instance the data can be output in the same column order as the input or the coordinates could be printed first with the non-coordinate columns printed after the coordinates.

@busstoptaktik
Copy link
Member

I think proj and cs2cs just appends the input record to the output. And, besides being the easiest to implement, I also think it in most cases will be the most useful. Editing the input record, replacing input coordinate by output coordinate is tedious, and gets even more complicated in cases where -t and/or -z options are used, so one or two coordinates are missing from the input record.

@kbevers: If you agree, I will submit a PR implementing this.

@kbevers
Copy link
Member Author

kbevers commented Apr 16, 2018

@kbevers: If you agree, I will submit a PR implementing this.

I agree 👍

@kbevers
Copy link
Member Author

kbevers commented Apr 16, 2018

How difficult would it be to implement a solution where all non-coordinate columns are appended at the end of the output? Let's say for input like

VAGT, 10736, 20101004, 3566244.16681, 699724.21743, 5223954.52103, 4

you would get a the following back

   633190.4711   6136231.7651    54.7020   2010.7562   VAGT, 10736,  4

I am not sure it is preferable as the default behaviour but maybe if controlled by switch it can be useful in some cases.

@busstoptaktik
Copy link
Member

How difficult would it be to implement a solution where all non-coordinate columns are appended at the end of the output?

Probably not terribly difficult, but I am a bit reluctant at building too much of AWK into cct. Better include everything, and let the user pipe output through an awk one-liner to remove the unneeded.

kbevers added a commit to kbevers/PROJ that referenced this issue Sep 6, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
kbevers added a commit to kbevers/PROJ that referenced this issue Sep 6, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
kbevers added a commit to kbevers/PROJ that referenced this issue Sep 7, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
kbevers added a commit to kbevers/PROJ that referenced this issue Sep 7, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
kbevers added a commit to kbevers/PROJ that referenced this issue Sep 7, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
kbevers added a commit to kbevers/PROJ that referenced this issue Sep 7, 2018
Any text written after the coordinate input will automatically be
forwarded to the output stream. Text in columns before the coordinate
input is discarded in the output. This works for any combination of -c, -t
and -z parameters:

$ echo 12 56 100 2018.0 comment comment | cct +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment commen

$ echo text 12 56 100 2018.0 comment | cct -c 2,3,4,5 +proj=merc
 1335833.8895   7522963.2411      100.0000     2018.0000 comment

$ echo text 12 56 comment | cct -c 2,3 -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

$ echo 12 56 comment | cct -t0 -z0 +proj=merc
 1335833.8895   7522963.2411        0.0000        0.0000 comment

Closes OSGeo#918
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants