Skip to content

Commit

Permalink
document json format for v.info and add changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
kritibirda26 committed Jun 7, 2024
1 parent 2b4d017 commit 132c4d3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
1 change: 0 additions & 1 deletion vector/v.info/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ int main(int argc, char *argv[])
if (format == JSON) {
root_value = json_value_init_object();
root_object = json_value_get_object(root_value);
json_set_float_serialization_format("%lf");
}

/* try to open head-only on level 2 */
Expand Down
10 changes: 8 additions & 2 deletions vector/v.info/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ void print_shell(struct Map_info *Map, const char *field_opt,
Vect_get_finfo_geometry_type(Map));
break;
case JSON:
// fixme: add format=%,%s
json_object_set_string(root_object, "format",
Vect_maptype_info(Map));
json_object_set_string(root_object, "format-detail",
Vect_get_finfo_format_info(Map));
json_object_set_string(root_object, "ogr_layer",
Vect_get_finfo_layer_name(Map));
json_object_set_string(root_object, "ogr_dsn",
Expand Down Expand Up @@ -337,7 +340,10 @@ void print_shell(struct Map_info *Map, const char *field_opt,
Vect_get_finfo_geometry_type(Map));
break;
case JSON:
// fixme: add format=%,%s
json_object_set_string(root_object, "format",
Vect_maptype_info(Map));
json_object_set_string(root_object, "format-detail",
Vect_get_finfo_format_info(Map));
json_object_set_string(root_object, "pg_table",
Vect_get_finfo_layer_name(Map));
json_object_set_string(root_object, "pg_dbname",
Expand Down
1 change: 0 additions & 1 deletion vector/v.info/testsuite/test_vinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ def test_json(self):
# therefore only check for their presence in the JSON output
# and not exact values
remove_fields = [
"location",
"project",
"database",
"source_date",
Expand Down
43 changes: 43 additions & 0 deletions vector/v.info/v.info.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,49 @@ <h3>Basic metadata information in shell script style</h3>
bottom=0.000000
</pre></div>

<h3>Output in JSON format</h3>
<div class="code"><pre>
{
"name": "geology",
"mapset": "PERMANENT",
"project": "nc_spm_08_grass7",
"database": "\/grassdata",
"title": "North Carolina geology map (polygon map)",
"scale": 1,
"creator": "helena",
"organization": "NC OneMap",
"source_date": "Mon Nov 6 15:48:53 2006",
"timestamp": null,
"format": "native",
"level": 2,
"num_dblinks": 1,
"attribute_layer_number": 1,
"attribute_layer_name": "geology",
"attribute_database": "\/grassdata\/nc_spm_08_grass7\/PERMANENT\/sqlite\/sqlite.db",
"attribute_database_driver": "sqlite",
"attribute_table": "geology",
"attribute_primary_key": "cat",
"projection": "Lambert Conformal Conic",
"digitization_threshold": 0,
"comment": "",
"north": 318117.43741634465,
"south": 10875.827232091688,
"east": 930172.31282271142,
"west": 123971.19498978264,
"top": 0,
"bottom": 0,
"nodes": 2724,
"points": 0,
"lines": 0,
"boundaries": 3649,
"centroids": 1832,
"areas": 1832,
"islands": 907,
"primitives": 5481,
"map3d": false
}
</pre></div>

<h2>PYTHON</h2>

See <em><a href="https://grass.osgeo.org/grass-stable/manuals/libpython/">Python
Expand Down

0 comments on commit 132c4d3

Please sign in to comment.