[GRASS-SVN] r72252 - in grass/branches/releasebranch_7_4/raster: r.external r.in.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Feb 17 05:34:52 PST 2018


Author: mmetz
Date: 2018-02-17 05:34:52 -0800 (Sat, 17 Feb 2018)
New Revision: 72252

Modified:
   grass/branches/releasebranch_7_4/raster/r.external/proj.c
   grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c
   grass/branches/releasebranch_7_4/raster/r.in.gdal/proj.c
Log:
r.in.gdal/r.external: add test if OGR spatial reference is NULL (backport trunk r72251)

Modified: grass/branches/releasebranch_7_4/raster/r.external/proj.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.external/proj.c	2018-02-17 13:33:50 UTC (rev 72251)
+++ grass/branches/releasebranch_7_4/raster/r.external/proj.c	2018-02-17 13:34:52 UTC (rev 72252)
@@ -35,9 +35,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);
 

Modified: grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c	2018-02-17 13:33:50 UTC (rev 72251)
+++ grass/branches/releasebranch_7_4/raster/r.in.gdal/main.c	2018-02-17 13:34:52 UTC (rev 72252)
@@ -476,11 +476,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.              */
     /* -------------------------------------------------------------------- */
@@ -580,6 +575,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/branches/releasebranch_7_4/raster/r.in.gdal/proj.c
===================================================================
--- grass/branches/releasebranch_7_4/raster/r.in.gdal/proj.c	2018-02-17 13:33:50 UTC (rev 72251)
+++ grass/branches/releasebranch_7_4/raster/r.in.gdal/proj.c	2018-02-17 13:34:52 UTC (rev 72252)
@@ -35,9 +35,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);
 



More information about the grass-commit mailing list