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

g.region: add JSON support #3941

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

kritibirda26
Copy link
Contributor

Using parson, add JSON support to g.region module.

The output looks like as follows:

{
    "projection": 99,
    "zone": 0,
    "region": {
        "north": 228500,
        "south": 215000,
        "west": 630000,
        "east": 645000,
        "ns-res": 10,
        "ns-res3": 10,
        "ew-res": 10,
        "ew-res3": 10
    },
    "top": 1,
    "bottom": 0,
    "tbres": 1,
    "rows": 1350,
    "rows3": 1350,
    "cols": 1500,
    "cols3": 1500,
    "depths": 1,
    "cells": 2025000,
    "cells3": 2025000
}

The interaction of format option with existing flags needs more looking into. We may want to disallow some combinations.

I will add tests and update documentation once the JSON format is finalized.

@github-actions github-actions bot added C Related code is in C module general labels Jun 29, 2024
@echoix echoix added this to the 8.5.0 milestone Jun 30, 2024
Copy link
Contributor

@cwhite911 cwhite911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kritibirda26 please address the comments I left in the review and add tests to make sure the JSON format respects the various flag combinations.

general/g.region/main.c Show resolved Hide resolved
general/g.region/printwindow.c Outdated Show resolved Hide resolved
general/g.region/printwindow.c Outdated Show resolved Hide resolved
}
}

/* flag.gmt_style */
if (print_flag & PRINT_GMT)
if ((print_flag & PRINT_GMT) && format != JSON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The json format should work with GMT and WMS print flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the output format in case of the GMT and WMS flags used with JSON respectively?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outputs can match what is returned from the plain and shell formats.

{
    "GMT":  "629970/645000/215010/228540",
    "WMS": "bbox=629970,215010,645000,228540"
}
@github-actions github-actions bot added Python Related code is in Python HTML Related code is in HTML docs tests Related to Test Suite labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C docs general HTML Related code is in HTML module Python Related code is in Python tests Related to Test Suite
3 participants