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

[Feat] Add JSON output to v.colors.out #4660

Open
NishantBansal2003 opened this issue Nov 6, 2024 · 4 comments
Open

[Feat] Add JSON output to v.colors.out #4660

NishantBansal2003 opened this issue Nov 6, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@NishantBansal2003
Copy link
Contributor

Add JSON output for easy parsing of v.colors.out output.

Describe the solution you'd like
Add an option for format, such as format=plain for the current output format and format=json for the JSON output. Additionally, include the color_format option to specify the color format to be printed in JSON. The available options for color_format include rgb, hex, hsv, and triplet.

A possible JSON layout could be:

[
    {
        "value": 1,
        "hex": "#00BFBF"
    },
    {
        "value": 286.4,
        "hex": "#00FF00"
    },
    {
        "value": 571.8,
        "hex": "#FFFF00"
    },
    {
        "value": 857.2,
        "hex": "#FF7F00"
    },
    {
        "value": 1142.6,
        "hex": "#BF7F3F"
    },
    {
        "value": 1428,
        "hex": "#C8C8C8"
    },
    {
        "value": "nv",
        "hex": "#FFFFFF"
    },
    {
        "value": "default",
        "hex": "#FFFFFF"
    }
]
@NishantBansal2003 NishantBansal2003 added the enhancement New feature or request label Nov 6, 2024
@petrasovaa
Copy link
Contributor

We should consider moving some of the common functionality with r.colors.out to library to avoid duplication.

@NishantBansal2003
Copy link
Contributor Author

Sure, I will create a PR since both r.colors.out and v.colors.out print colors in plain text using Rast_print_colors.

Rast_print_colors(&colors, range.min, range.max, fp,
flag.p->answer ? 1 : 0);

Rast_print_colors(colors, (DCELL)min, (DCELL)max, fp,
flag.p->answer ? 1 : 0);

@NishantBansal2003
Copy link
Contributor Author

We should consider moving some of the common functionality with r.colors.out to library to avoid duplication.

Hey @petrasovaa, should I move the common functionality to a library and add JSON output to v.colors.out in a single PR or separate PRs?

@echoix
Copy link
Member

echoix commented Nov 7, 2024

We should consider moving some of the common functionality with r.colors.out to library to avoid duplication.

Hey @petrasovaa, should I move the common functionality to a library and add JSON output to v.colors.out in a single PR or separate PRs?

To answer this, you can think about if there would be a problem with the PR and it would need to be reverted, would it also remove some other new functionality? If so, it's probably because it would have been better to be in separate PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants