src/AircraftTrajectories/Models/TemporalGrid/Contours/Contour.cs
/// <summary>
/// Creates contours based on noise data and given grid
/// </summary>
/// <param name="data"></param>
/// <param name="hgrid"></param>
/// <param name="vgrid"></param>
/// <returns></returns>
Creates contours based on noise data and given grid
Creates contours based on noise data and given grid
public static IEnumerable<Contour> CreateContours(double[][] data, out IEnumerable<ContourPoint>[][] hgrid, out IEnumerable<ContourPoint>[][] vgrid)
        {
            if (data == null)
            {
                hgrid = vgrid = null;
                return null;
            }
            hgrid = new IEnumerable<ContourPoint>[data.Length][];
            vgrid = new IEnumerable<ContourPoint>[data.Length - 1][];
            for (int x = 0; x < data.Length; x++)
            {
                if (x != data.Length - 1)
                {
                    vgrid[x] = new IEnumerable<ContourPoint>[data[x].Length];
                }
                hgrid[x] = new IEnumerable<ContourPoint>[data[x].Length - 1];
                for (int y = 0; y < data[x].Length; y++)
                {
                    var value = data[x][y];
                    if (x != 0)
                    {
                        vgrid[x - 1][y] = Enumerable.Range(Math.Min((int)value, (int)data[x - 1][y]) + 1, Math.Abs((int)data[x - 1][y] - (int)value))
                            .Select(v => new ContourPoint
                            {
                                Coordinate = new Coordinate(x - 1, y),
                                Location = new
                                    Point((x - (v - value) / (data[x - 1][y] - value)), y),
                                Direction = (value > data[x - 1][y]) ? ContourDirection.East : ContourDirection.West,
                                Value = v
                            }).ToList();
                    }
                    if (y < data[x].Length - 1)
                    {
                        hgrid[x][y] = Enumerable.Range(Math.Min((int)value, (int)data[x][y + 1]) + 1, Math.Abs((int)data[x][y + 1] - (int)value))
                            .Select(v => new ContourPoint
                            {
                                Coordinate = new Coordinate(x, y),
                                Location = new Point(x, (y + (v - value) / (data[x][y + 1] - value))),
                                Direction = (value > data[x][y + 1]) ? ContourDirection.South : ContourDirection.North,
                                Value = v
                            }).ToList();
                    }
                }
            }
            return GenerateContours(vgrid, hgrid);
        }
public static IEnumerable < Contour > CreateContours ( double [ ] [ ] data , out IEnumerable < ContourPoint > [ ] [ ] hgrid , out IEnumerable < ContourPoint > [ ] [ ] vgrid ) { if ( data == null ) { hgrid = vgrid = null ; return null ; } hgrid = new IEnumerable < ContourPoint > [ data . Length ] [ ] ; vgrid = new IEnumerable < ContourPoint > [ data . Length - 1 ] [ ] ; for ( int x = 0 ; x < data . Length ; x ++ ) { if ( x != data . Length - 1 ) { vgrid [ x ] = new IEnumerable < ContourPoint > [ data [ x ] . Length ] ; } hgrid [ x ] = new IEnumerable < ContourPoint > [ data [ x ] . Length - 1 ] ; for ( int y = 0 ; y < data [ x ] . Length ; y ++ ) { var value = data [ x ] [ y ] ; if ( x != 0 ) { vgrid [ x - 1 ] [ y ] = Enumerable . Range ( Math . Min ( ( int ) value , ( int ) data [ x - 1 ] [ y ] ) + 1 , Math . Abs ( ( int ) data [ x - 1 ] [ y ] - ( int ) value ) ) . Select ( v => new ContourPoint { Coordinate = new Coordinate ( x - 1 , y ) , Location = new Point ( ( x - ( v - value ) / ( data [ x - 1 ] [ y ] - value ) ) , y ) , Direction = ( value > data [ x - 1 ] [ y ] ) ? ContourDirection . East : ContourDirection . West , Value = v } ) . ToList ( ) ; } if ( y < data [ x ] . Length - 1 ) { hgrid [ x ] [ y ] = Enumerable . Range ( Math . Min ( ( int ) value , ( int ) data [ x ] [ y + 1 ] ) + 1 , Math . Abs ( ( int ) data [ x ] [ y + 1 ] - ( int ) value ) ) . Select ( v => new ContourPoint { Coordinate = new Coordinate ( x , y ) , Location = new Point ( x , ( y + ( v - value ) / ( data [ x ] [ y + 1 ] - value ) ) ) , Direction = ( value > data [ x ] [ y + 1 ] ) ? ContourDirection . South : ContourDirection . North , Value = v } ) . ToList ( ) ; } } } return GenerateContours ( vgrid , hgrid ) ; }
Creates contours based on noise data and given grid
Creates contours based on noise data and given grid
None
data
double[][]
None
IEnumerable<ContourPoint>[][]
out
hgrid
None
vgrid
None