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

v.colors.out: Add JSON support #4964

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

NishantBansal2003
Copy link
Contributor

@NishantBansal2003 NishantBansal2003 commented Jan 18, 2025

fixes: #4660

Used Parson to add JSON output format support to the v.colors.out module.

Description

  • Added a new format option, allowing users to specify the output format:
  • format=plain for the current output format.
  • format=json for JSON output.
  • Introduced the color_format option to specify the color format for JSON output. Supported values for color_format include rgb, hex, hsv, and triplet.

Example JSON Output

The JSON output appears as follows:

[
        {"value": 1, "hex": "#00BFBF"},
        {"value": 20.8, "hex": "#00FF00"},
        {"value": 40.6, "hex": "#FFFF00"},
        {"value": 60.4, "hex": "#FF7F00"},
        {"value": 80.2, "hex": "#BF7F3F"},
        {"value": 100, "hex": "#C8C8C8"},
        {"value": "nv", "hex": "#FFFFFF"},
        {"value": "default", "hex": "#FFFFFF"},
]

Signed-off-by: Nishant Bansal <[email protected]>
@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python C Related code is in C module labels Jan 18, 2025
@cwhite911
Copy link
Contributor

How about setting the JSON key for the returned color to color instead of hex, rgb, hsv, and triplet because it doesn't appear that you can request multiple color formats at once.

@cwhite911 cwhite911 self-requested a review January 20, 2025 22:12
@github-actions github-actions bot added raster Related to raster data processing libraries labels Jan 21, 2025
@NishantBansal2003
Copy link
Contributor Author

How about setting the JSON key for the returned color to color instead of hex, rgb, hsv, and triplet because it doesn't appear that you can request multiple color formats at once.

Yes, that will be great. I have made the necessary changes. PTAL.

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.

@NishantBansal2003 looks good to me!

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

Works great!

@petrasovaa petrasovaa added this to the 8.5.0 milestone Jan 22, 2025
@petrasovaa petrasovaa merged commit fbabf32 into OSGeo:main Jan 22, 2025
27 checks passed
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 libraries module Python Related code is in Python raster Related to raster data processing vector Related to vector data processing
Projects
Development

Successfully merging this pull request may close these issues.

[Feat] Add JSON output to v.colors.out
3 participants