[GRASS-SVN] r74188 - grass/trunk/general/g.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 8 02:48:45 PST 2019


Author: mmetz
Date: 2019-03-08 02:48:45 -0800 (Fri, 08 Mar 2019)
New Revision: 74188

Modified:
   grass/trunk/general/g.proj/main.c
Log:
g.proj: +error handling with PROJ 6

Modified: grass/trunk/general/g.proj/main.c
===================================================================
--- grass/trunk/general/g.proj/main.c	2019-03-08 08:40:26 UTC (rev 74187)
+++ grass/trunk/general/g.proj/main.c	2019-03-08 10:48:45 UTC (rev 74188)
@@ -268,13 +268,12 @@
 	proj_crs_info = proj_get_crs_info_list_from_database(NULL, listcodes->answer, NULL, &crs_cnt);
 	if (crs_cnt < 1)
 	    G_fatal_error(_("No codes found for authority %s"),
-		          listcodes->answer;
+		          listcodes->answer);
 		
 	for (i = 0; i < crs_cnt; i++) {
-	    char *proj_definition;
+	    const char *proj_definition;
 	    PJ *pj;
 
-
 	    pj = proj_create_from_database(NULL,
 	                                   proj_crs_info[i]->auth_name,
 	                                   proj_crs_info[i]->code,
@@ -281,10 +280,23 @@
 					   PJ_CATEGORY_CRS,
 					   0, NULL);
 	    proj_definition = proj_as_proj_string(NULL, pj, PJ_PROJ_5, NULL);
-
-	    fprintf(stdout, "%s|%s|%s\n", proj_crs_info[i]->code,
-					  proj_crs_info[i]->name,
-					  proj_definition);
+	    if (!proj_definition) {
+		int err = proj_errno(pj);
+		
+		if (err) {
+		    G_warning(_("Unable to fetch proj string: %s"),
+			      proj_errno_string(err));
+		}
+		else {
+		    G_warning(_("Unable to fetch proj string: unknown error"));
+		}
+	    }
+	    else {
+		fprintf(stdout, "%s|%s|%s\n", proj_crs_info[i]->code,
+					      proj_crs_info[i]->name,
+					      proj_definition);
+	    }
+	    proj_destroy(pj);
 	}
 #else
 	char pathname[GPATH_MAX];



More information about the grass-commit mailing list