<commit_before>/** 
 * Flamingomap 
 * @class 
 * @constructor
 * @description
 * 
 */

Ext.define("viewer.viewercontroller.flamingo.FlamingoMap",{
    extend: "viewer.viewercontroller.controller.Map",
    enabledEvents: new Object(),
    editMapId: null,
    gisId: 'gis',
    config: {
        options: null,
        viewerController:null
    },
    constructor: function(config){
        viewer.viewercontroller.flamingo.FlamingoMap.superclass.constructor.call(this, config);
        this.initConfig(config);        
        this.frameworkMap = this.mapComponent.viewerObject;
        return this;
    },
    
    /**
     *See @link Map.getId
     */
    getId : function(){
        return this.id;
    },

    /**
     *See @link Map.getAllWMSLayers
     */
    getAllWMSLayers : function(){
        var lagen = new Array();
        for(var i = 0 ; i < this.layers.length;i++){
            if(this.layers[i] instanceof viewer.viewercontroller.flamingo.FlamingoWMSLayer){
                lagen.push(this.layers[i]);
            }
        }
        return lagen;
    },
    /**
     *See @link Map.getAllVectorLayers
     */
    getAllVectorLayers : function(){
        var lagen = new Array();
        for(var i = 0 ; i < this.layers.length;i++){
            if(this.layers[i] instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer){
                lagen.push(this.layers[i]);
            }
        }
        return lagen;
    },
    /**
     *see @link Map.remove
     */
    remove : function(){
        this.getFrameworkMap().callMethod("flamingo","killComponent",this.getId());
    },

    /**
     *Add a layer(service) to the map
     *@param layer a FlamingoLayer that needs to be added.
     *see @link Map.addLayer
     **/
    addLayer : function(layer){
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoLayer))
            Ext.Error.raise({msg: "FlamingoMap.addLayer(): Given layer not of type FlamingoLayer"});
        //call super function
        this.superclass.addLayer.call(this,layer);                
        if (layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer){
            if (this.editMapId==null){
                this.addEditMap();             
            }
            layer.setGisId(this.gisId);
            this.addLayerToGis(layer);
        }else if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer)){
            this.getFrameworkMap().callMethod(this.getId(),'addLayer',layer.toXML());
        }
    },
    addLayerToGis : function (layer){
        if(this.getFrameworkMap().callMethod("flamingo", "isLoaded",this.gisId, true)){
            this.getFrameworkMap().callMethod(this.gisId,'addLayerAsString',layer.toXML());
            layer.isLoaded=true;
        }else{
            var thisObj = this;
            setTimeout(function(){
                thisObj.addLayerToGis(layer,thisObj);
            },500);
        }
    },
    /**
     *remove the specific layer. See @link Map.removeLayer
     **/
    removeLayer:function(layer){
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoLayer))
            Ext.Error.raise({msg: "FlamingoMap.removeLayer(): Given layer not of type FlamingoLayer"});
        //call super function
        this.superclass.removeLayer.call(this,layer);
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer)){
            this.getFrameworkMap().callMethod(this.getId(),'removeLayer',this.getId()+'_'+layer.getId());
        }
    },
    
    addEditMap: function(){
        this.editMapId='editMap';        
        //add gis
        this.getFrameworkMap().callMethod(
            this.getMapComponent().mainContainerId,
            "addComponent",
            "<fmc:GIS xmlns:fmc='fmc' id='"+this.gisId+"' geometryeditable='true' alwaysdrawpoints='false'></fmc:GIS>");
        //add editMap
        this.getFrameworkMap().callMethod(
            this.getMapComponent().mainContainerId,
            "addComponent",
            "<fmc:EditMap xmlns:fmc='fmc' id='"+this.editMapId+"' editable='true' left='0' top='0%' height='100%' width='100%' bottom='bottom' listento='"+this.gisId+","+this.id+"'/>");                
    },
    /**
     * Get layer with flamingo layer id (with mapid_ as prefix)
     */
    getLayerByFlamingoId: function(layerId){
        var l=null;
        if (layerId.indexOf(this.getId()+"_")==0){
            l=this.getLayer( (layerId.replace(this.getId() + "_" ,"")));<commit_msg>Map options added to editmap. (top,left,etc.)<commit_after>/** 
 * Flamingomap 
 * @class 
 * @constructor
 * @description
 * 
 */

Ext.define("viewer.viewercontroller.flamingo.FlamingoMap",{
    extend: "viewer.viewercontroller.controller.Map",
    enabledEvents: new Object(),
    editMapId: null,
    gisId: 'gis',
    config: {
        options: null,
        viewerController:null
    },
    constructor: function(config){
        viewer.viewercontroller.flamingo.FlamingoMap.superclass.constructor.call(this, config);
        this.initConfig(config);        
        this.frameworkMap = this.mapComponent.viewerObject;
        return this;
    },
    
    /**
     *See @link Map.getId
     */
    getId : function(){
        return this.id;
    },

    /**
     *See @link Map.getAllWMSLayers
     */
    getAllWMSLayers : function(){
        var lagen = new Array();
        for(var i = 0 ; i < this.layers.length;i++){
            if(this.layers[i] instanceof viewer.viewercontroller.flamingo.FlamingoWMSLayer){
                lagen.push(this.layers[i]);
            }
        }
        return lagen;
    },
    /**
     *See @link Map.getAllVectorLayers
     */
    getAllVectorLayers : function(){
        var lagen = new Array();
        for(var i = 0 ; i < this.layers.length;i++){
            if(this.layers[i] instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer){
                lagen.push(this.layers[i]);
            }
        }
        return lagen;
    },
    /**
     *see @link Map.remove
     */
    remove : function(){
        this.getFrameworkMap().callMethod("flamingo","killComponent",this.getId());
    },

    /**
     *Add a layer(service) to the map
     *@param layer a FlamingoLayer that needs to be added.
     *see @link Map.addLayer
     **/
    addLayer : function(layer){
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoLayer))
            Ext.Error.raise({msg: "FlamingoMap.addLayer(): Given layer not of type FlamingoLayer"});
        //call super function
        this.superclass.addLayer.call(this,layer);                
        if (layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer){
            if (this.editMapId==null){
                this.addEditMap();             
            }
            layer.setGisId(this.gisId);
            this.addLayerToGis(layer);
        }else if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer)){
            this.getFrameworkMap().callMethod(this.getId(),'addLayer',layer.toXML());
        }
    },
    addLayerToGis : function (layer){
        if(this.getFrameworkMap().callMethod("flamingo", "isLoaded",this.gisId, true)){
            this.getFrameworkMap().callMethod(this.gisId,'addLayerAsString',layer.toXML());
            layer.isLoaded=true;
        }else{
            var thisObj = this;
            setTimeout(function(){
                thisObj.addLayerToGis(layer,thisObj);
            },500);
        }
    },
    /**
     *remove the specific layer. See @link Map.removeLayer
     **/
    removeLayer:function(layer){
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoLayer))
            Ext.Error.raise({msg: "FlamingoMap.removeLayer(): Given layer not of type FlamingoLayer"});
        //call super function
        this.superclass.removeLayer.call(this,layer);
        if (!(layer instanceof viewer.viewercontroller.flamingo.FlamingoVectorLayer)){
            this.getFrameworkMap().callMethod(this.getId(),'removeLayer',this.getId()+'_'+layer.getId());
        }
    },
    
    addEditMap: function(){
        this.editMapId='editMap';        
        //add gis
        this.getFrameworkMap().callMethod(
            this.getMapComponent().mainContainerId,
            "addComponent",
            "<fmc:GIS xmlns:fmc='fmc' id='"+this.gisId+"' geometryeditable='true' alwaysdrawpoints='false'></fmc:GIS>");
        //add editMap
        var editmapXml="<fmc:EditMap xmlns:fmc='fmc' id='"+this.editMapId+"' editable='true'";
        for (var key in this.config.options){
            editmapXml+=" "+key+"='"+this.config.options[key]+"'";
        }
        editmapXml+="listento='"+this.gisId+","+this.id+"'/>";
        
        this.getFrameworkMap().callMethod(
            this.getMapComponent().mainContainerId,
            "addComponent",
            editmapXml);                
    },
    /**
     * Get layer with flamingo layer id (with mapid_ as prefix)
     */
    getLayerByFlamingoId: function(layerId){
        var l=null;
        if (layerId.indexOf(this.getId()+"_")==0){
            l=this.getLayer( (layerId.replace(this.getId() + "_" ,"")));
{'fraction_non_alphanumeric': 0.14095425264766895, 'fraction_numerical': 0.0021836445026749644, 'mean_word_length': 2.2855093256814922, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5387743', 'n_tokens_mistral': 2793, 'n_tokens_neox': 2746, 'n_words': 453}