[GRASS-SVN] r72251 - in grass/trunk/raster: r.external r.in.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 17 05:33:51 PST 2018


Author: mmetz
Date: 2018-02-17 05:33:50 -0800 (Sat, 17 Feb 2018)
New Revision: 72251

Modified:
   grass/trunk/raster/r.external/proj.c
   grass/trunk/raster/r.in.gdal/main.c
   grass/trunk/raster/r.in.gdal/proj.c
Log:
r.in.gdal/r.external: add test if OGR spatial reference is NULL

Modified: grass/trunk/raster/r.external/proj.c
===================================================================
--- grass/trunk/raster/r.external/proj.c	2018-02-16 13:34:23 UTC (rev 72250)
+++ grass/trunk/raster/r.external/proj.c	2018-02-17 13:33:50 UTC (rev 72251)
@@ -39,9 +39,10 @@
 	OGRSpatialReferenceH hSRS;
 
 	hSRS = OSRNewSpatialReference(wkt);
-	GPJ_osr_to_grass(cellhd, &proj_info, &proj_units, hSRS, 0);
+	if (hSRS != NULL)
+	    GPJ_osr_to_grass(cellhd, &proj_info, &proj_units, hSRS, 0);
 
-	if (!OSRIsProjected(hSRS) && !OSRIsGeographic(hSRS)) {
+	if (!hSRS || (!OSRIsProjected(hSRS) && !OSRIsGeographic(hSRS))) {
 	    G_important_message(_("Input contains an invalid SRS. " 
 	                          "WKT definition:\n%s"), wkt);
 
@@ -59,7 +60,7 @@
 	    if (authname && *authname && strcmp(authname, "EPSG") == 0) {
 		authcode = OSRGetAuthorityCode(hSRS, authkey);
 		if (authcode && *authcode) {
-		    G_debug(0, "found EPSG:%s", authcode);
+		    G_debug(1, "found EPSG:%s", authcode);
 		    proj_epsg = G_create_key_value();
 		    G_set_key_value("epsg", authcode, proj_epsg);
 		}

Modified: grass/trunk/raster/r.in.gdal/main.c
===================================================================
--- grass/trunk/raster/r.in.gdal/main.c	2018-02-16 13:34:23 UTC (rev 72250)
+++ grass/trunk/raster/r.in.gdal/main.c	2018-02-17 13:33:50 UTC (rev 72251)
@@ -472,11 +472,6 @@
     check_projection(&cellhd, hDS, parm.outloc->answer, flag_c->answer,
                      flag_o->answer, flag_j->answer);
 
-    if (GDALGetRasterCount(hDS) > 1) {
-	G_message(_("Importing %d raster bands..."),
-		  GDALGetRasterCount(hDS));
-    }
-
     /* -------------------------------------------------------------------- */
     /*      Set the active window to match the available data.              */
     /* -------------------------------------------------------------------- */
@@ -576,6 +571,11 @@
 	    n_bands++;
     }
 
+    if (GDALGetRasterCount(hDS) > 1 && n_bands != 1) {
+	G_message(_("Importing %d raster bands..."),
+		  (n_bands > 1 ? n_bands : GDALGetRasterCount(hDS)));
+    }
+
     if ((GDALGetRasterCount(hDS) > 1 && n_bands != 1)
 	|| GDALGetGCPCount(hDS) > 0)
 	force_imagery = TRUE;

Modified: grass/trunk/raster/r.in.gdal/proj.c
===================================================================
--- grass/trunk/raster/r.in.gdal/proj.c	2018-02-16 13:34:23 UTC (rev 72250)
+++ grass/trunk/raster/r.in.gdal/proj.c	2018-02-17 13:33:50 UTC (rev 72251)
@@ -39,9 +39,10 @@
 	OGRSpatialReferenceH hSRS;
 
 	hSRS = OSRNewSpatialReference(wkt);
-	GPJ_osr_to_grass(cellhd, &proj_info, &proj_units, hSRS, 0);
+	if (hSRS != NULL)
+	    GPJ_osr_to_grass(cellhd, &proj_info, &proj_units, hSRS, 0);
 
-	if (!OSRIsProjected(hSRS) && !OSRIsGeographic(hSRS)) {
+	if (!hSRS || (!OSRIsProjected(hSRS) && !OSRIsGeographic(hSRS))) {
 	    G_important_message(_("Input contains an invalid SRS. " 
 	                          "WKT definition:\n%s"), wkt);
 
@@ -59,7 +60,7 @@
 	    if (authname && *authname && strcmp(authname, "EPSG") == 0) {
 		authcode = OSRGetAuthorityCode(hSRS, authkey);
 		if (authcode && *authcode) {
-		    G_debug(0, "found EPSG:%s", authcode);
+		    G_debug(1, "found EPSG:%s", authcode);
 		    proj_epsg = G_create_key_value();
 		    G_set_key_value("epsg", authcode, proj_epsg);
 		}



More information about the grass-commit mailing list