<commit_before>//= require leaflet/draw
//= require leaflet/map

//= require leaflet/draw.translations

const $building_geo_data = $('#building_geo_data');
const $building_geo_data_json = $building_geo_data.val();

function saveToForm(geo_json) {
    $building_geo_data.val(JSON.stringify(geo_json.toGeoJSON()));
}

var drawnLayer = L.geoJSON().addTo(map);
map.addLayer(drawnLayer);

// Load json from the form
if ($building_geo_data_json) {
    drawnLayer.addData(JSON.parse($building_geo_data_json));
}

var drawControl = new L.Control.Draw({
    edit: {
        featureGroup: drawnLayer
    },
    draw: {
        polyline: false,
        circle: false,
        rectangle: false,
        polygon: {
            allowIntersection: false,
            showArea: true
        }
    }
});

map.on(L.Draw.Event.CREATED, function(event) {
    var layer = event.layer;
    drawnLayer.addLayer(layer);
    saveToForm(drawnLayer);
});

// map.on(L.Draw.Event.EDITED, function(event) {
//     var layer = event.layer;
//     drawnLayer.addLayer(layer);
//     saveToForm(drawnLayer);
// });
// map.on(L.Draw.Event.DELETED, function(event) {
//     var layer = event.layer;
//     drawnLayer.addLayer(layer);
//     saveToForm(drawnLayer);
// });

map.addControl(drawControl);

// TODO:10 Create button to define the location<commit_msg>Save to the form edited and deleted polygons.<commit_after>//= require leaflet/draw
//= require leaflet/map

//= require leaflet/draw.translations

const $building_geo_data = {
  element: $('#building_geo_data'),
  save: function(geo_json){
    this.element.val(JSON.stringify(geo_json.toGeoJSON()));
  },
  load(){
    const $geo_json = this.element.val();
    if ($geo_json) {
        drawnLayer.addData(JSON.parse($geo_json));
    }
  }
};

var drawnLayer = L.geoJSON().addTo(map);
map.addLayer(drawnLayer);

// Load json from the form
$building_geo_data.load();

var drawControl = new L.Control.Draw({
    edit: {
        featureGroup: drawnLayer
    },
    draw: {
        polyline: false,
        circle: false,
        rectangle: false,
        polygon: {
            allowIntersection: false,
            showArea: true
        }
    }
});

map.on(L.Draw.Event.CREATED, function(event) {
    var layer = event.layer;
    drawnLayer.addLayer(layer);
    $building_geo_data.save(drawnLayer);
});

map.on(L.Draw.Event.EDITED, function(event) {
    $building_geo_data.save(drawnLayer);
});
map.on(L.Draw.Event.DELETED, function(event) {
    $building_geo_data.save(drawnLayer);
});

map.addControl(drawControl);

// TODO:10 Create button to define the location
{'fraction_non_alphanumeric': 0.14583333333333334, 'fraction_numerical': 0.0015432098765432098, 'mean_word_length': 3.162118780096308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6802997', 'n_tokens_mistral': 873, 'n_tokens_neox': 863, 'n_words': 153}