OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
820 stars 302 forks source link

[Bug] r.info: format=json does not respect flags #4039

Open veroandreo opened 1 month ago

veroandreo commented 1 month ago

Describe the bug

r.info with format=json does not seem to respect the flags and always prints the same info.

To reproduce

r.info -r map=elevation format=json
r.info -g map=elevation format=json
r.info -h  map=elevation format=json
r.info -e  map=elevation format=json

They all print this:

{
    "north": 228500,
    "south": 215000,
    "nsres": 10,
    "east": 645000,
    "west": 630000,
    "ewres": 10,
    "rows": 1350,
    "cols": 1500,
    "cells": 2025000,
    "datatype": "FCELL",
    "ncats": 255,
    "min": 55.578792572021484,
    "max": 156.32986450195312,
    "map": "elevation",
    "maptype": "raster",
    "mapset": "PERMANENT",
    "location": "nc_spm_08_grass7",
    "project": "nc_spm_08_grass7",
    "database": "\/home\/vandreo\/grassdata",
    "date": "Tue Nov  7 01:09:51 2006",
    "creator": "helena",
    "title": "South-West Wake county: Elevation NED 10m",
    "timestamp": null,
    "units": null,
    "vdatum": null,
    "semantic_label": null,
    "source1": "",
    "source2": "",
    "description": "generated by r.proj",
    "comments": [
        "r.proj input=\"ned03arcsec\" location=\"northcarolina_latlong\" mapset=\"\\",
        "helena\" output=\"elev_ned10m\" method=\"cubic\" resolution=10"
    ]
}

Expected behavior

format=json should print only what the flag indicates as format=plain does

System description

GRASS version: 8.5.0dev                                                         
Code revision: ee9fa48798                                                       
Build date: 2024-07-11                                                          
Build platform: x86_64-pc-linux-gnu                                             
GDAL: 3.7.1                                                                     
PROJ: 9.2.1                                                                     
GEOS: 3.12.0                                                                    
SQLite: 3.42.0                                                                  
Python: 3.11.6                                                                  
wxPython: 4.2.1                                                                 
Platform: Linux-6.5.0-44-generic-x86_64-with-glibc2.38                          
veroandreo commented 1 month ago

@kritibirda26 would you mind having a look?

kritibirda26 commented 1 month ago

Hi @veroandreo! This is the intended behavior. As per the discussion at https://github.com/OSGeo/grass/pull/3744, only the -s flag is respected.

veroandreo commented 1 month ago

Hi @veroandreo! This is the intended behavior. As per the discussion at #3744, only the -s flag is respected.

I see, would you please document that behavior in the r.info manual page? I found it pretty confusing that flags were not respected.

kritibirda26 commented 1 month ago

Sure, will do.