<commit_before>import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Map, FeatureGroup } from 'leaflet';
import { MapService } from '../map.service';

import 'leaflet-draw';
import * as L from 'leaflet';

@Component({
  selector: 'pnx-leaflet-draw',
  templateUrl: 'leaflet-draw.component.html'
})

export class LeafletDrawComponent implements OnInit {
  public map: Map;
  private _currentDraw:any;
  private _Le: any;
  public drawnItems:any;
  @Input() options: any;
  @Output() layerDrawed = new EventEmitter<any>();

  constructor(public mapservice: MapService) { }

  ngOnInit() {
    this.map = this.mapservice.map;
    this._Le = L as any;
    this.enableLeafletDraw();


  }

   enableLeafletDraw() {
    this.options.edit['featureGroup'] = this.drawnItems;
    this.options.edit['featureGroup'] = this.mapservice.releveFeatureGroup;
    const drawControl =  new this._Le.Control.Draw(this.options);
    this.map.addControl(drawControl);

    this.map.on(this._Le.Draw.Event.DRAWSTART, (e) => {
      // remove the current draw
      if (this._currentDraw !== null) {
        this.mapservice.removeAllLayers(this.map, this.mapservice.releveFeatureGroup);
      }
      // remove the current marker
      const markerLegend = document.getElementById('markerLegend');
      if (markerLegend) {
        markerLegend.style.backgroundColor = 'white';
      }
      this.mapservice.editingMarker = false;
      this.map.off('click');
      if (this.mapservice.marker) {
        this.map.removeLayer(this.mapservice.marker);
      }
    });

    // on draw layer created
    this.map.on(this._Le.Draw.Event.CREATED, (e) => {
      if (this.map.getZoom() < 5) {
        this.mapservice.sendWarningMessage();
      }else {
        this._currentDraw = (e as any).layer;
        const layerType = (e as any).layerType;
        const latlngTab = this._currentDraw._latlngs;
        this.mapservice.releveFeatureGroup.addLayer(this._currentDraw);
        let geojson = this.mapservice.releveFeatureGroup.toGeoJSON();
        geojson = (geojson as any).features[0];
        // output
        this.layerDrawed.emit(geojson);
      }

    });
  }
}<commit_msg>get geoInfo on leaflet draw edited<commit_after>import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Map, FeatureGroup } from 'leaflet';
import { MapService } from '../map.service';

import 'leaflet-draw';
import * as L from 'leaflet';

@Component({
  selector: 'pnx-leaflet-draw',
  templateUrl: 'leaflet-draw.component.html'
})

export class LeafletDrawComponent implements OnInit {
  public map: Map;
  private _currentDraw:any;
  private _Le: any;
  public drawnItems:any;
  @Input() options: any;
  @Output() layerDrawed = new EventEmitter<any>();

  constructor(public mapservice: MapService) { }

  ngOnInit() {
    this.map = this.mapservice.map;
    this._Le = L as any;
    this.enableLeafletDraw();


  }

   enableLeafletDraw() {
    this.options.edit['featureGroup'] = this.drawnItems;
    this.options.edit['featureGroup'] = this.mapservice.releveFeatureGroup;
    const drawControl =  new this._Le.Control.Draw(this.options);
    this.map.addControl(drawControl);

    this.map.on(this._Le.Draw.Event.DRAWSTART, (e) => {
      // remove the current draw
      if (this._currentDraw !== null) {
        this.mapservice.removeAllLayers(this.map, this.mapservice.releveFeatureGroup);
      }
      // remove the current marker
      const markerLegend = document.getElementById('markerLegend');
      if (markerLegend) {
        markerLegend.style.backgroundColor = 'white';
      }
      this.mapservice.editingMarker = false;
      this.map.off('click');
      if (this.mapservice.marker) {
        this.map.removeLayer(this.mapservice.marker);
      }
    });

    // on draw layer created
    this.map.on(this._Le.Draw.Event.CREATED, (e) => {
      if (this.map.getZoom() < 5) {
        this.mapservice.sendWarningMessage();
      }else {
        this._currentDraw = (e as any).layer;
        const layerType = (e as any).layerType;
        const latlngTab = this._currentDraw._latlngs;
        this.mapservice.releveFeatureGroup.addLayer(this._currentDraw);
        let geojson = this.mapservice.releveFeatureGroup.toGeoJSON();
        geojson = (geojson as any).features[0];
        // output
        this.layerDrawed.emit(geojson);
      }
    });

    // on draw edited
    this.mapservice.map.on('draw:edited', (e) => {
      let geojson = this.mapservice.releveFeatureGroup.toGeoJSON();
      geojson = (geojson as any).features[0];
      // output
      this.layerDrawed.emit(geojson);
    });
  }
}
{'fraction_non_alphanumeric': 0.13323288850624193, 'fraction_numerical': 0.001076194575979337, 'mean_word_length': 3.0408695652173914, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '6890448', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1454, 'n_words': 285}