<commit_before>/**
 * OpenLayers 3 map
 *
 * events:
 *   maprotation({rotation: <rad>})
 */

var Map = {};

// topics (key = topic name)
Map.topics = {};
// current topic
Map.topic = null;
// ordered layers (key = layer name)
Map.layers = {};
// OpenLayers 3 map object
Map.map = null;
// OpenLayers 3 geolocation object
Map.geolocation = null;
// OpenLayers 3 DeviceOrientation object
Map.deviceOrientation = null;
// OpenLayers 3 ScaleLine control
Map.scaleLine = null;
// WMS selection
Map.selection = null;
// last click position
Map.lastClickPos = null;
// click marker
Map.clickMarker = null;

Map.useTiledWMS = false;

Map.createMap = function(featureInfoCallback) {
  // map options
  var useCanvasRenderer = true; // FIXME: disable WEBGL renderer for now

  // browser specific map setup
  if (navigator.userAgent.match(/Mozilla.+Android.+Safari/)) {
    // Android Safari
    // Mozilla/5.0 (Linux; U; Android 4.0.3; en-gb; Transformer TF101 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

    // SingleImageWMS is not refreshed on pinch zoom
    Map.useTiledWMS = true;
  }
  else if (navigator.userAgent.match(/Mozilla.+Android.+Firefox/)) {
    // Android Firefox
    // Mozilla/5.0 (Android; Tablet; rv:21.0) Gecko/21.0 Firefox/21.0

    // SingleImageWMS is not refreshed on pinch zoom
    Map.useTiledWMS = true;
    // WEBGL renderer renders GL WMS as black image
    useCanvasRenderer = true;
  }

  // override from URL params
  if (UrlParams.params.tiledWms != undefined) {
    Map.useTiledWMS = UrlParams.params.tiledWms;
  }

  var projection = ol.proj.configureProj4jsProjection({
    code: 'EPSG:21781',
    extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864]
  });

  var renderers = ol.RendererHints.createFromQueryData();
  if (useCanvasRenderer) {
    renderers = [ol.RendererHint.CANVAS, ol.RendererHint.WEBGL, ol.RendererHint.DOM];
  }

  Map.map = new ol.Map({
    layers: [],
    renderers: renderers,
    target: 'map',
    view: new ol.View2D({
      projection: projection,
      center: [660000, 190000],
      zoom: 2
    }),
    controls:[]
  });

  Map.map.getView().on('change:rotation', function() {
    $.event.trigger({type: 'maprotation', rotation: Map.map.getView().getRotation()});
  });

  // feature info
  if (featureInfoCallback != null) {
    Map.map.on('click', function(e) {
      Map.lastClickPos = e.getCoordinate();

      /* FIXME: enable this block for production
      Map.map.getFeatureInfo({
        pixel: e.getPixel(),
        success: featureInfoCallback
      });
      */
      /* FIXME: use static xml file for demonstration purposes, to avoid cross domain issues */
      $.ajax({
        url: "src/get_feature_info_response.xml",
        dataType: 'text'
      }).done(function(data, status) {
        featureInfoCallback([data]);
      });
      /* END */
    });
  }
};

Map.setTopicLayer = function() {
  // remove old layer
  Map.map.removeLayer(Map.map.getLayers().getAt(0));

  // add new layer
  var wmsParams = {<commit_msg>no feature info on double click in map<commit_after>/**
 * OpenLayers 3 map
 *
 * events:
 *   maprotation({rotation: <rad>})
 */

var Map = {};

// topics (key = topic name)
Map.topics = {};
// current topic
Map.topic = null;
// ordered layers (key = layer name)
Map.layers = {};
// OpenLayers 3 map object
Map.map = null;
// OpenLayers 3 geolocation object
Map.geolocation = null;
// OpenLayers 3 DeviceOrientation object
Map.deviceOrientation = null;
// OpenLayers 3 ScaleLine control
Map.scaleLine = null;
// WMS selection
Map.selection = null;
// last click position
Map.lastClickPos = null;
// click marker
Map.clickMarker = null;

Map.useTiledWMS = false;

Map.createMap = function(featureInfoCallback) {
  // map options
  var useCanvasRenderer = true; // FIXME: disable WEBGL renderer for now

  // browser specific map setup
  if (navigator.userAgent.match(/Mozilla.+Android.+Safari/)) {
    // Android Safari
    // Mozilla/5.0 (Linux; U; Android 4.0.3; en-gb; Transformer TF101 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

    // SingleImageWMS is not refreshed on pinch zoom
    Map.useTiledWMS = true;
  }
  else if (navigator.userAgent.match(/Mozilla.+Android.+Firefox/)) {
    // Android Firefox
    // Mozilla/5.0 (Android; Tablet; rv:21.0) Gecko/21.0 Firefox/21.0

    // SingleImageWMS is not refreshed on pinch zoom
    Map.useTiledWMS = true;
    // WEBGL renderer renders GL WMS as black image
    useCanvasRenderer = true;
  }

  // override from URL params
  if (UrlParams.params.tiledWms != undefined) {
    Map.useTiledWMS = UrlParams.params.tiledWms;
  }

  var projection = ol.proj.configureProj4jsProjection({
    code: 'EPSG:21781',
    extent: [485869.5728, 837076.5648, 76443.1884, 299941.7864]
  });

  var renderers = ol.RendererHints.createFromQueryData();
  if (useCanvasRenderer) {
    renderers = [ol.RendererHint.CANVAS, ol.RendererHint.WEBGL, ol.RendererHint.DOM];
  }

  Map.map = new ol.Map({
    layers: [],
    renderers: renderers,
    target: 'map',
    view: new ol.View2D({
      projection: projection,
      center: [660000, 190000],
      zoom: 2
    }),
    controls:[]
  });

  Map.map.getView().on('change:rotation', function() {
    $.event.trigger({type: 'maprotation', rotation: Map.map.getView().getRotation()});
  });

  // feature info
  if (featureInfoCallback != null) {
    var clickTimeout = null;
    Map.map.on('click', function(e) {
      clearTimeout(clickTimeout);
      clickTimeout = setTimeout(function() {
        Map.lastClickPos = e.getCoordinate();

        /* FIXME: enable this block for production
        Map.map.getFeatureInfo({
          pixel: e.getPixel(),
          success: featureInfoCallback
        });
        */
        /* FIXME: use static xml file for demonstration purposes, to avoid cross domain issues */
        $.ajax({
          url: "src/get_feature_info_response.xml",
          dataType: 'text'
        }).done(function(data, status) {
          featureInfoCallback([data]);
        });
        /* END */
      }, 200);
    });
    Map.map.on('dblclick', function(e) {
      // abort feature info on double click
      clearTimeout(clickTimeout);
    });
  }
};

Map.setTopicLayer = function() {
  // remove old layer
  Map.map.removeLayer(Map.map.getLayers().getAt(0));

  // add new layer
  var wmsParams = {
{'fraction_non_alphanumeric': 0.13758021599624354, 'fraction_numerical': 0.031147284395054, 'mean_word_length': 2.8892270237370665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6734471', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2090, 'n_words': 511}