<commit_before>/**
 * @author <NAME>
 */
var EventBus = require( '../event/event-bus' )
var Events   = require( '../event/events' )

var Mosaic          = require( './ee-mosaic' )
var LandsatMosaic   = null
var Sentinel2Mosaic = null
var ActiveMosaic    = null

var LAYER_INDEX = 100

var visible = false

var reset = function () {
    hideActiveMosaic()
    ActiveMosaic = null
}

var hideActiveMosaic = function () {
    if ( ActiveMosaic ) {
        EventBus.dispatch( Events.MAP.REMOVE_EE_MOSAIC, null, LAYER_INDEX )
        visible = false
    }
}

var showActiveMosaic = function () {
    if ( ActiveMosaic ) {
        EventBus.dispatch( Events.MAP.ADD_EE_MOSAIC, null, LAYER_INDEX, ActiveMosaic.layer )
        visible = true
    }
}

var addMosaic = function ( mapId, token ) {
    reset()
    ActiveMosaic = Mosaic.newInstance( mapId, token )
    showActiveMosaic()
}

// var addLandsatMosaic = function ( mapId, token ) {
//     LandsatMosaic = Mosaic.newInstance( mapId, token )
//     addMosaic( LandsatMosaic )
// }
//
// var addSentinel2Mosaic = function ( mapId, token ) {
//     Sentinel2Mosaic = Mosaic.newInstance( mapId, token )
//     addMosaic( Sentinel2Mosaic )
// }
//
// var addMosaic = function ( mosaic ) {
//     reset()
//     ActiveMosaic = mosaic
//     showActiveMosaic()
// }

var toggleMosaicVisibility = function ( e ) {
    if ( visible ) {
        hideActiveMosaic()
    } else {
        showActiveMosaic()
    }
}
// var toggleLandsatMosaic = function ( e ) {
//     if ( ActiveMosaic === LandsatMosaic ) {
//         reset()
//     } else {
//         addMosaic( LandsatMosaic )
//     }
// }
//
// var toggleSentinel2Mosaic = function ( e ) {
//     if ( ActiveMosaic === Sentinel2Mosaic ) {
//         reset()
//     } else {
//         addMosaic( Sentinel2Mosaic )
//     }
// }

module.exports = {
    reset                   : reset
    , addMosaic             : addMosaic
    , toggleMosaicVisibility: toggleMosaicVisibility
    // , addLandsatMosaic     : addLandsatMosaic
    // , addSentinel2Mosaic   : addSentinel2Mosaic
    // , toggleLandsatMosaic  : toggleLandsatMosaic
    // , toggleSentinel2Mosaic: toggleSentinel2Mosaic
    , hideMosaic            : hideActiveMosaic
    , showMosaic            : showActiveMosaic
}<commit_msg>removing old mosaic first in preview<commit_after>/**
 * @author <NAME>
 */
var EventBus = require('../event/event-bus')
var Events   = require('../event/events')

var Mosaic          = require('./ee-mosaic')
var LandsatMosaic   = null
var Sentinel2Mosaic = null
var ActiveMosaic    = null

var LAYER_INDEX = 100

var visible = false

var reset = function () {
  hideActiveMosaic()
  ActiveMosaic = null
}

var hideActiveMosaic = function () {
  if (ActiveMosaic) {
    EventBus.dispatch(Events.MAP.REMOVE_EE_MOSAIC, null, LAYER_INDEX)
    visible = false
  }
}

var showActiveMosaic = function () {
  if (ActiveMosaic) {
    EventBus.dispatch(Events.MAP.ADD_EE_MOSAIC, null, LAYER_INDEX, ActiveMosaic.layer)
    visible = true
  }
}

var addMosaic = function (mapId, token) {
  reset()
  setTimeout(function () {
    ActiveMosaic = Mosaic.newInstance(mapId, token)
    showActiveMosaic()
  }, 500)
}

// var addLandsatMosaic = function ( mapId, token ) {
//     LandsatMosaic = Mosaic.newInstance( mapId, token )
//     addMosaic( LandsatMosaic )
// }
//
// var addSentinel2Mosaic = function ( mapId, token ) {
//     Sentinel2Mosaic = Mosaic.newInstance( mapId, token )
//     addMosaic( Sentinel2Mosaic )
// }
//
// var addMosaic = function ( mosaic ) {
//     reset()
//     ActiveMosaic = mosaic
//     showActiveMosaic()
// }

var toggleMosaicVisibility = function (e) {
  if (visible) {
    hideActiveMosaic()
  } else {
    showActiveMosaic()
  }
}
// var toggleLandsatMosaic = function ( e ) {
//     if ( ActiveMosaic === LandsatMosaic ) {
//         reset()
//     } else {
//         addMosaic( LandsatMosaic )
//     }
// }
//
// var toggleSentinel2Mosaic = function ( e ) {
//     if ( ActiveMosaic === Sentinel2Mosaic ) {
//         reset()
//     } else {
//         addMosaic( Sentinel2Mosaic )
//     }
// }

module.exports = {
  reset                   : reset
  , addMosaic             : addMosaic
  , toggleMosaicVisibility: toggleMosaicVisibility
  // , addLandsatMosaic     : addLandsatMosaic
  // , addSentinel2Mosaic   : addSentinel2Mosaic
  // , toggleLandsatMosaic  : toggleLandsatMosaic
  // , toggleSentinel2Mosaic: toggleSentinel2Mosaic
  , hideMosaic            : hideActiveMosaic
  , showMosaic            : showActiveMosaic
}
{'fraction_non_alphanumeric': 0.12444933920704845, 'fraction_numerical': 0.006828193832599119, 'mean_word_length': 2.406601650412603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7663172', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1504, 'n_words': 301}