-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
g.proj: add JSON support #4104
base: main
Are you sure you want to change the base?
g.proj: add JSON support #4104
Conversation
For the proj4 format flag -j and the WKT format flag -w you can just return the the flattened (flag -f) string to the json. {
"wtk": "string_value",
"proj4": "string_value"
} |
Use parson to add JSON support to g.proj. Currently, only works with the -p flag.
@cwhite911 I have made the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Please add tests and update the docs.
From @florisvdh on issue #3020
|
@cwhite911 I tried to update the output to use projjson specification, however there seem to be a lot of cases to handle. IIUC, there are 3 different major versions (4/5/6) of proj4 that need to be handled separately and another case of not having libproj4 but using internal Grass GIS functions. FWIW, libproj4 starting with v6 exposes a function to generate the projjson representation directly. While reading the code in |
@kritibirda26 that sounds good to me. Thanks for looking into it! |
Are we even running build that use proj4? I only remember seeing proj 5+ api at the end of configure, and now Proj is at 9.4 now. |
According to |
Do we want to go forward finishing up and merging the existing json PRs kinda soon? since some work is being done to implement on other modules too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should merge this as it addresses the main purpose of the PR and make a new issues to discuss incorporating the PROJJSON specification.
@echoix same issue here. I am no longer able to resolve conversations. |
Ok, resolved them. Do you think the tests failures are transient and I should update the PR, or there's some real changes to do? |
Because of the open comments, when doing my rounds of PRs to merge, I didn't act on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to fix the shell
format output when the g
flag is set.
for (i = 0; i < projinfo->nitems; i++) { | ||
if (strcmp(projinfo->key[i], "init") == 0) | ||
continue; | ||
if (shell) | ||
switch (format) { | ||
case PLAIN: | ||
fprintf(stdout, "%s=%s\n", projinfo->key[i], projinfo->value[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fprintf(stdout, "%s=%s\n", projinfo->key[i], projinfo->value[i]); | |
fprintf(stdout, "%-11s: %s\n", projinfo->key[i], | |
projinfo->value[i]); |
fprintf(stdout, "%-11s: %s\n", projinfo->key[i], | ||
projinfo->value[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fprintf(stdout, "%-11s: %s\n", projinfo->key[i], | |
projinfo->value[i]); | |
fprintf(stdout, "%s=%s\n", projinfo->key[i], projinfo->value[i]); |
@kritibirda26 will you please accept these changes so we can merge this PR. |
Real changes. Nice catch @echoix! |
Use parson to add JSON support to g.proj. Currently, only works with the -p flag.
I tried to add support for some other flags as well but it seems the SHELL/PLAIN output needs to be parsed manually to obtain the data and there is no direct way to obtain the data directly, for instance for
w
flag.Also, some floats are represented as strings at the moment and need to be fixed.