Parcourir la source

libgis, G_window_percentage_overlap(): account for N == S or E == W

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@70764 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz il y a 8 ans
Parent
commit
12b23b92e2
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      lib/gis/wind_overlap.c

+ 12 - 0
lib/gis/wind_overlap.c

@@ -94,6 +94,12 @@ double G_window_percentage_overlap(const struct Cell_head *window,
 	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 @@ double G_window_percentage_overlap(const struct Cell_head *window,
     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 @@ double G_window_percentage_overlap(const struct Cell_head *window,
 	    H += e - w;
 	}
     }
+    if (W == E) {
+	W = 0;
+	E = 1;
+    }
 
     return (H * V) / ((N - S) * (E - W));
 }