<commit_before>//__BEGIN_LICENSE__
// Copyright (c) 2015, United States Government, as represented by the
// Administrator of the National Aeronautics and Space Administration.
// All rights reserved.
//
// The xGDS platform is licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0.
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
//__END_LICENSE__
var DEG2RAD = Math.PI / 180.0;
var SPHERICAL_MERCATOR = 'EPSG:3857'; 
var WGS_84 = 'EPSG:3395';
var LONG_LAT =  'EPSG:4326';
var DEFAULT_COORD_SYSTEM = SPHERICAL_MERCATOR;
var mapResizeTimeout;

function showOnMap(data){
	app.vent.trigger("mapSearch:found", data);
	app.vent.trigger('mapSearch:fit');
}

function highlightOnMap(data){
	app.vent.trigger("mapSearch:highlight", data);
}

function unhighlightOnMap(data){
	app.vent.trigger("mapSearch:unhighlight", data);
}

function removeFromMap(data){
	app.vent.trigger("mapSearch:clear", data);
}

// take a list of tuples and return a flat list
function flatten(coords){
    var result = [];
    for (i = 0; i < coords.length; i++){
        result.push(coords[i][0]);
        result.push(coords[i][1]);
    }
    return result;
}

// transform coords from lon lat to default coordinate system (ol map coords) 
function transform(coords){
    return ol.proj.transform(coords, LONG_LAT,  DEFAULT_COORD_SYSTEM);    
}

function transformFromProjection(coords, projection){
	return ol.proj.transform(coords, projection, DEFAULT_COORD_SYSTEM);
}

function transformFlatList(coords){
    // Takes a flat list of coords and returns a list of transformed coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 2){
        var coord = [coords[i], coords[i+1]]
        result.push(transform(coord));
    }
    return result;
}

function transformList(coords){
    // Takes a  list of coords and returns a list of transformed coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 1){
        var coord = coords[i];
        result.push(transform(coord));
    }
    return result;
}

function inverseTransform(coords){
    return ol.proj.transform(coords, DEFAULT_COORD_SYSTEM, LONG_LAT);    
}

function inverseList(coords){
    // Takes a list of coords and returns a list of inverse coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 1){
        var coord = coords[i];
        result.push(inverseTransform(coord));
    }
    return result;
}

function inverseFlatList(coords){
    // Takes a flat list of coords and returns a list of inverse coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 2){
        var coord = [coords[i], coords[i+1]];
        result.push(inverseTransform(coord));
    }
    return result;
}

function endsWith(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}


function getExtens(coordinates){
    var xValues = [];
    var yValues = [];
    for (i = 0; i < coordinates.length; i++){
        xValues.push(coordinates[i][1]);
        yValues.push(coordinates[i][0]);
    }
    var minX = Math.min.apply(null, xValues);
    var maxX = Math.max.apply(null, xValues);   
    var minY = Math.min.apply(null, yValues);
    var maxY = Math.max.apply(null, yValues);   
    return [coordinates[0][0], coordinates[0][1], coordinates[2][0], coordinates[2][1]]
//    return [minY, minX, maxY, maxX];
}

function calculateOpacity(transparency){
	if (transparency == undefined || transparency == 0){
		return 1;
	}
	var t = transparency/100.0;
	return 1.0 - t;
}

