Skip to content

Commit

Permalink
add gmt, wms to output
Browse files Browse the repository at this point in the history
  • Loading branch information
kritibirda26 committed Aug 1, 2024
1 parent f77b779 commit a3b9209
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
36 changes: 28 additions & 8 deletions general/g.region/printwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,36 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag,
}

/* flag.gmt_style */
if ((print_flag & PRINT_GMT) && format != JSON)
fprintf(stdout, "%s/%s/%s/%s\n", west, east, south, north);
if (print_flag & PRINT_GMT) {
char gmt[120];
switch (format) {
case JSON:
snprintf(gmt, 120, "%s/%s/%s/%s", west, east, south, north);
json_object_set_string(root_object, "GMT", gmt);
break;
default:
fprintf(stdout, "%s/%s/%s/%s\n", west, east, south, north);
break;
}
}

/* flag.wms_style */
if ((print_flag & PRINT_WMS) && format != JSON) {
G_format_northing(window->north, north, -1);
G_format_northing(window->south, south, -1);
G_format_easting(window->east, east, -1);
G_format_easting(window->west, west, -1);
fprintf(stdout, "bbox=%s,%s,%s,%s%s", west, south, east, north, sep);
if (print_flag & PRINT_WMS) {
char wms[150];
switch (format) {
case JSON:
snprintf(wms, 150, "bbox=%s,%s,%s,%s", west, south, east, north);
json_object_set_string(root_object, "WMS", wms);
break;
default:
G_format_northing(window->north, north, -1);
G_format_northing(window->south, south, -1);
G_format_easting(window->east, east, -1);
G_format_easting(window->west, west, -1);
fprintf(stdout, "bbox=%s,%s,%s,%s%s", west, south, east, north,
sep);
break;
}
}

/* flag.nangle */
Expand Down
4 changes: 3 additions & 1 deletion general/g.region/testsuite/test_g_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def test_format_json(self):
"depths": 10,
"cells": 1010600,
"cells3": 2526500,
"GMT": "120000/935000/10000/320000",
"WMS": "bbox=120000,10000,935000,320000",
}

output = call_module("g.region", flags="p", format="json")
output = call_module("g.region", flags="ptw", format="json")
output_json = json.loads(output)

expected_ellps = expected.pop("ellipsoid").split(" ")
Expand Down

0 comments on commit a3b9209

Please sign in to comment.