﻿// JScript File

Type.registerNamespace("MapApiClient");

//Enums defining map mode
MapApiClient.EnumMapMode = function(){}
MapApiClient.EnumMapMode.prototype= {
    MAP_MODE_ZOOM_RECT: 1,
    MAP_MODE_ZOOM_OUT: 2,
    MAP_MODE_MOVE: 3, 
    MAP_MODE_SELECT: 4,
    MAP_MODE_ZOOM_START: 5,
    MAP_MODE_DIGITIZE_RECT: 6,
    MAP_MODE_DIGITIZE_POLYGON: 7,
    MAP_MODE_SELECT_BY_POLYGON: 8
}
//Enums defining Mouse event state
MapApiClient.EnumMouseMode = function(){}
MapApiClient.EnumMouseMode.prototype= {
    MOUSE_MODE_MOVE: 1,
    MOUSE_MODE_STOPPED: 2,
    MOUSE_MODE_CLICK: 3, 
    MOUSE_MODE_DBL_CLICK: 4
}

//Enums defining Mouse event state
MapApiClient.EnumObjectHitMode = function(){}
MapApiClient.EnumObjectHitMode.prototype= {
    OBJECT_HIT_ANY: 1,
    OBJECT_HIT_SELECTABLE: 2,
    OBJECT_HIT_MOUSEOVER: 3
}
        
MapApiClient.MapApi = function(rootObj) 
{
    MapApiClient.MapApi.initializeBase(this);

    this._mapRootObj = rootObj;
    this._EnumMapMode = new MapApiClient.EnumMapMode();
    this._EnumMouseMode = new MapApiClient.EnumMouseMode();
    this._EnumObjectHitMode = new MapApiClient.EnumObjectHitMode();
    
    this._bSuspendMapLoad = false;
    this._minDigitizeRectSize = 3; //Minimum size of a rectangle dX or dY to classify rect as point in digitize
}

MapApiClient.MapApi.prototype={
    
    EnumMouseMode: function(){
        return this._EnumMouseMode;
    },
    EnumMapMode: function(){
        return this._EnumMapMode;
    },
    EnumObjectHitMode: function(){
        return this._EnumObjectHitMode;
    },
    getMapRootObj: function() {
        return this._mapRootObj;
    },
  
    initialize: function() {
        alert("MapApiClient.MapApi.initialize()");
        return false;
    },
    
    getMapModeEnumFromString: function ( enumMapModeString )
    {
        switch(enumMapModeString)
        {
            case "MAP_MODE_ZOOM_RECT":
            return this.EnumMapMode().MAP_MODE_ZOOM_RECT; break;
            case "MAP_MODE_ZOOM_OUT":
            return this.EnumMapMode().MAP_MODE_ZOOM_OUT; break;
            case "MAP_MODE_MOVE":
            return this.EnumMapMode().MAP_MODE_MOVE; break;
            case "MAP_MODE_SELECT":
            return this.EnumMapMode().MAP_MODE_SELECT; break;
            case "MAP_MODE_ZOOM_START":
            return this.EnumMapMode().MAP_MODE_ZOOM_START; break;
            case "MAP_MODE_DIGITIZE_RECT":
            return this.EnumMapMode().MAP_MODE_DIGITIZE_RECT; break;
            case "MAP_MODE_DIGITIZE_POLYGON":
            return this.EnumMapMode().MAP_MODE_DIGITIZE_POLYGON; break;
            case "MAP_MODE_SELECT_BY_POLYGON":
            return this.EnumMapMode().MAP_MODE_SELECT_BY_POLYGON; break;
        }
    },
    ///
    /// MapApi
    ///
    
    //Returning the Scale of the map: E.g 1:100K returning 100000
    getMapScale: function() { return 0; },
    //Set the map scale, for e.g 1:100K set 100000. Will redraw map if needed
    setMapScale: function( scale ) { return false;},
    //Returning object (C# class) Rectangle, containing Map rectangle in world coords: properties: LLX,LLY,URX,URY
    getMapRect: function() { return null; }, 
    //Return the width of the map in meter
    getMapWidthMeter: function() { return 0;},
    //Return the URL of the map
    getMapURL: function() { return null;},
    
    //Set a layer group Visible or not visible
    //layerGroup = string nameOfGroup
    //layerVisible: true/false
    //reloadMap: true/false  will redraw map after call
    setLayerGroupVisibility: function( layerGroup, layerVisible, reloadMap ){ },
    
    //Set a NE_ID filter for the provided layer
    //layerGroup = string, name of group to set filter
    //filterType = string, type of filter e.g {CELL, SITE, MSC, MSC, LAC etc etc}
    //filterLogic = string, type of logic to apply {INCLUDE, EXCLUDE}
    //filterData = a) string, comma ',' separated list of filter data, E.g list if NE_ID's for CELLS or SITES
    //             b) <NetworkElement> . Array of objects with Coordinates, id, Label, tooltip etc
    //reloadMap  = true/false. true=map redrawn, false not redawn
    //Example : 1) setLayerGroupFilter('CELL_COVERAGE_LAYERS', 'CELL', 'INCLUDE', "12345,761278, 9726,",false);
    //          2) setLayerGroupVisibility('CELL_COVERAGE_LAYERS', true, true);
    //          
    setLayerGroupFilter: function(layerGroup, filterType, filerLogic, filterData, reloadMap){},
    clearLayerGroupFilter: function(layerGroup, filterMapType, reloadMap){;},
    
    //Return all NE filterts applied to <LayerGroupFilter> filterID's.
    //filterTypes { null | unknown = get all,  comma separated list og filterId's E.g: CELL,SITE etc
    //retval: array{filterId, filterType, filterMethod, filterData}
    getLayerGroupNeFilters: function(filterTypes){;},
    ///
    /// Set a database column filter. E.g applies to colimns in database table or view accosiated with layer
    /// i_layerGroupId : Filter a specific layerGroup. if != null Mapkey ignored, else mapKey mandatory
    /// i_filterMapKey : lokup list of layerGroups from filter map. Only used if i_lauergroupId==null
    /// ** Requires a map key <LayerGroupFilterMap filterId="i_filterMapKey"> in MapLayerConfig.xml
    /// i_columnFilterList arrayList of filter strigs of format : "Column|Operator|Data" , "Example: CT_NAME|like|'a%'"
    /// **Column: Database column in table or view
    /// **Operators: INCLUDE and IN=in; EXCLUDE and not in=not in; like; all these add single brackets if needed
    /// **Operators: All valid SQL operators <,>,=, <=, >=; no single brackets added  "Example: CT_VALUE|=|4"
    /// **Data: Case insensitive data to use with operator
    setLayerGroupColumnFilter: function(i_layerGroupId, i_filterMapKey, i_columnFilterList, reloadMap ){;},
    clearLayerGroupColumnFilter: function(i_layerGroupId, i_filterMapKey, reloadMap){;},
    
    
    ///
    /// Override Layer Max/Min scale by defining a dynamic scale on LayerGroup level
    /// i_layerGroupId = LayerGroup to apply this filter
    /// maxScale, minScale. value = -1. Ignore value
    /// maxScale null. Set Max to curr scale, and at next zoom in, set to the new value
    ///                 Used to zoom in and activate layer at that zoom level
    setLayerGroupDynamicMapScale: function(i_layerGroupId, maxScale, minScale, reloadMap){;},
    clearLayerGroupDynamicMapScale: function(i_layerGroupId){;},
    
    //set/get overlay visibility above water
    setPlotOverWaterVisibility: function( visibility ){;},
    getPlotOverWaterVisibility: function( ){;},
    
    //return the visibility state for the provided groupName
    getLayerGroupVisibility: function( i_layerGroup ){ return false;},
    
    //return the potential visibility state for the provided groupName
    getLayerGroupPotVisibility: function( i_layerGroup ){ return false;},
    
    
    //Load the map
    loadMap: function(action, param){return false;},
    //Rebuild the map layers if e.g source data has changed
    mapRebuild: function(){return;},
    //bSuspendFlag { true/false }  true will suspend all incoming loadMap, reload functions etc
    suspendMapLoad: function( bSuspendFlag ) { this._bSuspendMapLoad = bSuspendFlag;},
    
    //Change the current module to ui_module
    changeModule: function( i_module ){return false;},
    
    //Zoom to default coordinates (default World rect)
    zoomStart: function(){return false;},
    //Map centre is set to the easting/northing coordinates (Application world coordibnates
    // if scale provided, mapScale changes
    zoomToWorldPoint: function( easting, northing, scale){return false;},
    //set mapRect to provided coordinates
    //LLX...URY = Mandatory,  rectangle to zoom to in world coordinates
    //minscale  = Optional, if rectangle is very small, the map scale will not be lower than provided min val
    //extendPercent = Optional, if this parameter provided. Rectangle is extended with this value in percent
    zoomToWorldRect: function(LLX, LLY, URX, URY, minscale, extendPercent){return false;},
    //Pan the map with relative factor of screen width in vertical and horizontal direction
    // vertical pos value = south(Down), neg values = north Up (0.5=half screen pan)
    // horizontal ps value = East, neg value West
    panMap: function(verticalFactor, horizontalfactor){ return false;},
    //Set the map mode: see EnumMapMode
    setMapMode: function( enumMapMode ){return false;},
    //Return the current map mode
    getMapMode: function(){return false;},
    
    getLegendData: function(){return null;},
    
    //Draw utilities
    // Easting, Northing -> Location coordinates in Application world coordinates
    // shapeType: string {"CIRCLE","To be continued"}
    // shapeParam: CIRCLE : Diameter in device pixels
    //              To be cont.
    // lineColor: color for sorrounding line: Either {"red", "green" etc} or hex {"#FF0000", "#00FF00",...}
    // shadowColor: shadow color drawn a bit smaller than the "lineColor" object (E.g second ring)
    // innerColor:  second shadow color drawn a bit smaller than the "shadowColor" object (E.g third ring)
    // fillColor: if null or not passed, shape is not filled, else same syntax as line_color
    // bAppendToCanvas:Optional: if true, DrawingCanvas is not cleared and shapes are added. false or null: canvas cleared 
    // bZoomIfOutside: Optional: if true, map is zoomet to cover either point or poslist
    drawShape: function(Easting, Northing, shapeType, shapeParam, 
                        lineColor, shadowColor, innerColor,fillColor, bAppendToCanvas, bZoomIfOutside){ return false;},
    
    // Same as above but with a position list instead of one location
    //posList = Array() of Array(2) [0]=Easting, [1]=Northing
    //posList[0][0] = Easting of first position, posArr[2][1] = Northing of third position
    drawShapeList: function(posList, shape_type, shape_param, line_color, fill_color, bAppendToCanvas, bZoomIfOutside){ return false;},
    
    // Draw lines in the map
    // p1_easting/northing - First point northing/easting in application coordinates
    // p1_easting/northing - Second point
    // lineThickness in pixels
    // lineColor:  {"red", "green" etc} or hex {"#FF0000", "#00FF00",...}
    // shadowColor: if != null or unknown, "2 pixel" thicker line is drawn behind the line to indicate shadow.
    // bAppendToCanvas:Optional: if true, DrawingCanvas is not cleared and shapes are added. false or null: canvas cleared 
    drawLine: function (p1_easting, p1_northing, p2_easting, p2_northing, lineThickness, lineColor, shadowColor, bAppendToCanvas ){ return false;},
    
    // Same as above but with a position list instead of one location
    //posList = Array() of Array(4) [0]=P1_Easting, [1]=P1_Northing, [2]=P2_Easting, [3]=P2_Northing
    //posList[0][0] = P1_Easting of first position, posArr[2][3] = P2_Northing of third position etc
    drawLineList: function (posList, lineThickness, lineColor, shadowColor, bAppendToCanvas ){ return false;},
    
    //
    // Easting, Northing; World app coordinates
    // image: image URL (relative path to image e.g ./image/myimage.png"
    // text: text to we drawn next  to teh image(NOT implemented yet)
    // hint: hint text when moving cursor over image
    drawImage: function(Easting, Northing, image, text, hint){ return null;},
    
    //
    // return a div relative ti the map which can host a legend
    // null if not supported my mapApi instance
    getLegendContainer: function(){ return null;},
    
    //
    // Initiate digitize operations in map
    // Results are broadcasted as events:
    //
    // evtDigitizedPoint Return data: array[]  len==2 "point" [0]East,[1]North
    // evtDigitizedRect, Return data: array[]  len==2 "point" [0]East,[1]North, len==4 "Rect" [0]LLX, [1]LLY, [2]URX, [3]URY
    // evtDigitizedPolygon, Return data: array[2] len==2. array[0] = []Point array of CV.mBOSS.DAL.Point, 
    //                                                    array[1]={true=clockwise, false=counter clockwise}
    digitizePoint: function(){ return false;},
    digitizeRect: function(){ return false;},
    digitizePolygon: function(){ return false;},
    
    printPreview: function(){ return false;},
    printMap: function(){ return false;},
    
    //
    //location:     Single location description: legal values {LL,LR, UL, UR}
    //Text:         Pipe separated lines of text. example "line1|line2|line3|line4", youcan have as many lines you want
    //visibility:   true/false if the location is visible initially
    //redraw:       true/false - if true the map will redraw
    setMapLabelText: function(location, text, visibility, redraw){ return false;},
    //
    //location:     Pipe separated list of Label locations: example "LL|UL"
    //visibility:   true/false set visibility
    //redraw:       true/false - if true the map will redraw
    setMapLabelVisibility: function(location, visibility, redraw){ return false;},
    
    ///Tools, return CV.mBOSS.DAL.Point()
    worldToDevPoint: function(easting, northing){ return null;},
    
    ///
    /// return an arr[2]
    /// arr[0] = Pipe separated list of active layergroups
    /// arr[1] = Pipe separated list of active data layers
    /// null if layerManager not initialized
    ///
    getListOfActiveLayerGroups: function(){ return null;}
}
MapApiClient.MapApi.registerClass('MapApiClient.MapApi', null, Sys.IDisposable);


