[GRASS-SVN] r70764 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 17 14:29:45 PDT 2017


Author: mmetz
Date: 2017-03-17 14:29:45 -0700 (Fri, 17 Mar 2017)
New Revision: 70764

Modified:
   grass/trunk/lib/gis/wind_overlap.c
Log:
libgis, G_window_percentage_overlap(): account for N == S or E == W

Modified: grass/trunk/lib/gis/wind_overlap.c
===================================================================
--- grass/trunk/lib/gis/wind_overlap.c	2017-03-17 20:54:57 UTC (rev 70763)
+++ grass/trunk/lib/gis/wind_overlap.c	2017-03-17 21:29:45 UTC (rev 70764)
@@ -94,6 +94,12 @@
 	s = S;
     V = n - s;
 
+    if (N == S) {
+	V = (N < window->north && N > window->south);
+	N = 1;
+	S = 0;
+    }
+
     if (V <= 0.0)
 	return 0.0;
 
@@ -114,6 +120,8 @@
     if ((w = window->west) < W)
 	w = W;
     H = e - w;
+    if (W == E)
+	H = (E > window->west && E < window->east);
     if (H <= 0.0)
 	return 0.0;
 
@@ -134,6 +142,10 @@
 	    H += e - w;
 	}
     }
+    if (W == E) {
+	W = 0;
+	E = 1;
+    }
 
     return (H * V) / ((N - S) * (E - W));
 }



More information about the grass-commit mailing list