<commit_before>/**
 * flights
 *
 * Array of flight objects. (see addFlight method)
 */
var flights = [];


/**
 * top_flight
 *
 * Defines which flight should be handled first
 */
var top_flight = 0;


/**
 * barogram
 *
 * Holds the Raphael instance
 */
var barogram;

/**
 * barogram_t and barogram_h
 *
 * {Array(Array(double))} - contains time and height values for the barogram.
 */
var barogram_t = [];
var barogram_h = [];


/**
 * colors
 *
 * List of colors for flight path display
 */
//var colors = ['#bf2fa2', '#2f69bf', '#d63a35', '#d649ff'];
var colors = ['#004bbd', '#bf0099', '#cf7c00', '#ff0000', '#00c994'];

/**
 * Function initOpenLayers
 *
 * Initialize the map and add airspace and flight path layers.
 */

function initFlightLayer() {
  var default_style = new OpenLayers.Style({
    strokeColor: "${color}",
    strokeWidth: 2
  });

  var plane_style = new OpenLayers.Style({
    // Set the external graphic and background graphic images.
    externalGraphic: "${getGraphic}",
    // Makes sure the background graphic is placed correctly relative
    // to the external graphic.
    graphicXOffset: -(40/2),
    graphicYOffset: -8,
    graphicWidth: 40,
    graphicHeight: 24,
    rotation: "${rotation}",
    // Set the z-indexes of both graphics to make sure the background
    // graphics stay in the background (shadows on top of markers looks
    // odd; let's not do that).
    graphicZIndex: 2000
  }, {
    context: {
      getGraphic: function(feature) {
        var msie_8 = $.browser.msie && (parseInt($.browser.version, 10) < 9);
        var ghost_glider = msie_8?"/images/glider_symbol_ghost_msie.png":"/images/glider_symbol_ghost.png";
        var normal_glider = msie_8?"/images/glider_symbol_msie.png":"/images/glider_symbol.png";
        return feature.attributes["ghost"]?ghost_glider:normal_glider;
      }
    }
  });

  var flightPathLayer = new OpenLayers.Layer.Vector("Flight", {
    styleMap: new OpenLayers.StyleMap({
      'default': default_style,
      'plane': plane_style
    })
  });

  map.addLayer(flightPathLayer);

  map.events.register("move", this, function() {
    initRedrawLayer(flightPathLayer);
  });
};

/**
 * Function: initRedrawLayer
 *
 * initiates the redraw of a layer
 */
function initRedrawLayer(layer) {
  if (this.timer)
    return;

  this.timer = window.setTimeout(function() {
    this.timer = null; layer.redraw();
  }, 50);
};

/**
 * Function: addFlight
 *
 * Add a flight to the map and barogram.
 *
 * Parameters:
 * sfid - {int} SkyLines flight ID
 * _lonlat - {String} Google polyencoded string of geolocations (lon + lat, WSG 84)
 * _levels - {String} Google polyencoded string of levels of detail<commit_msg>public.js.flight: redraw layer instantly when requested<commit_after>/**
 * flights
 *
 * Array of flight objects. (see addFlight method)
 */
var flights = [];


/**
 * top_flight
 *
 * Defines which flight should be handled first
 */
var top_flight = 0;


/**
 * barogram
 *
 * Holds the Raphael instance
 */
var barogram;

/**
 * barogram_t and barogram_h
 *
 * {Array(Array(double))} - contains time and height values for the barogram.
 */
var barogram_t = [];
var barogram_h = [];


/**
 * colors
 *
 * List of colors for flight path display
 */
//var colors = ['#bf2fa2', '#2f69bf', '#d63a35', '#d649ff'];
var colors = ['#004bbd', '#bf0099', '#cf7c00', '#ff0000', '#00c994'];

/**
 * Function initOpenLayers
 *
 * Initialize the map and add airspace and flight path layers.
 */

function initFlightLayer() {
  var default_style = new OpenLayers.Style({
    strokeColor: "${color}",
    strokeWidth: 2
  });

  var plane_style = new OpenLayers.Style({
    // Set the external graphic and background graphic images.
    externalGraphic: "${getGraphic}",
    // Makes sure the background graphic is placed correctly relative
    // to the external graphic.
    graphicXOffset: -(40/2),
    graphicYOffset: -8,
    graphicWidth: 40,
    graphicHeight: 24,
    rotation: "${rotation}",
    // Set the z-indexes of both graphics to make sure the background
    // graphics stay in the background (shadows on top of markers looks
    // odd; let's not do that).
    graphicZIndex: 2000
  }, {
    context: {
      getGraphic: function(feature) {
        var msie_8 = $.browser.msie && (parseInt($.browser.version, 10) < 9);
        var ghost_glider = msie_8?"/images/glider_symbol_ghost_msie.png":"/images/glider_symbol_ghost.png";
        var normal_glider = msie_8?"/images/glider_symbol_msie.png":"/images/glider_symbol.png";
        return feature.attributes["ghost"]?ghost_glider:normal_glider;
      }
    }
  });

  var flightPathLayer = new OpenLayers.Layer.Vector("Flight", {
    styleMap: new OpenLayers.StyleMap({
      'default': default_style,
      'plane': plane_style
    })
  });

  map.addLayer(flightPathLayer);

  map.events.register("move", this, function() {
    initRedrawLayer(flightPathLayer);
  });
};

/**
 * Function: initRedrawLayer
 *
 * initiates the redraw of a layer
 */
function initRedrawLayer(layer) {
  // Run this function only every 50ms to save some computing power.
  if (this.initRedrawLayerRunning) return;

  this.initRedrawLayerRunning = true;
  setTimeout(function() { this.initRedrawLayerRunning = false; }, 50);

  layer.redraw();
};

/**
 * Function: addFlight
 *
 * Add a flight to the map and barogram.
 *
 * Parameters:
 * sfid - {int} SkyLines flight ID
 * _lonlat - {String} Google polyencoded string of geolocations (lon + lat, WSG 84)
 * _levels - {String} Google polyencoded string of levels of detail
{'fraction_non_alphanumeric': 0.1332133213321332, 'fraction_numerical': 0.020162016201620163, 'mean_word_length': 3.347417840375587, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4012273', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1767, 'n_words': 500}