v.what: Update JSON output format#6252
Conversation
Signed-off-by: Nishant Bansal <[email protected]>
|
After thinking more about this, I have a list of things to (re)consider here. Output attributes according to their typesIn the example, Make type names all lower caseMy guess is that the uppercase letter at the beginning of Point is a left over from a plain text output. I don't know that there would be any example for uppercase in type in GRASS. The parameter type has possible values point, line, boundary, centroid, area, face, kernel. [
{
"coordinate": {
"easting": 542690.40000000002,
"northing": 204802.70000000001
},
"map": "hospitals",
"mapset": "PERMANENT",
"type": "point",
"id": 22,
"categories": [
...No connection informationSeeing this together with JSON output of v.db.connect (#6077) made me think that we don't need to output connection information for every geometry id because you can get it from v.db.connect: [
{
"coordinate": {
"easting": 542690.40000000002,
"northing": 204802.70000000001
},
"map": "hospitals",
"mapset": "PERMANENT",
"type": "Point",
"id": 22,
"categories": [
{
"layer": 1,
"category": 22,
"driver": "sqlite",
"database": "/grassdata/nc_spm_08_grass7/PERMANENT/sqlite/sqlite.db",
"table": "hospitals",
"key_column": "cat",
"attributes": {
"cat": "22",
"OBJECTID": "22",
"AREA": "0",
"PERIMETER": "0",
"HLS_": "22",
"HLS_ID": "22",
"NAME": "Randolph Hospital",
"ADDRESS": "364 White Oak St",
"CITY": "Asheboro",
"ZIP": "27203",
"COUNTY": "Randolph",
"PHONE": "(336) 625-5151",
"CANCER": "yes",
"POLYGONID": "0",
"SCALE": "1",
"ANGLE": "1"
}
}
]
}
]v.db.connect output with #6077 (hand-written): [
{
"layer": 1,
"name": "hospitals",
"table": "hospitals",
"driver": "sqlite",
"database": "/grassdata/nc_spm_08_grass7/PERMANENT/sqlite/sqlite.db",
"key": "cat",
}
]
|
Signed-off-by: Nishant Bansal <[email protected]>
Signed-off-by: Nishant Bansal <[email protected]>
|
I apologize I didn't specify this earlier but we need to keep the old format and add the new one for backwards compatibility. With j flag you would get the old format (and that would be marked deprecated) and with format=json you get the new format. |
|
To start I think we should go with alternative 2, this will provide backwards compatibility and remove the connection details bloat from the json. |
Yeah, I actually thought about asking but then I assumed the previous JSON output might not have been correct, which is why we weren’t going with a backward-compatible solution. But never mind, I understand now that every change should be backward-compatible. That was a mistake on my part as well. Working on fixing it. |
Right, it's just that with one coordinate pair and one map it was still okay (100% valid JSON). |
|
one doubt I have is about alternative 2: is the |
Only for format=json, -j and -g should behave as if it would be enabled for backwards compatibility reasons. -j and -g can basically use the original code as is. For the default output (and also with format=plain), I would say you can implement -i because there are no backwards compatibility concerns here (the parsable format were -g and -j). |
Signed-off-by: Nishant Bansal <[email protected]>
… object found; -i requires -a
petrasovaa
left a comment
There was a problem hiding this comment.
I did some small adjustments and I think it's good to go! Thank you!
Once this is in, we need to also update the querying in the GUI to switch from -j flag.
Signed-off-by: Nishant Bansal <[email protected]>
The description attribute was repeated, but it was supposed to be label. Introduced in OSGeo#6252. Found by Coverity Scan.
The description attribute was repeated, but it was supposed to be label. Introduced in #6252. Found by Coverity Scan.
Fixes: #6226
This PR updates JSON output to the
v.whatmodule.The JSON output looks like:
[ { "coordinate": { "easting": 542690.40000000002, "northing": 204802.70000000001 }, "map": "hospitals", "mapset": "PERMANENT", "id": 22, "type": "point", "data": [ { "layer": 1, "category": 22, "attributes": { "cat": 22, "OBJECTID": 22, "AREA": 0, "PERIMETER": 0, "HLS_": 22, "HLS_ID": 22, "NAME": "Randolph Hospital", "ADDRESS": "364 White Oak St", "CITY": "Asheboro", "ZIP": "27203", "COUNTY": "Randolph", "PHONE": "(336) 625-5151", "CANCER": "yes", "POLYGONID": 0, "SCALE": 1, "ANGLE": 1 } } ] } ]This PR includes the following changes: