From 2d521c53117a56353e0b32b12d46182a6f4a4f39 Mon Sep 17 00:00:00 2001
From: Anton Kudryashov <qubabox@mail.ru>
Date: Wed, 23 Nov 2016 14:14:16 +0300
Subject: [PATCH] fixed specific coordinates method

---
 WindStressPRM/WindStressPRM.cs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/WindStressPRM/WindStressPRM.cs b/WindStressPRM/WindStressPRM.cs
index a9947ee..8538d20 100644
--- a/WindStressPRM/WindStressPRM.cs
+++ b/WindStressPRM/WindStressPRM.cs
@@ -284,13 +284,15 @@ namespace WindStressPRM
             Coordinate firstCoordinate = Input.ClimateCells.Origin;
             Index lastIndex = new Index( Input.ClimateCells.RowsCount() - 1, Input.ClimateCells.ColumnCount() - 1);
             Coordinate lastCoordinate = Input.ClimateCells.CellToProjection(lastIndex);
-            for (double x = firstCoordinate.X; x <= lastCoordinate.X; 
-                x += Math.Sign(lastCoordinate.X - firstCoordinate.X)*Input.Distance35kVCheck)
+            double x = firstCoordinate.X;
+            double y = firstCoordinate.Y;
+            while (Math.Sign(lastCoordinate.X - firstCoordinate.X) * (lastCoordinate.X - x) >= 0)
             {
-                for (double y = firstCoordinate.Y; y <= lastCoordinate.Y;
-                y += Math.Sign(lastCoordinate.Y - firstCoordinate.Y) * Input.Distance35kVCheck)
+                while (Math.Sign(lastCoordinate.Y - firstCoordinate.Y) * (lastCoordinate.Y - y) >= 0)
                 {
                     Coordinate current = new Coordinate(x, y);
+                    y += Math.Sign(lastCoordinate.Y - firstCoordinate.Y) * Input.Distance35kVCheck;
+
                     double wind = interpol<ClimateCell>(current, Input.ClimateCells, delegate(ClimateCell cell) { return cell.Wind10; });
                     double u = interpol<PrognosticCell>(current, Input.PrognosticCells, delegate(PrognosticCell cell) { return cell.VelocityX; });
                     double v = interpol<PrognosticCell>(current, Input.PrognosticCells, delegate(PrognosticCell cell) { return cell.VelocityY; });
@@ -306,6 +308,7 @@ namespace WindStressPRM
                         list.Add(current);
                     }
                 }
+                x += Math.Sign(lastCoordinate.X - firstCoordinate.X) * Input.Distance35kVCheck;
             }
             return list;
         }
-- 
GitLab