$(function() {
    app.views = app.views || {};

    // map to look up the different layers since we want to initialize them before the tree shows up
    app.nodeMap = {}; 

    app.views.OLMapView = Marionette.View.extend({
            el: "#map",
            initialize: function(options) {
                this.options = options || {};
                //_.bindAll(this);
                var _this = this;
                this.$el.resizable({
                    stop: function( event, ui ) {
                        _this.handleResize();
                    }
                  });
                
                // pre-set certain variables to speed up this code
                app.State.pageContainer = this.$el.parent();
                app.State.pageInnerWidth = app.State.pageContainer.innerWidth();
                var horizOrigin = this.$el.width();

                var DEFAULT_ZOOM = app.options.DEFAULT_ZOOM;
                var DEFAULT_ROTATION = app.options.DEFAULT_ROTATION;

                proj4.defs('EPSG:3395', '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs');
                if (!_.isEmpty(app.options.DEFAULT_COORD_SYSTEM) && app.options.DEFAULT_COORD_SYSTEM != SPHERICAL_MERCATOR){
                	if (!_.isNull(app.options.SETUP_COORD_SYSTEM)){
                		DEFAULT_COORD_SYSTEM = app.options.DEFAULT_COORD_SYSTEM;
                		app.options.SETUP_COORD_SYSTEM(app.options.DEFAULT_COORD_SYSTEM);
                	}
                }
                
                this.$el.bind('resize', this.handleResize);
                app.vent.on('doMapResize', this.handleResize);
                // also bind to window to adjust on window size change
                $(window).bind('resize', this.handleWindowResize);
                
                this.buildLayersForMap();
                this.layersInitialized = false;
                
                app.mapView = new ol.View({
                    // we will center the view later with updateBbox
                    zoom: DEFAULT_ZOOM,
                    projection: ol.proj.get(DEFAULT_COORD_SYSTEM),
                    rotation: DEFAULT_ROTATION
                });
                <commit_msg>added this to event things<commit_after>//__BEGIN_LICENSE__
// Copyright (c) 2015, United States Government, as represented by the
// Administrator of the National Aeronautics and Space Administration.
// All rights reserved.
//
// The xGDS platform is licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0.
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
//__END_LICENSE__
var DEG2RAD = Math.PI / 180.0;
var SPHERICAL_MERCATOR = 'EPSG:3857'; 
var WGS_84 = 'EPSG:3395';
var LONG_LAT =  'EPSG:4326';
var DEFAULT_COORD_SYSTEM = SPHERICAL_MERCATOR;
var mapResizeTimeout;

function showOnMap(data){
	app.vent.trigger("mapSearch:found", data);
	app.vent.trigger('mapSearch:fit');
}

function highlightOnMap(data){
	app.vent.trigger("mapSearch:highlight", data);
}

function unhighlightOnMap(data){
	app.vent.trigger("mapSearch:unhighlight", data);
}

function removeFromMap(data){
	app.vent.trigger("mapSearch:clear", data);
}

// take a list of tuples and return a flat list
function flatten(coords){
    var result = [];
    for (i = 0; i < coords.length; i++){
        result.push(coords[i][0]);
        result.push(coords[i][1]);
    }
    return result;
}

// transform coords from lon lat to default coordinate system (ol map coords) 
function transform(coords){
    return ol.proj.transform(coords, LONG_LAT,  DEFAULT_COORD_SYSTEM);    
}

function transformFromProjection(coords, projection){
	return ol.proj.transform(coords, projection, DEFAULT_COORD_SYSTEM);
}

function transformFlatList(coords){
    // Takes a flat list of coords and returns a list of transformed coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 2){
        var coord = [coords[i], coords[i+1]]
        result.push(transform(coord));
    }
    return result;
}

function transformList(coords){
    // Takes a  list of coords and returns a list of transformed coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 1){
        var coord = coords[i];
        result.push(transform(coord));
    }
    return result;
}

function inverseTransform(coords){
    return ol.proj.transform(coords, DEFAULT_COORD_SYSTEM, LONG_LAT);    
}

function inverseList(coords){
    // Takes a list of coords and returns a list of inverse coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 1){
        var coord = coords[i];
        result.push(inverseTransform(coord));
    }
    return result;
}

function inverseFlatList(coords){
    // Takes a flat list of coords and returns a list of inverse coordinate pairs
    var result = [];
    for (i = 0; i < coords.length; i = i + 2){
        var coord = [coords[i], coords[i+1]];
        result.push(inverseTransform(coord));
    }
    return result;
}

function endsWith(str, suffix) {
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
}


function getExtens(coordinates){
    var xValues = [];
    var yValues = [];
    for (i = 0; i < coordinates.length; i++){
        xValues.push(coordinates[i][1]);
        yValues.push(coordinates[i][0]);
    }
    var minX = Math.min.apply(null, xValues);
    var maxX = Math.max.apply(null, xValues);   
    var minY = Math.min.apply(null, yValues);
    var maxY = Math.max.apply(null, yValues);   
    return [coordinates[0][0], coordinates[0][1], coordinates[2][0], coordinates[2][1]]
//    return [minY, minX, maxY, maxX];
}

function calculateOpacity(transparency){
	if (transparency == undefined || transparency == 0){
		return 1;
	}
	var t = transparency/100.0;
	return 1.0 - t;
}

$(function() {
    app.views = app.views || {};

    // map to look up the different layers since we want to initialize them before the tree shows up
    app.nodeMap = {}; 

    app.views.OLMapView = Marionette.View.extend({
            el: "#map",
            initialize: function(options) {
                this.options = options || {};
                //_.bindAll(this);
                var _this = this;
                this.$el.resizable({
                    stop: function( event, ui ) {
                        _this.handleResize();
                    }
                  });
                
                // pre-set certain variables to speed up this code
                app.State.pageContainer = this.$el.parent();
                app.State.pageInnerWidth = app.State.pageContainer.innerWidth();
                var horizOrigin = this.$el.width();

                var DEFAULT_ZOOM = app.options.DEFAULT_ZOOM;
                var DEFAULT_ROTATION = app.options.DEFAULT_ROTATION;

                proj4.defs('EPSG:3395', '+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs');
                if (!_.isEmpty(app.options.DEFAULT_COORD_SYSTEM) && app.options.DEFAULT_COORD_SYSTEM != SPHERICAL_MERCATOR){
                	if (!_.isNull(app.options.SETUP_COORD_SYSTEM)){
                		DEFAULT_COORD_SYSTEM = app.options.DEFAULT_COORD_SYSTEM;
                		app.options.SETUP_COORD_SYSTEM(app.options.DEFAULT_COORD_SYSTEM);
                	}
                }
                
                this.$el.bind('resize', this.handleResize, this);
                app.vent.on('doMapResize', this.handleResize, this);
                // also bind to window to adjust on window size change
                $(window).bind('resize', this.handleWindowResize, this);
                
                this.buildLayersForMap();
                this.layersInitialized = false;
                
                app.mapView = new ol.View({
                    // we will center the view later with updateBbox
                    zoom: DEFAULT_ZOOM,
                    projection: ol.proj.get(DEFAULT_COORD_SYSTEM),
                    rotation: DEFAULT_ROTATION
                });
                
{'fraction_non_alphanumeric': 0.1171011217819385, 'fraction_numerical': 0.012266967960616576, 'mean_word_length': 2.4403109383675736, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1694186', 'n_tokens_mistral': 3840, 'n_tokens_neox': 3652, 'n_words': 1011}