OSGeo / grass

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

v.info: add json output for columns #4590

Closed NishantBansal2003 closed 3 weeks ago

NishantBansal2003 commented 1 month ago

Use parson to add json support to v.info for columns. The JSON output looks like as follows:

{
    "columns": [
        {
            "name": "cat",
            "sql_type": "INTEGER",
            "is_number": true
        },
        {
            "name": "MAJORRDS_",
            "sql_type": "DOUBLE PRECISION",
            "is_number": true
        },
        {
            "name": "ROAD_NAME",
            "sql_type": "CHARACTER",
            "is_number": false
        },
        {
            "name": "MULTILANE",
            "sql_type": "CHARACTER",
            "is_number": false
        },
        {
            "name": "PROPYEAR",
            "sql_type": "INTEGER",
            "is_number": true
        },
        {
            "name": "OBJECTID",
            "sql_type": "INTEGER",
            "is_number": true
        },
        {
            "name": "SHAPE_LEN",
            "sql_type": "DOUBLE PRECISION",
            "is_number": true
        }
    ]
}

fixes: https://github.com/OSGeo/grass/issues/4218

nilason commented 1 month ago

As print_columns() creates its own json objects, the following part in main:

https://github.com/OSGeo/grass/blob/24469d8dcb73fdcec1c59713de4a8c82ce3eea3e/vector/v.info/main.c#L57-L60

may be moved down, before:

https://github.com/OSGeo/grass/blob/24469d8dcb73fdcec1c59713de4a8c82ce3eea3e/vector/v.info/main.c#L95-L96

nilason commented 1 month ago

Looks good to me now.

NishantBansal2003 commented 1 month ago

Could we move forward with this PR? CC: @cwhite911 @wenzeslaus @echoix @petrasovaa

Any suggestions are welcome.

petrasovaa commented 3 weeks ago

Looks like everything was addressed. I briefly tested it and looks good! Thank you @NishantBansal2003 !