Skip to content

Commit

Permalink
g.proj: fix wkt output on Windows (#3306)
Browse files Browse the repository at this point in the history
Follows documentation of exportToWkt: Note that the returned WKT string should be freed with CPLFree() when no longer needed. It is the responsibility of the caller.
  • Loading branch information
petrasovaa authored and neteler committed Dec 17, 2023
1 parent c003c3f commit 61123da
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion general/g.proj/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <grass/glocale.h>
#include <grass/config.h>

#ifdef HAVE_OGR
#include <cpl_csv.h>
#endif

#include "local_proto.h"

static int check_xy(int shell);
Expand Down Expand Up @@ -274,7 +278,7 @@ void print_wkt(int esristyle, int dontprettify)

if (outwkt != NULL) {
fprintf(stdout, "%s\n", outwkt);
G_free(outwkt);
CPLFree(outwkt);
}
else
G_warning(_("Unable to convert to WKT"));
Expand Down
27 changes: 27 additions & 0 deletions general/g.proj/testsuite/test_g_proj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""g.proj tests
(C) 2023 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.
:author: Anna Petrasova
"""

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.gmodules import SimpleModule


class GProjWKTTestCase(TestCase):
"""Test g.proj with WKT output"""

def test_wkt_output(self):
"""Test if g.proj returns WKT"""
module = SimpleModule("g.proj", flags="w")
self.assertModule(module)
self.assertIn("PROJCRS", module.outputs.stdout)


if __name__ == "__main__":
test()

0 comments on commit 61123da

Please sign in to comment.