DEM.Net icon indicating copy to clipboard operation
DEM.Net copied to clipboard

Wrong y direction in HyperbolicInterpolator

Open g0ro opened this issue 4 years ago • 3 comments

https://github.com/dem-net/DEM.Net/blob/168cd8e0e277793227f9cacd1cd26310ba495928/DEM.Net.Core/Services/Interpolation/HyperbolicInterpolator.cs#L44

If x is from west to east and y is from north to south, then (0,0) point should be at NW, not SW

g0ro avatar Sep 29 '21 12:09 g0ro

Hi @g0ro, thanks for reporting this. Can you submit a test case for that ? Which data set did you use ?

xfischer avatar Sep 29 '21 12:09 xfischer

It does not depend on a dataset. HyperbolicInterpolator's y is just inversed compared to BilinearInterpolator. The later seems to be right.

To test it, we may get height values of corner points, they should be the same:


        private static void TestInterpolators()
        {
            var iplBl = new BilinearInterpolator();
            var iplHb = new HyperbolicInterpolator();

            for (var x = 0; x<=1; x++)
            {
                for (var y = 0; y <= 1; y++)
                {
                    var hBl = iplBl.Interpolate(1, 2, 3, 4, x, y);
                    var hHb = iplHb.Interpolate(1, 2, 3, 4, x, y);
                    Console.WriteLine($"x={x} y={y} hBl={hBl} hHb={hHb}");
                }

            }

        }

But the result is inverted:

x=0 y=0 hBl=3 hHb=1
x=0 y=1 hBl=1 hHb=3
x=1 y=0 hBl=4 hHb=2
x=1 y=1 hBl=2 hHb=4

g0ro avatar Oct 01 '21 12:10 g0ro

OK thanks for pointing this out. Will fix it

xfischer avatar Oct 01 '21 12:10 xfischer