<commit_before>import {Component, OnInit} from '@angular/core';
import {HsCesiumService} from './hscesium.service';
import {HsCoreService} from '../core/core.service';
import {HsEventBusService} from '../core/event-bus.service';
import {HsLayoutService} from '../layout/layout.service';
import {HsMapService} from '../map/map.service';
import {HsShareUrlService} from '../permalink/share-url.service';
import {HsSidebarService} from '../sidebar/sidebar.service';

@Component({
  selector: 'hs.cesium',
  template: require('./partials/cesium.html'),
})
export class HsCesiumComponent implements OnInit {
  visible = true;
  constructor(
    private HsCesiumService: HsCesiumService,
    private HsPermalinkUrlService: HsShareUrlService,
    private HsCoreService: HsCoreService,
    private HsMapService: HsMapService,
    private HsSidebarService: HsSidebarService,
    private HsEventBusService: HsEventBusService,
    private HsLayoutService: HsLayoutService //Used in template
  ) {}

  ngOnInit(): void {
    this.HsCesiumService.init();
    const view = this.HsPermalinkUrlService.getParamValue('view');
    if (view != '2d') {
      this.HsPermalinkUrlService.updateCustomParams({view: '3d'});
      this.HsMapService.visible = false;
    } else {
      this.HsPermalinkUrlService.updateCustomParams({view: '2d'});
    }

    this.HsSidebarService.buttons.push({
      title: '3D/2D',
      description: 'Switch between 3D (Cesium) and 2D (OpenLayers)',
      icon: 'icon-globealt',
      click: () => this.toggleCesiumMap(),
    });

    this.HsEventBusService.layermanagerDimensionChanges.subscribe((data) =>
      this.HsCesiumService.dimensionChanged(data.layer, data.dimension)
    );

    this.HsEventBusService.sizeChanges.subscribe((size) =>
      this.HsCesiumService.resize(size)
    );
    this.HsCesiumService.resize();
  }

  /**
   * @ngdoc method
   * @name HsCesiumController#toggleCesiumMap
   * @private
   * @description Toggles between Cesium and OL maps by setting hs_map.visible variable which is monitored by ng-show. ng-show is set on map directive in map.js link function.
   */
  toggleCesiumMap() {
    this.HsMapService.visible = !this.HsMapService.visible;
    this.visible = !this.HsMapService.visible;
    this.HsPermalinkUrlService.updateCustomParams({
      view: HsMapService.visible ? '2d' : '3d',
    });
    if (this.HsMapService.visible) {
      this.HsCesiumService.viewer.destroy();
      this.HsCoreService.updateMapSize();
    } else {
      this.HsCesiumService.init();
    }
    this.HsEventBusService.mapLibraryChanges.next(
      this.visible ? 'cesium' : 'ol'
    );
  }
}<commit_msg>fix mapService context in hscesium<commit_after>import {Component, OnInit} from '@angular/core';
import {HsCesiumService} from './hscesium.service';
import {HsCoreService} from '../core/core.service';
import {HsEventBusService} from '../core/event-bus.service';
import {HsLayoutService} from '../layout/layout.service';
import {HsMapService} from '../map/map.service';
import {HsShareUrlService} from '../permalink/share-url.service';
import {HsSidebarService} from '../sidebar/sidebar.service';

@Component({
  selector: 'hs.cesium',
  template: require('./partials/cesium.html'),
})
export class HsCesiumComponent implements OnInit {
  visible = true;
  constructor(
    private HsCesiumService: HsCesiumService,
    private HsPermalinkUrlService: HsShareUrlService,
    private HsCoreService: HsCoreService,
    private HsMapService: HsMapService,
    private HsSidebarService: HsSidebarService,
    private HsEventBusService: HsEventBusService,
    private HsLayoutService: HsLayoutService //Used in template
  ) {}

  ngOnInit(): void {
    this.HsCesiumService.init();
    const view = this.HsPermalinkUrlService.getParamValue('view');
    if (view != '2d') {
      this.HsPermalinkUrlService.updateCustomParams({view: '3d'});
      this.HsMapService.visible = false;
    } else {
      this.HsPermalinkUrlService.updateCustomParams({view: '2d'});
    }

    this.HsSidebarService.buttons.push({
      title: '3D/2D',
      description: 'Switch between 3D (Cesium) and 2D (OpenLayers)',
      icon: 'icon-globealt',
      click: () => this.toggleCesiumMap(),
    });

    this.HsEventBusService.layermanagerDimensionChanges.subscribe((data) =>
      this.HsCesiumService.dimensionChanged(data.layer, data.dimension)
    );

    this.HsEventBusService.sizeChanges.subscribe((size) =>
      this.HsCesiumService.resize(size)
    );
    this.HsCesiumService.resize();
  }

  /**
   * @ngdoc method
   * @name HsCesiumController#toggleCesiumMap
   * @private
   * @description Toggles between Cesium and OL maps by setting hs_map.visible variable which is monitored by ng-show. ng-show is set on map directive in map.js link function.
   */
  toggleCesiumMap() {
    this.HsMapService.visible = !this.HsMapService.visible;
    this.visible = !this.HsMapService.visible;
    this.HsPermalinkUrlService.updateCustomParams({
      view: this.HsMapService.visible ? '2d' : '3d',
    });
    if (this.HsMapService.visible) {
      this.HsCesiumService.viewer.destroy();
      this.HsCoreService.updateMapSize();
    } else {
      this.HsCesiumService.init();
    }
    this.HsEventBusService.mapLibraryChanges.next(
      this.visible ? 'cesium' : 'ol'
    );
  }
}
{'fraction_non_alphanumeric': 0.12735849056603774, 'fraction_numerical': 0.0033962264150943396, 'mean_word_length': 3.8812154696132595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6426770', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1661, 'n_words': 320}