src/AircraftTrajectories/Models/Visualisation/KML/AnimationSections/ContourKMLAnimator.cs
/// <summary>
///  Return a string in KML format containing all pre animation definitions 
///  that are required for the contour animation
/// </summary>
/// <returns></returns>
Return a string in KML format containing all pre animation definitions
that are required for the contour animation
Return a string in KML format containing all pre animation definitions that are required for the contour animation
public string KMLSetup()
        {
            if (_gradientContours.Count == 0 && _highlightedContours.Count == 0) { return ""; }
            _numberOfContours = HighestContourValue - LowestContourValue + 1;
            DetermineNumberOfContoursPerValue();
            Color c1 = Color.FromArgb(0, 20, 240, 0);
            Color c2 = Color.FromArgb(150, 20, 0, 255);
            Color[] colors = interpolateColors(c1, c2, _numberOfContours);
            string contourSetup = @"
<Folder> 
 <open>0</open>
 <name>Contours</name>
            ";
            for (int i = 0; i < _numberOfContours; i++)
            {
                int value = LowestContourValue + i;
                if (!_highlightedContours.Contains(value) && !_gradientContours.Contains(value)) { continue; }
                int occurrences;
                maxNumberOfOccurrences.TryGetValue(value, out occurrences);
                if (occurrences == 0) { continue;  }
                var c = colors[i];
                string altitudeMode = (AltitudeOffset) ? "<altitudeMode>absolute</altitudeMode>" : "";
                contourSetup += @"
<Style id='contour_style" + i + @"'>
    <LineStyle>";
                if (!_highlightedContours.Contains(value))
                {
                    contourSetup += "<color>00000000</color>";
                }
                else
                {
                    contourSetup += "<color>" + string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", Math.Min(255, c.A + 150), c.R, c.G, c.B) + "</color>";
                }
                contourSetup += @"
        <width>2</width>
    </LineStyle>
    <PolyStyle>";
                if (_gradientContours.Contains(value))
                {
                    contourSetup += "<color>" + string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", c.A, c.R, c.G, c.B) + "</color>";
                }
                else 
                {
                    contourSetup += "<color>00000000</color>";
                }
                contourSetup += @"
    </PolyStyle>
    <IconStyle>
        <scale>0</scale>
    </IconStyle>
    <LabelStyle>
        <color>FFFFFFFF</color>
        <scale>0.40</scale>
    </LabelStyle>
</Style>
                ";
                for (int o = 0; o < occurrences; o++)
                {
                    contourSetup += @"
<Placemark id='contour_placemark" + i+"_"+o + @"'>";
                    contourSetup += "<name>" + value + "dB</name>" + @"
    <styleUrl>#contour_style" + i + @"</styleUrl>
    <MultiGeometry>
        <Polygon>
            " + altitudeMode + @"
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing id='contour" + i+"_"+o + @"'>
                    <coordinates></coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
        <Point id='contourPoint" + i+"_"+o + @"'>
            <Coordinates></Coordinates>
        </Point>
    </MultiGeometry>
</Placemark>
                    ";
                }
            }
            contourSetup += "</Folder>";
            return contourSetup;
        }
public string KMLSetup ( ) { if ( _gradientContours . Count == 0 && _highlightedContours . Count == 0 ) { return " " ; } _numberOfContours = HighestContourValue - LowestContourValue + 1 ; DetermineNumberOfContoursPerValue ( ) ; Color c1 = Color . FromArgb ( 0 , 20 , 240 , 0 ) ; Color c2 = Color . FromArgb ( 150 , 20 , 0 , 255 ) ; Color [ ] colors = interpolateColors ( c1 , c2 , _numberOfContours ) ; string contourSetup = @"
<Folder> 
 <open>0</open>
 <name>Contours</name>
            " ; for ( int i = 0 ; i < _numberOfContours ; i ++ ) { int value = LowestContourValue + i ; if ( ! _highlightedContours . Contains ( value ) && ! _gradientContours . Contains ( value ) ) { continue ; } int occurrences ; maxNumberOfOccurrences . TryGetValue ( value , out occurrences ) ; if ( occurrences == 0 ) { continue ; } var c = colors [ i ] ; string altitudeMode = ( AltitudeOffset ) ? " " : " " ; contourSetup += @"
<Style id='contour_style" + i + @"'>
    <LineStyle>" ; if ( ! _highlightedContours . Contains ( value ) ) { contourSetup += " " ; } else { contourSetup += " " + string . Format ( " " , Math . Min ( 255 , c . A + 150 ) , c . R , c . G , c . B ) + " " ; } contourSetup += @"
        <width>2</width>
    </LineStyle>
    <PolyStyle>" ; if ( _gradientContours . Contains ( value ) ) { contourSetup += " " + string . Format ( " " , c . A , c . R , c . G , c . B ) + " " ; } else { contourSetup += " " ; } contourSetup += @"
    </PolyStyle>
    <IconStyle>
        <scale>0</scale>
    </IconStyle>
    <LabelStyle>
        <color>FFFFFFFF</color>
        <scale>0.40</scale>
    </LabelStyle>
</Style>
                " ; for ( int o = 0 ; o < occurrences ; o ++ ) { contourSetup += @"
<Placemark id='contour_placemark" + i + " " + o + @"'>" ; contourSetup += " " + value + " " + @"
    <styleUrl>#contour_style" + i + @"</styleUrl>
    <MultiGeometry>
        <Polygon>
            " + altitudeMode + @"
            <tessellate>1</tessellate>
            <outerBoundaryIs>
                <LinearRing id='contour" + i + " " + o + @"'>
                    <coordinates></coordinates>
                </LinearRing>
            </outerBoundaryIs>
        </Polygon>
        <Point id='contourPoint" + i + " " + o + @"'>
            <Coordinates></Coordinates>
        </Point>
    </MultiGeometry>
</Placemark>
                    " ; } } contourSetup += " " ; return contourSetup ; }
Return a string in KML format containing all pre animation definitions
that are required for the contour animation
Return a string in KML format containing all pre animation definitions that are required for the contour animation
// Define contour colors
None