How to use loadData_ method in wpt

Best JavaScript code snippet using wpt

tocModule.js

Source:tocModule.js Github

copy

Full Screen

1var tocModule = function() {2 3 var _olMap;4 var _KEY;5 var _tocDIV;6 var _tocType;7 var _originCRS;8 9 10 var _tocOBJ = {11 WMS : undefined,12 WebWMS : undefined,13 WFS : undefined,14 WCS : undefined,15 WMTS : undefined,16 WebWMTS : undefined17 };18 19 20 var initTOC = function(options_) {21 var tocType = options_["TocType"];22 23 if ( tocType === 'WMS' ) {24 var tocWMS = new toc_WMS();25 tocWMS.init( options_ );26 _tocOBJ["WMS"] = tocWMS;27 } else if ( tocType === 'WebWMS' ) {28 var tocWebWMS = new toc_WebWMS();29 tocWebWMS.init( options_ );30 _tocOBJ["WebWMS"] = tocWMS;31 } else if ( tocType === 'WFS' || tocType === 'WebWFS') {32 var tocWFS = new toc_WFS();33 tocWFS.init( options_ );34 _tocOBJ["WFS"] = tocWFS;35 _tocOBJ["WebWFS"] = tocWFS;36 } else if ( tocType === 'WCS' ) {37 var tocWCS = new toc_WCS();38 tocWCS.init( options_ );39 _tocOBJ["WCS"] = tocWCS;40 } else if ( tocType === 'WMTS' ) {41 var tocWMTS = new toc_WMTS();42 tocWMTS.init( options_ );43 _tocOBJ["WMTS"] = tocWMTS;44 } else if ( tocType === 'WebWMTS' ) {45 var tocWMTS = new toc_WMTS();46 tocWMTS.init( options_ );47 _tocOBJ["WebWMTS"] = tocWMTS;48 }49 };50 51 52 53 54 var _defaultInit = function(options_) {55 _olMap = options_["OlMap"];56 _KEY = options_["KEY"];57 _tocDIV = options_["TocDIV"];58 _tocType = options_["TocType"];59 _originCRS = options_["OriginCRS"];60 };61 62 63 var toc_WMS = function() {64 var _this = this;65 var zTreeLayer;66 var zTreeAttribute;67 var olWMSLayer;68 var showLayerNames;69 70 this.init = function(attribute_) {71 /*72 var options = {73 OlMap : map,74 TocDIV : 'TOC_1',75 TocType : 'WMS',76 OriginCRS : 'EPSG:5181',77 KEY : 'DT_ID_Group_Maple',78 OlWMSLayer : wmsLayer,79 isWebMap : false,80 isLoadData : false,81 LoadData : []82 CallBacks : {83 test : function(data) {84 console.log('CallBack : test');85 console.log(data);86 }87 }88 }89 */90 91 92 /*93 * tocWMS Init94 */95 _defaultInit( attribute_ );96 97 _olMap.on('change:view', function(e) {98 _addUpdateScaleListener();99 });100 101 _this.olWMSLayer = attribute_["OlWMSLayer"];102 _this.zTreeAttribute = new zTreeAttribute_WMS( this );103 _this.zTreeLayer = OBJ_TOC_WMS["createTOC_WMS"]( attribute_, _this.zTreeAttribute["zTreeSetting_WMS"] );104 _addUpdateScaleListener();105 106 107 console.log('### TOC Init ###');108 console.log('TOC Type : ' + _tocType);109 console.log('Projection : ' + _originCRS);110 console.log('zTreeLayer : ' + _this.zTreeLayer);111 112 };113 114 115 this.layerSetVisible = function(e, treeId, treeNode) {116 //console.log( 'testOnCheck : ' + treeNode.id + ' = ' + treeNode.checked ); 117 //console.log( _this.getZtreeLayerData() ); 118 _olWMSLayerRefresh();119 };120 121 this.layerOrderChange = function(treeId, treeNodes, targetNode, moveType) {122 var state = false;123 124 if ( treeNodes[0] ) {125 var tocID = treeNodes[0]["tId"].split('_')[1];126 if ( treeId.split('_')[1] !== tocID ) {127 return false;128 }129 } else {130 return false;131 }132 133 if ( targetNode["isGroupLayer"] ) {134 state = ( targetNode["drop"] ) ? true : false;135 if ( targetNode["LayerName"] === 'ROOT' && moveType !== 'inner' ) {136 state = false;137 }138 } else {139 state = ( moveType !== 'inner' ) ? true : false;140 }141 142 return _layerOrderChange(state);143 }144 145 146 var _layerOrderChange = function(state) {147 if ( state ) {148 _olWMSLayerRefresh();149 }150 return state;151 };152 153 154 155 156 157 this.updateScale = function(layer, scale) {158 if (1) {159 /*if (layer == null) {160 layer = this.rootLayer;161 }*/162 /*if (scale == null) {163 scale = parseFloat( this.map.getView().getResolution() * 72 * 39.3701 );164 }*/165 //if (layer.checked !== false) {166 //layer.checked = true;167 if (!(layer["MinScale"] == 0 || scale >= layer["MinScale"])) {168 layer.scaleCheck = 2;169 } else {170 layer.scaleCheck = 1;171 }172 if (!(layer["MaxScale"] == 0 || scale < layer["MaxScale"])) {173 layer.scaleCheck = 2;174 } else {175 layer.scaleCheck = 1;176 }177 if (layer.scaleCheck == 2) {178 //layer.checkImg.src = getImageLocation("scale_out.gif");179 layer.chkDisabled = true;180 } else {181 //layer.checkImg.src = getImageLocation("check_on.gif");182 layer.chkDisabled = false;183 }184 //}185 var children = layer.children;186 for (var i = 0; i < children.length; i++) {187 var child = children[i];188 //_this.updateScale( child, scale );189 arguments.callee( child, scale );190 }191 }192 };193 194 var _addUpdateScaleListener = function() {195 _olMap.getView().on('change:resolution', _changeResolution);196 _changeResolution();197 };198 199 200 var _changeResolution = function() {201 var scale = parseFloat( _olMap.getView().getResolution() * 72 * 39.3701 );202 203 //console.log( '_changeResolution : ' + scale );204 205 var layers = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0];206 _this.updateScale( layers, scale );207 $.fn.zTree.getZTreeObj( _tocDIV ).refresh();208 _olWMSLayerRefresh();209 }210 211 212 213 214 var _getZtreeLayerData = function(layers, names, type) {215 var layer = [ layers ];216 for (var i in layer) {217 var data = layer[i];218 if ( (type === 'show' && data["checked"] === false) || (type === 'show' && data["chkDisabled"] === true) ) {219 return;220 }221 if ( data.isGroupLayer ) {222 var childs = data["children"];223 for (var j = childs.length; --j >= 0;) {224 var child = childs[j];225 //_getZtreeLayerData( child, names, type );226 arguments.callee( child, names, type );227 }228 } else {229 names.push( data["LayerName"] ); 230 }231 }232 233 return names;234 };235 236 237 var _olWMSLayerRefresh = function() {238 setTimeout(function() {239 _this.olWMSLayer.getSource().getParams().LAYERS = _this.getZtreeLayerData()240 _this.olWMSLayer.getSource().updateParams( _this.olWMSLayer.getSource().getParams() );241 }, 50);242 };243 244 245 this.getZtreeLayerData = function() {246 var layerNames = [];247 var layers = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0]; 248 layerNames = _getZtreeLayerData( layers, layerNames, 'show' );249 layerNames = ( typeof layerNames === 'undefined' ) ? '' : layerNames.toString();250 showLayerNames = layerNames;251 return layerNames;252 };253 254 255 this.getShowLayerNames = function() {256 return showLayerNames;257 };258 259 };260 261 262 263 264 265 266 267 268 var _addDIYDom_WFS = function(treeId, treeNode) {269 270 if ( treeNode["parentNode"] && treeNode["parentNode"]["id"] !== 2 ) return;271 272 var aObj = $("#" + treeNode.tId + '_a');273 //var cbx_FeatureInfoID = 'cbx_FID_' + treeNode.id + '_' + treeNode.tId; 274 //var btn_columnID = 'btn_CID_' + treeNode.id + '_' + treeNode.tId;275 276 var cbx_FeatureInfoID = 'cbx_FID_' + treeNode.tId; 277 var btn_columnID = 'btn_CID_' + treeNode.tId;278 279 aObj.css('clear', 'both');280 aObj.css('height', 'auto');281 var checked = (treeNode.UseFeatureInfo) ? 'checked' : '';282 283 var title = '';284 var columnSetting = '';285 286 if ( typeof i18n === 'function' ) {287 title = i18n('WM043');288 columnSetting = i18n('WM044');289 } else {290 title = '정보조회 활성화';291 columnSetting = '컬럼설정';292 }293 294 var editStr1 = 295 '<div name="wfsInfo" style="margin-left: 35px; line-height:15px;" title="' + title + '" onfocus="this.blur();">' + 296 //'<label>' +297 '<input type="checkbox" style="margin-right: 2px;" id="' + cbx_FeatureInfoID + '"' + checked + '/>' + 298 '<label style="font-weight:normal;font-size:12px; vertical-align:top; margin-top:3px" for="' + cbx_FeatureInfoID + '">' + title + '</label>' + 299 //'</label>' + 300 '</div>';301 var editStr2 = 302 /*303 '<div style="margin-left: 35px; line-height:15px;" title="' + columnSetting + '" onfocus="this.blur();>">' + 304 //'<label>' + 305 '<span style="font-size:12px; vertical-align:top;">' + columnSetting + '</span>' + 306 '<span class="button icon02" id="' + btn_columnID + '"></span>' + 307 //'</label>' + 308 '</div>';309 */310 '<div name="wfsInfo" style="margin-left: 35px; line-height:15px;" title="' + columnSetting + '" onfocus="this.blur();>">' + 311 //'<label>' + 312 '<span style="cursor: pointer; "id="' + btn_columnID + '">' + 313 '<i class="icon-gwp-admin icon-gwp-sm"></i>' + 314 '<span style="font-size: 12px; vertical-align:top; margin-left: 2px;">' + columnSetting + '</span>' + 315 '</span>' + 316 //'</label>' + 317 '</div>';318 319 aObj.after(editStr2);320 aObj.after(editStr1);321 322 323 324 325 326 var check = $("#" + cbx_FeatureInfoID);327 if ( check ) {328 check.on('change', function() {329 var treeObj = $.fn.zTree.getZTreeObj( _tocDIV );330 treeNode["UseFeatureInfo"] = check.is(":checked");331 treeObj.updateNode( treeNode );332 333 334 _tocOBJ[_tocType].callBacks.setEnableLayer( _tocOBJ[_tocType].olWFSLayer, check.is(":checked") );335 336 337 });338 }339 340 341 342 var btn = $("#" + btn_columnID);343 344 if ( btn ) {345 btn.on('click', function() {346 var treeObj = $.fn.zTree.getZTreeObj( _tocDIV );347 348 //treeNode["UseFeatureInfo"] = !treeNode["UseFeatureInfo"]; 349 //treeObj.updateNode( treeNode );350 351 352 /*353 var obj = {354 originFields : [355 'col1', 'col2', 'col4'356 ],357 userFields : {358 col1 : 'col1_user',359 col2 : 'col2_user',360 col3 : 'col3_user'361 },362 commit : function(el1) {363 console.log( el1 );364 console.log( treeObj );365 }366 };367 */368 369 370 var updateData = function(userProperties_) {371 _tocOBJ[_tocType]["olWFSLayer"].set("UserProperties", userProperties_)372 treeNode["UserProperties"] = userProperties_;373 treeObj.updateNode( treeNode );374 };375 376 377 _tocOBJ[_tocType].callBacks.setUserProperties( updateData );378 379 380 });381 }382 383 };384 385 386 387 388 389 390 391 392 393 var _addDIYDom_WMS = function(treeId, treeNode) {394 if ( treeNode["parentNode"] && treeNode["parentNode"]["id"] !== 2 ) return;395 396 var aObj = $("#" + treeNode.tId + '_a');397 if ( treeNode["LegendURL"] !== null && treeNode["LegendURL"] !== undefined ) {398 aObj.css('clear', 'both');399 aObj.css('height', 'auto');400 var editStr = "<br><img src='" + treeNode["LegendURL"] + "'>";401 aObj.append( editStr );402 _setLegendExpand( aObj );403 }404 };405 var _setLegendExpand = function(aObj) {406 var level = aObj.attr('class');407 var cl = 'button ' + level + ' swith bottom_';408 var btn = aObj.parent().find('span').eq(0);409 btn.removeClass();410 var OPEN = 'open';411 var CLOSE = 'close';412 btn.addClass(cl + OPEN);413 btn.attr('state', OPEN);414 btn.on('click', function() {415 var state = $(this).attr('state');416 if ( state === 'open' ) {417 aObj.find('img').hide();418 btn.removeClass();419 btn.addClass(cl + CLOSE);420 btn.attr('state', CLOSE);421 } else if ( state === 'close' ) {422 aObj.find('img').show();423 btn.removeClass();424 btn.addClass(cl + OPEN);425 btn.attr('state', OPEN);426 }427 });428 };429 430 431 432 433 var zTreeAttribute_WMS = function(toc_WMS_) {434 var zTreeSetting_WMS = {435 view : {436 selectedMulti : false,437 expandSpeed : 'fast',438 addDiyDom : _addDIYDom_WMS439 },440 check : {441 autoCheckTrigger : true,442 enable : true,443 chkboxType : { "Y" : "", "N" : "" }444 },445 data : {446 simpleData : {447 enable : true448 }449 },450 edit : {451 enable : true,452 showRemoveBtn : false,453 showRenameBtn : false454 },455 callback : {456 onCheck: toc_WMS_.layerSetVisible,457 beforeDrop : toc_WMS_.layerOrderChange,458 //onCollapse : onCollapse,459 //onExpand : onExpand460 },461 async : {462 enable : true463 }464 };465 466 return {467 zTreeSetting_WMS : zTreeSetting_WMS468 }469 };470 471 472 473 474 var OBJ_TOC_WMS = {475 476 createTOC_WMS : function(attribute_, zTreeSetting_WMS_) {477 var wmsZtreeLayer;478 var originWMSztreeLayer = this.getWMSNodeTozTree( this.getWMSLayerData( attribute_ )["Layers"] );479 480 if ( attribute_["isWebMap"] ) {481 var noneGroupLayers = _getNoneGroupLayers( originWMSztreeLayer, [] );482 originWMSztreeLayer["children"] = noneGroupLayers;483 wmsZtreeLayer = originWMSztreeLayer;484 485 if ( attribute_["isLoadData"] ) {486 wmsZtreeLayer = this.getLoadData( originWMSztreeLayer, attribute_["LoadData"]["Layers"] );487 }488 489 } else {490 wmsZtreeLayer = originWMSztreeLayer; 491 }492 493 $.fn.zTree.init( $("#" + _tocDIV ), zTreeSetting_WMS_, wmsZtreeLayer );494 495 return wmsZtreeLayer;496 },497 498 getWMSLayerData : function(attribute_) {499 /*500 var attribute = {501 CRS : 'EPSG:3857',502 KEY : 'DT_ID_1',503 BaseMapType : 'daum_normal',504 capabilitiesJSON : {}505 };506 */507 var wmsLayerData = {508 CRS : attribute_["CRS"],509 KEY : attribute_["KEY"],510 BaseMapType : attribute_["BaseMapType"],511 //FullExtent : [0.0, 0.0, 0.0, 0.0],512 ViewExtent : [0.0, 0.0, 0.0, 0.0],513 isViewExtent : false,514 Layers : []515 };516 var capabilitiesJSON = attribute_["CapabilitiesJSON"]["WMS_Capabilities"]["Capability"]["Layer"];517 var layers = this.getWMSCapabilitieLayerData( [ capabilitiesJSON ] );518 wmsLayerData["Layers"].push( layers );519 return wmsLayerData;520 },521 522 getWMSCapabilitieLayerData : function(node_) {523 var layerData = {524 LayerName : layerName,525 Title : title,526 Extent : extent,527 MinScale : minScale,528 MaxScale : maxScale,529 LegendURL : legendURL,530 isGroupLayer : false,531 isVisible : true,532 ChildLayers: []533 };534 for(var i in node_) {535 var title = node_[i]["Title"]["#text"];536 var layerName = node_[i]["Name"]["#text"];537 var extent = node_[i]["BoundingBox"]["@attributes"];538 extent = [539 parseFloat(extent["minx"]),540 parseFloat(extent["miny"]),541 parseFloat(extent["maxx"]),542 parseFloat(extent["maxy"])543 ];544 var minScale = node_[i]["MinScaleDenominator"]["#text"];545 minScale = parseFloat( minScale );546 var maxScale = node_[i]["MaxScaleDenominator"];547 if ( typeof maxScale !== 'undefined' ) {548 maxScale = parseFloat( maxScale["#text"] );549 }550 var style = node_[i]["Style"];551 var legendURL;552 if ( typeof style !== 'undefined' ) {553 if ( typeof style["LegendURL"] !== 'undefined' ) {554 legendURL = style["LegendURL"]["OnlineResource"]["@attributes"]["xlink:href"];555 } 556 }557 var childLayer = node_[i]["Layer"];558 559 if ( !Array.isArray( childLayer ) && typeof childLayer !== 'undefined') {560 childLayer = [ childLayer ];561 }562 if ( Array.isArray( childLayer ) ) {563 layerData["isGroupLayer"] = true;564 for (var j=childLayer.length; --j >= 0;) {565 //layerData["ChildLayers"].push( this.getWMSCapabilitieLayerData( [ childLayer[j] ] ) );566 layerData["ChildLayers"].push( arguments.callee( [ childLayer[j] ] ) );567 }568 }569 570 layerData["LayerName"] = layerName;571 layerData["Title"] = title;572 layerData["Extent"] = extent;573 layerData["MinScale"] = minScale;574 layerData["MaxScale"] = maxScale;575 layerData["LegendURL"] = legendURL;576 577 }578 return layerData;579 },580 581 getWMSNodeTozTree : function(node_) {582 583 var layer = {584 id : null,585 name : null,586 //title : null,587 children : [], 588 open : false,589 drop : true,590 //inner : true,591 checked : true, 592 LayerName : null,593 isGroupLayer : false,594 LegendURL : null,595 MinScale : 0,596 MaxScale : 0,597 Extent : null,598 scaleCheck : 1,599 chkDisabled : false,600 //isAddedLayer : false,601 //isDeletedLayer : false602 };603 for(var i in node_) {604 /*605 var node = {606 LayerName : layerName,607 Title : title,608 Extent : extent,609 MinScale : minScale,610 MaxScale : maxScale,611 LegendURL : legendURL,612 isGroupLayer : false,613 isVisible : true,614 Opacity : 1.0,615 ChildLayers: []616 };617 */618 layer["name"] = node_[i]["Title"];619 layer["id"] = node_[i]["LayerName"];620 layer["LayerName"] = node_[i]["LayerName"];621 if ( layer["id"] === 'ROOT' ) {622 layer["open"] = true;623 }624 layer["LegendURL"] = node_[i]["LegendURL"];625 var minScale = node_[i]["MinScale"];626 if ( typeof minScale !== 'undefined' ) {627 layer["MinScale"] = minScale;628 }629 var maxScale = node_[i]["MaxScale"];630 if ( typeof maxScale !== 'undefined' ) {631 layer["MaxScale"] = maxScale;632 }633 layer["Extent"] = node_[i]["Extent"];634 layer["isGroupLayer"] = node_[i]["isGroupLayer"];635 636 var childLayers = node_[i]["ChildLayers"];637 if ( childLayers.length > 0 ) {638 //for (var j=child.length; --j >= 0;) {639 for(var j=0; j<childLayers.length; j++) {640 //layer["children"].push( this.getWMSNodeTozTree( [ childLayers[j] ] ) );641 layer["children"].push( arguments.callee( [ childLayers[j] ] ) );642 643 }644 } else {645 //layer["inner"] = false;646 layer["drop"] = false;647 }648 }649 return layer;650 },651 652 653 getLoadData : function(originWMSztreeLayer_, loadData_) {654 var reLoadData = [];655 var noneGroupLayers_origin = [];656 noneGroupLayers_origin = _getNoneGroupLayers( originWMSztreeLayer_, noneGroupLayers_origin );657 /*658 for(var i in noneGroupLayers_origin) {659 var originLayer = noneGroupLayers_origin[i];660 for(var j in loadData_) {661 var loadLayer = loadData_[j];662 if ( originLayer["LayerName"] === loadLayer["LayerName"] ) {663 originLayer["checked"] = loadLayer["checked"];664 }665 }666 }667 */668 var temp = [];669 for(var i in loadData_) {670 var loadLayer = loadData_[i];671 for(var j in noneGroupLayers_origin) {672 var originLayer = noneGroupLayers_origin[j];673 if ( originLayer["LayerName"] === loadLayer["LayerName"] ) {674 originLayer["checked"] = loadLayer["checked"];675 temp.push( noneGroupLayers_origin.slice( j, j+1 )[0] );676 noneGroupLayers_origin.splice( j, 1 );677 }678 }679 }680 681 reLoadData = noneGroupLayers_origin.concat( temp );682 683 originWMSztreeLayer_["children"] = reLoadData;684 685 return originWMSztreeLayer_;686 }687 688 };689 var toc_WFS = function() {690 var _this = this;691 var zTreeLayer;692 var zTreeAttribute;693 var olWFSLayer;694 var callBacks;695 696 this.init = function(attribute_) {697 /*698 var options = {699 OlMap : map,700 TocDIV : 'TOC_1',701 TocType : 'WFS',702 OriginCRS : 'EPSG:5181',703 KEY : 'DT_ID_Group_Maple',704 OlWFSLayer : wfsLayer,705 LayerName : 'LV14_SCCO_EMD',706 LayerTitle : 'LV14_SCCO_EMD-Title',707 authority : false, // toc 컨트롤 권한708 isWebMap : false,709 isLoadData : false,710 LoadData : {711 Checked : false,712 UserProperties713 Style : {714 LineColor : '',715 LineWidth : 10716 // To do - 스타일717 }718 },719 CallBacks : {720 test : function(data) {721 console.log('CallBack : test');722 console.log(data);723 }724 }725 }726 */727 728 729 /*730 * tocWFS Init731 */732 _defaultInit( attribute_ );733 _this.olWFSLayer = attribute_["OlWFSLayer"];734 _this.callBacks = attribute_["CallBacks"];735 _this.zTreeAttribute = new zTreeAttribute_WFS( this );736 _this.zTreeLayer = OBJ_TOC_WFS["createTOC_WFS"]( attribute_, _this.zTreeAttribute["zTreeSetting_WFS"] ); 737 738 _olWFSLayerRefresh();739 740 console.log('### TOC Init ###');741 console.log('TOC Type : ' + _tocType);742 console.log('Projection : ' + _originCRS);743 console.log('zTreeLayer : ' + _this.zTreeLayer);744 };745 746 747 this.layerSetVisible = function(e, treeId, treeNode) {748 _this.olWFSLayer.setVisible( !(_this.olWFSLayer.getVisible()) );749 };750 751 752 var _olWFSLayerRefresh = function() {753 _this.olWFSLayer.setVisible( _this.getZtreeLayerWFSchecked() );754 };755 756 757 this.getZtreeLayerWFSchecked = function() {758 var layer = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0]; 759 return layer["checked"];760 };761 };762 763 var zTreeAttribute_WFS = function(toc_WFS_) {764 var zTreeSetting_WFS = {765 view : {766 selectedMulti : false,767 expandSpeed : 'fast',768 addDiyDom : _addDIYDom_WFS769 },770 check : {771 enable : true,772 chkboxType : { "Y" : "", "N" : "" }773 },774 data : {775 simpleData : {776 enable : true777 }778 },779 edit : {780 enable : true,781 showRemoveBtn : false,782 showRenameBtn : false783 },784 callback : {785 onCheck: toc_WFS_.layerSetVisible786 },787 async : {788 enable : true789 }790 };791 792 return {793 zTreeSetting_WFS : zTreeSetting_WFS794 }795 };796 var OBJ_TOC_WFS = {797 798 createTOC_WFS : function(attribute_, zTreeSetting_WFS_) {799 var wfsZtreeLayer;800 var originWFSztreeLayer = this.getWFSNodeTozTree( this.getWFSLayerData( attribute_ ) );801 802 if ( attribute_["isWebMap"] ) {803 wfsZtreeLayer = originWFSztreeLayer;804 805 if ( attribute_["isLoadData"] ) {806 wfsZtreeLayer = this.getLoadData( originWFSztreeLayer, attribute_["LoadData"] );807 }808 809 } else {810 wfsZtreeLayer = originWFSztreeLayer; 811 }812 813 $.fn.zTree.init( $("#" + _tocDIV ), zTreeSetting_WFS_, wfsZtreeLayer );814 815 return wfsZtreeLayer;816 },817 818 getWFSLayerData : function(attribute_) {819 /*820 var attribute = {821 CRS : 'EPSG:3857',822 KEY : 'DT_ID_1',823 //BaseMapType : 'daum_normal',824 LayerName : 'LV14_SCCO_EMD'825 };826 */827 var wfsLayerData = {828 CRS : attribute_["CRS"],829 KEY : attribute_["KEY"],830 LayerName : attribute_["LayerName"],831 LayerTitle : attribute_["LayerTitle"]832 };833 return wfsLayerData;834 },835 836 getWFSNodeTozTree : function(attribute_) {837 838 var layer = {839 id : attribute_["LayerName"],840 name : attribute_["LayerTitle"],841 //title : null,842 children : [],843 open : true,844 drop : false,845 inner : false,846 checked : true,847 LayerName : attribute_["LayerName"],848 isGroupLayer : false,849 LegendURL : null,850 Extent : null,851 chkDisabled : false,852 UseFeatureInfo : true,853 UserProperties : {854 UseYN : false,855 Properties : {856 857 }858 }859 };860 return layer;861 },862 863 864 getLoadData : function(originWFSztreeLayer_, loadData_) {865 var loadztreeLayer;866 867 originWFSztreeLayer_["checked"] = loadData_["Layers"][0]["checked"];868 originWFSztreeLayer_["UseFeatureInfo"] = loadData_["UseFeatureInfo"];869 originWFSztreeLayer_["UserProperties"] = loadData_["UserProperties"];870 871 // To do - 스타일872 873 874 loadztreeLayer = originWFSztreeLayer_;875 876 return loadztreeLayer;877 }878 879 };880 var toc_WCS = function() {881 var _this = this;882 var zTreeLayer;883 var zTreeAttribute;884 var olWCSLayer;885 var callBacks;886 887 this.init = function(attribute_) {888 /*889 var options = {890 OlMap : map,891 TocDIV : 'TOC_1',892 TocType : 'WCS',893 OriginCRS : 'EPSG:5181',894 KEY : 'DT_ID_Group_Maple',895 OlWCSLayer : wcsLayer,896 Coverage : 'LV14_SCCO_EMD.jpg',897 isWebMap : false,898 isLoadData : false,899 LoadData : {900 Checked : false901 },902 CallBacks : {903 test : function(data) {904 console.log('CallBack : test');905 console.log(data);906 }907 }908 }909 */910 911 912 /*913 * tocWCS Init914 */915 _defaultInit( attribute_ );916 _this.olWCSLayer = attribute_["OlWCSLayer"];917 _this.callBacks = attribute_["CallBacks"];918 _this.zTreeAttribute = new zTreeAttribute_WCS( this );919 _this.zTreeLayer = OBJ_TOC_WCS["createTOC_WCS"]( attribute_, _this.zTreeAttribute["zTreeSetting_WCS"] ); 920 921 _olWCSLayerRefresh();922 923 console.log('### TOC Init ###');924 console.log('TOC Type : ' + _tocType);925 console.log('Projection : ' + _originCRS);926 console.log('zTreeLayer : ' + _this.zTreeLayer);927 };928 929 930 this.layerSetVisible = function(e, treeId, treeNode) {931 _this.olWCSLayer.setVisible( !(_this.olWCSLayer.getVisible()) );932 };933 934 935 var _olWCSLayerRefresh = function() {936 _this.olWCSLayer.setVisible( _this.getZtreeLayerWCSchecked() );937 };938 939 940 this.getZtreeLayerWCSchecked = function() {941 var layer = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0]; 942 return layer["checked"];943 };944 };945 946 var zTreeAttribute_WCS = function(toc_WCS_) {947 var zTreeSetting_WCS = {948 view : {949 selectedMulti : false,950 expandSpeed : 'fast',951 addDiyDom : _addDIYDom_WMS952 },953 check : {954 enable : true,955 chkboxType : { "Y" : "", "N" : "" }956 },957 data : {958 simpleData : {959 enable : true960 }961 },962 edit : {963 enable : true,964 showRemoveBtn : false,965 showRenameBtn : false966 },967 callback : {968 onCheck: toc_WCS_.layerSetVisible969 },970 async : {971 enable : true972 }973 };974 975 return {976 zTreeSetting_WCS : zTreeSetting_WCS977 }978 };979 var OBJ_TOC_WCS = {980 981 createTOC_WCS : function(attribute_, zTreeSetting_WCS_) {982 var wcsZtreeLayer;983 var originWCSztreeLayer = this.getWCSNodeTozTree( this.getWCSLayerData( attribute_ ) );984 985 if ( attribute_["isWebMap"] ) {986 wcsZtreeLayer = originWCSztreeLayer;987 988 if ( attribute_["isLoadData"] ) {989 wcsZtreeLayer = this.getLoadData( originWCSztreeLayer, attribute_["LoadData"] );990 }991 992 } else {993 wcsZtreeLayer = originWCSztreeLayer;994 }995 996 $.fn.zTree.init( $("#" + _tocDIV ), zTreeSetting_WCS_, wcsZtreeLayer );997 998 return wcsZtreeLayer;999 },1000 1001 getWCSLayerData : function(attribute_) {1002 /*1003 var attribute = {1004 CRS : 'EPSG:3857',1005 KEY : 'DT_ID_1',1006 //BaseMapType : 'daum_normal',1007 Coverage : 'LV14_SCCO_EMD.jpg'1008 };1009 */1010 var wcsLayerData = {1011 CRS : attribute_["CRS"],1012 KEY : attribute_["KEY"],1013 Coverage : attribute_["Coverage"]1014 };1015 return wcsLayerData;1016 },1017 1018 getWCSNodeTozTree : function(attribute_) {1019 1020 var layer = {1021 id : attribute_["Coverage"],1022 name : attribute_["Coverage"],1023 //title : null,1024 children : [],1025 open : true,1026 drop : false,1027 inner : false,1028 checked : true,1029 Coverage : attribute_["Coverage"],1030 isGroupLayer : false,1031 LegendURL : null,1032 Extent : null,1033 chkDisabled : false1034 };1035 return layer;1036 },1037 1038 1039 getLoadData : function(originWCSztreeLayer_, loadData_) {1040 var loadztreeLayer;1041 1042 originWCSztreeLayer_["checked"] = loadData_["Layers"][0]["checked"]; 1043 1044 loadztreeLayer = originWCSztreeLayer_;1045 1046 return loadztreeLayer;1047 }1048 1049 };1050 1051 var toc_WebWMS = function() {1052 var _this = this;1053 var zTreeLayer;1054 var zTreeAttribute;1055 var olWMSLayer;1056 1057 this.init = function(attribute_) {1058 /*1059 var options = {1060 OlMap : map,1061 TocDIV : 'TOC_1',1062 TocType : 'WebWMS',1063 OriginCRS : 'EPSG:5181',1064 KEY : 'http://geonuris?wms',1065 OlWMSLayer : wmsLayer,1066 isWebMap : false,1067 isLoadData : false,1068 LoadData : []1069 CallBacks : {1070 test : function(data) {1071 console.log('CallBack : test');1072 console.log(data);1073 }1074 }1075 }1076 */1077 1078 1079 /*1080 * tocWebWMS Init1081 */1082 _defaultInit( attribute_ );1083 1084 _olMap.on('change:view', function(e) {1085 _addUpdateScaleListener();1086 });1087 1088 _this.olWMSLayer = attribute_["OlWMSLayer"];1089 _this.zTreeAttribute = new zTreeAttribute_WebWMS( this );1090 _this.zTreeLayer = OBJ_TOC_WebWMS["createTOC_WebWMS"]( attribute_, _this.zTreeAttribute["zTreeSetting_WebWMS"] );1091 _addUpdateScaleListener();1092 1093 1094 console.log('### TOC Init ###');1095 console.log('TOC Type : ' + _tocType);1096 console.log('Projection : ' + _originCRS);1097 console.log('zTreeLayer : ' + _this.zTreeLayer);1098 1099 };1100 1101 1102 this.layerSetVisible = function(e, treeId, treeNode) {1103 //console.log( 'testOnCheck : ' + treeNode.id + ' = ' + treeNode.checked ); 1104 //console.log( _this.getZtreeLayerData() ); 1105 _olWMSLayerRefresh();1106 };1107 1108 this.layerOrderChange = function(treeId, treeNodes, targetNode, moveType) {1109 var state = false;1110 1111 if ( treeNodes[0] ) {1112 var tocID = treeNodes[0]["tId"].split('_')[1];1113 if ( treeId.split('_')[1] !== tocID ) {1114 return false;1115 }1116 } else {1117 return false;1118 }1119 1120 if ( targetNode["isGroupLayer"] ) {1121 state = ( targetNode["drop"] ) ? true : false;1122 if ( targetNode["LayerName"] === 'ROOT' && moveType !== 'inner' ) {1123 state = false;1124 }1125 } else {1126 state = ( moveType !== 'inner' ) ? true : false;1127 }1128 1129 return _layerOrderChange(state);1130 }1131 1132 1133 var _layerOrderChange = function(state) {1134 if ( state ) {1135 _olWMSLayerRefresh();1136 }1137 return state;1138 };1139 1140 1141 1142 1143 1144 this.updateScale = function(layer, scale) {1145 if (1) {1146 /*if (layer == null) {1147 layer = this.rootLayer;1148 }*/1149 /*if (scale == null) {1150 scale = parseFloat( this.map.getView().getResolution() * 72 * 39.3701 );1151 }*/1152 //if (layer.checked !== false) {1153 //layer.checked = true;1154 if (!(layer["MinScale"] == 0 || scale >= layer["MinScale"])) {1155 layer.scaleCheck = 2;1156 } else {1157 layer.scaleCheck = 1;1158 }1159 if (!(layer["MaxScale"] == 0 || scale < layer["MaxScale"])) {1160 layer.scaleCheck = 2;1161 } else {1162 layer.scaleCheck = 1;1163 }1164 if (layer.scaleCheck == 2) {1165 //layer.checkImg.src = getImageLocation("scale_out.gif");1166 layer.chkDisabled = true;1167 } else {1168 //layer.checkImg.src = getImageLocation("check_on.gif");1169 layer.chkDisabled = false;1170 }1171 //}1172 var children = layer.children;1173 for (var i = 0; i < children.length; i++) {1174 var child = children[i];1175 //_this.updateScale( child, scale );1176 arguments.callee( child, scale );1177 }1178 }1179 };1180 1181 var _addUpdateScaleListener = function() {1182 _olMap.getView().on('change:resolution', _changeResolution);1183 _changeResolution();1184 };1185 1186 1187 var _changeResolution = function() {1188 var scale = parseFloat( _olMap.getView().getResolution() * 72 * 39.3701 );1189 1190 c//onsole.log( '_changeResolution : ' + scale );1191 1192 var layers = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0];1193 _this.updateScale( layers, scale );1194 $.fn.zTree.getZTreeObj( _tocDIV ).refresh();1195 _olWMSLayerRefresh();1196 }1197 1198 1199 1200 1201 var _getZtreeLayerData = function(layers, names, type) {1202 var layer = [ layers ];1203 for (var i in layer) {1204 var data = layer[i];1205 if ( (type === 'show' && data["checked"] === false) || (type === 'show' && data["chkDisabled"] === true) ) {1206 return;1207 }1208 if ( data.isGroupLayer ) {1209 var childs = data["children"];1210 for (var j = childs.length; --j >= 0;) {1211 var child = childs[j];1212 //_getZtreeLayerData( child, names, type );1213 arguments.callee( child, names, type );1214 }1215 } else {1216 names.push( data["LayerName"] ); 1217 }1218 }1219 1220 return names;1221 };1222 1223 1224 var _olWMSLayerRefresh = function() {1225 setTimeout(function() {1226 _this.olWMSLayer.getSource().getParams().LAYERS = _this.getZtreeLayerData()1227 _this.olWMSLayer.getSource().updateParams( _this.olWMSLayer.getSource().getParams() );1228 1229 if ( _this.olWMSLayer.getSource().getParams().LAYERS === '' ) {1230 _this.olWMSLayer.setVisible("false");1231 } else {1232 if ( !(_this.olWMSLayer.getVisible()) ) {1233 _this.olWMSLayer.setVisible("true");1234 }1235 }1236 1237 }, 50);1238 };1239 1240 1241 this.getZtreeLayerData = function() {1242 var layerNames = [];1243 var layers = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0]; 1244 layerNames = _getZtreeLayerData( layers, layerNames, 'show' );1245 1246 return ( typeof layerNames === 'undefined' ) ? '' : layerNames.toString();1247 };1248 1249 };1250 var zTreeAttribute_WebWMS = function(toc_WebWMS_) {1251 var zTreeSetting_WebWMS = {1252 view : {1253 selectedMulti : false,1254 expandSpeed : 'fast',1255 addDiyDom : _addDIYDom_WMS1256 },1257 check : {1258 //autoCheckTrigger : true,1259 enable : true,1260 chkboxType : { "Y" : "", "N" : "" }1261 },1262 data : {1263 simpleData : {1264 enable : true1265 }1266 },1267 edit : {1268 enable : true,1269 showRemoveBtn : false,1270 showRenameBtn : false1271 },1272 callback : {1273 onCheck: toc_WebWMS_.layerSetVisible,1274 beforeDrop : toc_WebWMS_.layerOrderChange,1275 //onCollapse : onCollapse,1276 //onExpand : onExpand1277 },1278 async : {1279 enable : true1280 }1281 };1282 1283 return {1284 zTreeSetting_WebWMS : zTreeSetting_WebWMS1285 }1286 };1287 1288 1289 1290 1291 var OBJ_TOC_WebWMS = {1292 1293 createTOC_WebWMS : function(attribute_, zTreeSetting_WebWMS_) {1294 var webWMSZtreeLayer;1295 var originWebWMSztreeLayer = this.getWebWMSNodeTozTree( this.getWebWMSLayerData( attribute_ )["Layers"] );1296 1297 if ( attribute_["isWebMap"] ) {1298 var noneGroupLayers = _getNoneGroupLayers( originWebWMSztreeLayer, [] );1299 originWebWMSztreeLayer["children"] = noneGroupLayers;1300 webWMSZtreeLayer = originWebWMSztreeLayer;1301 1302 if ( attribute_["isLoadData"] ) {1303 var layerNames = [];1304 for(var i in attribute_["LoadData"]["Layers"]) {1305 layerNames.push( attribute_["LoadData"]["Layers"][i]["LayerName"] );1306 }1307 1308 webWMSZtreeLayer = this.getSelectLayers( webWMSZtreeLayer, layerNames );1309 1310 webWMSZtreeLayer = this.getLoadData( webWMSZtreeLayer, attribute_["LoadData"]["Layers"] );1311 }1312 1313 } else {1314 webWMSZtreeLayer = originWebWMSztreeLayer;1315 }1316 1317 if ( attribute_["SelectLayers"] !== undefined ) {1318 webWMSZtreeLayer = this.getSelectLayers( webWMSZtreeLayer, attribute_["SelectLayers"] );1319 }1320 1321 $.fn.zTree.init( $("#" + _tocDIV ), zTreeSetting_WebWMS_, webWMSZtreeLayer );1322 1323 return webWMSZtreeLayer;1324 },1325 1326 getWebWMSLayerData : function(attribute_) {1327 /*1328 var attribute = {1329 CRS : 'EPSG:3857',1330 KEY : 'DT_ID_1',1331 BaseMapType : 'daum_normal',1332 capabilitiesJSON : {}1333 };1334 */1335 var webWMSLayerData = {1336 CRS : attribute_["CRS"],1337 //KEY : attribute_["KEY"],1338 BaseMapType : attribute_["BaseMapType"],1339 //FullExtent : [0.0, 0.0, 0.0, 0.0],1340 ViewExtent : [0.0, 0.0, 0.0, 0.0],1341 isViewExtent : false,1342 Layers : []1343 };1344 var capabilitiesJSON = attribute_["CapabilitiesJSON"]["WMS_Capabilities"]["Capability"]["Layer"];1345 var layers = this.getWebWMSCapabilitieLayerData( [ capabilitiesJSON ] );1346 webWMSLayerData["Layers"].push( layers );1347 return webWMSLayerData;1348 },1349 1350 getWebWMSCapabilitieLayerData : function(node_) {1351 var layerData = {1352 LayerName : layerName,1353 Title : title,1354 Extent : extent,1355 MinScale : minScale,1356 MaxScale : maxScale,1357 LegendURL : legendURL,1358 isGroupLayer : false,1359 isVisible : true,1360 ChildLayers: []1361 };1362//debugger;1363 for(var i in node_) {1364 var title = node_[i]["Title"];1365 if ( typeof title !== 'undefined' ) {1366 title = title["#text"];1367 }1368 var layerName = node_[i]["Name"];1369 if ( typeof layerName !== 'undefined' ) {1370 layerName = layerName["#text"];1371 }1372 var extent = node_[i]["BoundingBox"];1373 if ( typeof extent !== 'undefined' ) {1374 if ( Array.isArray( extent ) ) {1375 extent = extent[0];1376 }1377 extent = extent["@attributes"];1378 extent = [1379 parseFloat(extent["minx"]),1380 parseFloat(extent["miny"]),1381 parseFloat(extent["maxx"]),1382 parseFloat(extent["maxy"])1383 ];1384 }1385 var minScale = node_[i]["MinScaleDenominator"];1386 if ( typeof minScale !== 'undefined' ) {1387 minScale = parseFloat( minScale["#text"] );1388 }1389 var maxScale = node_[i]["MaxScaleDenominator"];1390 if ( typeof maxScale !== 'undefined' ) {1391 maxScale = parseFloat( maxScale["#text"] );1392 }1393 var style = node_[i]["Style"];1394 var legendURL;1395 if ( typeof style !== 'undefined' ) {1396 1397 if ( Array.isArray( style ) ) {1398 style = style[0];1399 }1400 1401 if ( typeof style["LegendURL"] !== 'undefined' ) {1402 legendURL = style["LegendURL"]["OnlineResource"]["@attributes"]["xlink:href"];1403 }1404 }1405 var childLayer = node_[i]["Layer"];1406 1407 if ( !Array.isArray( childLayer ) && typeof childLayer !== 'undefined' ) {1408 childLayer = [ childLayer ];1409 }1410 if ( Array.isArray( childLayer ) ) {1411 layerData["isGroupLayer"] = true;1412 for (var j=childLayer.length; --j >= 0;) {1413 //layerData["ChildLayers"].push( this.getWMSCapabilitieLayerData( [ childLayer[j] ] ) );1414 layerData["ChildLayers"].push( arguments.callee( [ childLayer[j] ] ) );1415 }1416 }1417 1418 layerData["LayerName"] = layerName;1419 layerData["Title"] = title;1420 layerData["Extent"] = extent;1421 layerData["MinScale"] = minScale;1422 layerData["MaxScale"] = maxScale;1423 layerData["LegendURL"] = legendURL;1424 1425 }1426 return layerData;1427 },1428 1429 getWebWMSNodeTozTree : function(node_) {1430 1431 var layer = {1432 id : null,1433 name : null,1434 //title : null,1435 children : [], 1436 open : false,1437 drop : true,1438 //inner : true,1439 checked : true, 1440 LayerName : null,1441 isGroupLayer : false,1442 LegendURL : null,1443 MinScale : 0,1444 MaxScale : 0,1445 Extent : null,1446 scaleCheck : 1,1447 chkDisabled : false,1448 //isAddedLayer : false,1449 //isDeletedLayer : false1450 };1451 var cnt = 0;1452 1453 for(var i in node_) {1454 ++cnt;1455 /*1456 var node = {1457 LayerName : layerName,1458 Title : title,1459 Extent : extent,1460 MinScale : minScale,1461 MaxScale : maxScale,1462 LegendURL : legendURL,1463 isGroupLayer : false,1464 isVisible : true,1465 Opacity : 1.0,1466 ChildLayers: []1467 };1468 */1469 layer["name"] = node_[i]["Title"];1470 layer["id"] = node_[i]["LayerName"];1471 layer["LayerName"] = node_[i]["LayerName"];1472 if ( layer["id"] === 'ROOT' || cnt == 1 ) {1473 layer["open"] = true;1474 }1475 layer["LegendURL"] = node_[i]["LegendURL"];1476 var minScale = node_[i]["MinScale"];1477 if ( typeof minScale !== 'undefined' ) {1478 layer["MinScale"] = minScale;1479 }1480 var maxScale = node_[i]["MaxScale"];1481 if ( typeof maxScale !== 'undefined' ) {1482 layer["MaxScale"] = maxScale;1483 }1484 layer["Extent"] = node_[i]["Extent"];1485 layer["isGroupLayer"] = node_[i]["isGroupLayer"];1486 1487 var childLayers = node_[i]["ChildLayers"];1488 if ( childLayers.length > 0 ) {1489 //for (var j=child.length; --j >= 0;) {1490 for(var j=0; j<childLayers.length; j++) {1491 //layer["children"].push( this.getWMSNodeTozTree( [ childLayers[j] ] ) );1492 layer["children"].push( arguments.callee( [ childLayers[j] ] ) );1493 1494 }1495 } else {1496 //layer["inner"] = false;1497 layer["drop"] = false;1498 }1499 }1500 return layer;1501 },1502 1503 1504 getSelectLayers : function(originWebWMSztreeLayer_, selectLayers_) {1505 var reLoadData = [];1506 var noneGroupLayers_origin = [];1507 noneGroupLayers_origin = _getNoneGroupLayers( originWebWMSztreeLayer_, noneGroupLayers_origin );1508 1509 var temp = [];1510 for(var i in selectLayers_) {1511 var selectLayerName = selectLayers_[i];1512 for(var j in noneGroupLayers_origin) {1513 var originLayer = noneGroupLayers_origin[j];1514 if ( originLayer["LayerName"] === selectLayerName ) {1515 //originLayer["checked"] = false;1516 temp.push( noneGroupLayers_origin.slice( j, j+1 )[0] );1517 noneGroupLayers_origin.splice( j, 1 );1518 }1519 }1520 }1521 1522 //reLoadData = noneGroupLayers_origin.concat( temp );1523 reLoadData = temp;1524 1525 originWebWMSztreeLayer_["children"] = reLoadData;1526 1527 return originWebWMSztreeLayer_;1528 },1529 1530 1531 getLoadData : function(originWebWMSztreeLayer_, loadData_) {1532 var reLoadData = [];1533 var noneGroupLayers_origin = [];1534 noneGroupLayers_origin = _getNoneGroupLayers( originWebWMSztreeLayer_, noneGroupLayers_origin );1535 /*1536 for(var i in noneGroupLayers_origin) {1537 var originLayer = noneGroupLayers_origin[i];1538 for(var j in loadData_) {1539 var loadLayer = loadData_[j];1540 if ( originLayer["LayerName"] === loadLayer["LayerName"] ) {1541 originLayer["checked"] = loadLayer["checked"];1542 }1543 }1544 }1545 */1546 var temp = [];1547 for(var i in loadData_) {1548 var loadLayer = loadData_[i];1549 for(var j in noneGroupLayers_origin) {1550 var originLayer = noneGroupLayers_origin[j];1551 if ( originLayer["LayerName"] === loadLayer["LayerName"] ) {1552 originLayer["checked"] = loadLayer["checked"];1553 temp.push( noneGroupLayers_origin.slice( j, j+1 )[0] );1554 noneGroupLayers_origin.splice( j, 1 );1555 }1556 }1557 }1558 1559 reLoadData = noneGroupLayers_origin.concat( temp );1560 1561 originWebWMSztreeLayer_["children"] = reLoadData;1562 1563 return originWebWMSztreeLayer_;1564 }1565 1566 };1567 var toc_WMTS = function() {1568 var _this = this;1569 var zTreeLayer;1570 var zTreeAttribute;1571 var olWMTSLayer;1572 1573 this.init = function(attribute_) {1574 /*1575 var options = {1576 OlMap : map,1577 TocDIV : 'TOC_1',1578 TocType : 'WMTS',1579 OriginCRS : 'EPSG:3857',1580 KEY : 'DT_ID_WMTS',1581 olWMTSLayer : wmtsLayer,1582 LayerName : '$STATIC',1583 LayerTitle : '$STATIC-Title',1584 MatrixSet :'',1585 isWebMap : false,1586 isLoadData : false,1587 LoadData : {1588 Checked : false,1589 Style : {1590 LineColor : '',1591 LineWidth : 101592 // To do - 스타일1593 }1594 },1595 CallBacks : {1596 test : function(data) {1597 console.log('CallBack : test');1598 console.log(data);1599 }1600 }1601 }1602 */1603 1604 1605 /*1606 * tocWMTS Init1607 */1608 _defaultInit( attribute_ );1609 _this.olWMTSLayer = attribute_["OlWMTSLayer"];1610 _this.zTreeAttribute = new zTreeAttribute_WMTS( this );1611 _this.zTreeLayer = OBJ_TOC_WMTS["createTOC_WMTS"]( attribute_, _this.zTreeAttribute["zTreeSetting_WMTS"] ); 1612 1613 _olWMTSLayerRefresh();1614 1615 console.log('### TOC Init ###');1616 console.log('TOC Type : ' + _tocType);1617 console.log('Projection : ' + _originCRS);1618 console.log('zTreeLayer : ' + _this.zTreeLayer);1619 };1620 1621 1622 this.layerSetVisible = function(e, treeId, treeNode) {1623 _this.olWMTSLayer.setVisible( !(_this.olWMTSLayer.getVisible()) );1624 }; 1625 1626 var _olWMTSLayerRefresh = function() {1627 _this.olWMTSLayer.setVisible( _this.getZtreeLayerWMTSchecked() );1628 };1629 1630 1631 this.getZtreeLayerWMTSchecked = function() {1632 var layer = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0]; 1633 return layer["checked"];1634 };1635 1636 };1637 1638 var zTreeAttribute_WMTS = function(toc_WMTS_) {1639 var zTreeSetting_WMTS = {1640 view : {1641 selectedMulti : false,1642 expandSpeed : 'fast',1643 addDiyDom : _addDIYDom_WMS1644 },1645 check : {1646 enable : true,1647 chkboxType : { "Y" : "", "N" : "" }1648 },1649 data : {1650 simpleData : {1651 enable : true1652 }1653 },1654 edit : {1655 enable : true,1656 showRemoveBtn : false,1657 showRenameBtn : false1658 },1659 callback : {1660 onCheck: toc_WMTS_.layerSetVisible1661 },1662 async : {1663 enable : true1664 }1665 };1666 1667 return {1668 zTreeSetting_WMTS : zTreeSetting_WMTS1669 }1670 };1671 var OBJ_TOC_WMTS = {1672 1673 createTOC_WMTS : function(attribute_, zTreeSetting_WMTS_) {1674 var wmtsZtreeLayer;1675 var originWMTSztreeLayer = this.getWMTSNodeTozTree( this.getWMTSLayerData( attribute_ ) );1676 1677 if ( attribute_["isWebMap"] ) {1678 wmtsZtreeLayer = originWMTSztreeLayer;1679 1680 if ( attribute_["isLoadData"] ) {1681 wmtsZtreeLayer = this.getLoadData( originWMTSztreeLayer, attribute_["LoadData"]["Layers"][0] );1682 }1683 1684 } else {1685 wmtsZtreeLayer = originWMTSztreeLayer;1686 }1687 1688 $.fn.zTree.init( $("#" + _tocDIV ), zTreeSetting_WMTS_, wmtsZtreeLayer );1689 1690 return wmtsZtreeLayer;1691 },1692 1693 getWMTSLayerData : function(attribute_) {1694 /*1695 var attribute = {1696 CRS : 'EPSG:3857',1697 KEY : 'DT_ID_1',1698 //BaseMapType : 'daum_normal',1699 LayerName : 'LV14_SCCO_EMD'1700 };1701 */1702 var wmtsLayerData = {1703 //CRS : attribute_["CRS"],1704 KEY : attribute_["KEY"],1705 LayerName : attribute_["LayerName"],1706 LayerTitle : attribute_["LayerTitle"],1707 MatrixSet : attribute_["MatrixSet"],1708 LegendURL : attribute_["LegendURL"]1709 };1710 return wmtsLayerData;1711 },1712 1713 getWMTSNodeTozTree : function(attribute_) {1714 1715 var layer = {1716 id : attribute_["LayerName"],1717 name : attribute_["LayerTitle"],1718 //title : null,1719 children : [],1720 open : true,1721 drop : false,1722 //inner : true,1723 checked : true,1724 LayerName : attribute_["LayerName"],1725 MatrixSet : attribute_["MatrixSet"],1726 isGroupLayer : false,1727 LegendURL : null,1728 Extent : null,1729 chkDisabled : false,1730 LegendURL : attribute_["LegendURL"]1731 };1732 return layer;1733 },1734 1735 1736 getLoadData : function(originWMTSztreeLayer_, loadData_) {1737 var loadztreeLayer;1738 1739 originWMTSztreeLayer_["checked"] = loadData_["checked"];1740 1741 loadztreeLayer = originWMTSztreeLayer_;1742 1743 return loadztreeLayer;1744 }1745 1746 };1747 var _getNoneGroupLayers = function(layers_, noneGroupLayers_) {1748 layers_ = [layers_];1749 for (var i in layers_) {1750 var layer = layers_[i];1751 if ( layer.isGroupLayer ) {1752 //if ( layer["children"].length > 0 ) {1753 var childs = layer["children"];1754 for (var j in childs) {1755 var child = childs[j];1756 arguments.callee( child, noneGroupLayers_ );1757 }1758 } else { 1759 noneGroupLayers_.push( layer );1760 }1761 }1762 return noneGroupLayers_;1763 };1764 var _clone = function(obj) {1765 if ( obj === null || typeof(obj) !== 'object' ) {1766 return obj;1767 }1768 var copy = obj.constructor();1769 for(var attr in obj) {1770 if ( obj.hasOwnProperty(attr) ) {1771 copy[attr] = _clone(obj[attr]);1772 }1773 }1774 return copy;1775 };1776 var destroy = function() {1777 1778 };1779 var getSaveOptions = function() {1780 var options = {1781 KEY : _KEY,1782 TocType : _tocType, 1783 //ViewExtent : _olMap.getView().calculateExtent( _olMap.getSize() )1784 };1785 1786 options["Layers"] = _getTocLayers( _tocType );1787 1788 1789 if ( _tocType === 'WFS' || _tocType === 'WebWFS') {1790 var tocLayer = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0];1791 1792 options["UseFeatureInfo"] = tocLayer.UseFeatureInfo1793 options["UserProperties"] = tocLayer.UserProperties;1794 1795 }1796 1797 return options;1798 };1799 1800 var _getTocLayers = function(tocType_) {1801 var tocLayers = $.fn.zTree.getZTreeObj( _tocDIV ).getNodes()[0];1802 1803 if ( tocType_ === 'WMS' ) {1804 tocLayers = _setSaveLayers_WMS( tocLayers );1805 } else if ( tocType_ === 'WebWMS' ) {1806 tocLayers = _setSaveLayers_WebWMS( tocLayers );1807 } else if ( tocType_ === 'WFS' ) {1808 tocLayers = _setSaveLayers_WFS( tocLayers );1809 } else if ( tocType_ === 'WCS' ) {1810 tocLayers = _setSaveLayers_WCS( tocLayers );1811 } else if ( tocType_ === 'WebWFS' ) {1812 tocLayers = _setSaveLayers_WFS( tocLayers );1813 } else if ( tocType_ === 'WMTS' ) {1814 tocLayers = _setSaveLayers_WMTS( tocLayers );1815 } else if ( tocType_ === 'WebWMTS' ) {1816 tocLayers = _setSaveLayers_WMTS( tocLayers );1817 }1818 return tocLayers;1819 };1820 var _setSaveLayers_WMS = function(tocLayers_) {1821 var saveLayers = [];1822 1823 var layers = _getNoneGroupLayers( tocLayers_, [] );1824 1825 for(var i in layers) {1826 var layerAttribute = {1827 LayerName : '',1828 checked : ''1829 };1830 layerAttribute["LayerName"] = layers[i]["LayerName"];1831 layerAttribute["checked"] = layers[i]["checked"];1832 saveLayers.push( layerAttribute );1833 }1834 1835 return saveLayers;1836 };1837 var _setSaveLayers_WebWMS = function(tocLayers_) {1838 var saveLayers = [];1839 1840 var layers = _getNoneGroupLayers( tocLayers_, [] );1841 1842 for(var i in layers) {1843 var layerAttribute = {1844 LayerName : '',1845 checked : ''1846 };1847 layerAttribute["LayerName"] = layers[i]["LayerName"];1848 layerAttribute["checked"] = layers[i]["checked"];1849 saveLayers.push( layerAttribute );1850 }1851 1852 return saveLayers;1853 };1854 var _setSaveLayers_WFS = function(tocLayers_) {1855 var saveLayers = [];1856 1857 var layerAttribute = {1858 LayerName : tocLayers_["LayerName"],1859 checked : tocLayers_["checked"]1860 };1861 1862 saveLayers.push( layerAttribute );1863 1864 return saveLayers;1865 };1866 var _setSaveLayers_WCS = function(tocLayers_) {1867 var saveLayers = [];1868 1869 var layerAttribute = {1870 Coverage : tocLayers_["Coverage"],1871 checked : tocLayers_["checked"]1872 };1873 1874 saveLayers.push( layerAttribute );1875 1876 return saveLayers;1877 };1878 var _setSaveLayers_WMTS = function(tocLayers_) {1879 var saveLayers = [];1880 1881 var layerAttribute = {1882 LayerName : tocLayers_["LayerName"],1883 MatrixSet : tocLayers_["MatrixSet"],1884 checked : tocLayers_["checked"]1885 };1886 1887 saveLayers.push( layerAttribute );1888 1889 return saveLayers;1890 };1891 var getShowLayerNames = function() {1892 var showLayerNames;1893 if ( _tocType === 'WMS' ) {1894 showLayerNames = _tocOBJ[_tocType].getShowLayerNames();1895 }1896 return showLayerNames;1897 };1898 1899 1900 return {1901 initTOC : initTOC,1902 getSaveOptions : function() { return getSaveOptions(); },1903 getShowLayerNames : function() { return getShowLayerNames(); }1904 }1905 ...

Full Screen

Full Screen

load_data.js

Source:load_data.js Github

copy

Full Screen

...26 style.appendChild(sandbox);27 style.appendChild(linkStyle);28 store.set('firstRun', false);29}30function loadData_() {31 const store = new Store({32 configName: 'user-preferences',33 defaults: {}34 });35 /////////// FIELDS IN MODAL ///////////36 const fields = store.get('fields');37 var fieldsMain = document.getElementById('field-form');38 while (fieldsMain.firstChild) {39 fieldsMain.removeChild(fieldsMain.firstChild);40 }41 var optionElt = document.createElement('option');42 optionElt.value = "unselected";43 optionElt.setAttribute('selected', '');44 optionElt.textContent = 'Field';45 fieldsMain.appendChild(optionElt);46 for (const field of fields) {47 optionElt = document.createElement('option');48 optionElt.value = String(field['name']);49 optionElt.style.fontSize = "small";50 optionElt.textContent = String(field['name']);51 fieldsMain.appendChild(optionElt);52 }53 /////////// MAIN ///////////54 const { courses } = store.get('data');55 var main = document.getElementById('main-page');56 while (main.firstChild) {57 main.removeChild(main.firstChild);58 }59 for (const course of courses) {60 var divCard = document.createElement("div");61 divCard.classList.add('card', 'mb-4');62 divCard.style.maxWidth = '18rem';63 var h6Title = document.createElement("h6");64 h6Title.classList.add('card-header', 'h7');65 h6Title.style.backgroundColor = (course["color"]);66 h6Title.textContent = course["name"];67 var inputZoomF = document.createElement("input");68 inputZoomF.type = "image";69 inputZoomF.src = "images/icons/50/plus.png";70 inputZoomF.classList.add('right', 'resize1');71 inputZoomF.setAttribute('data-toggle', 'modal');72 inputZoomF.setAttribute('data-target', '#zoomOnField');73 inputZoomF.onclick = () => {74 loadData_zoomField(course["name"]);75 };76 h6Title.appendChild(inputZoomF)77 divCard.appendChild(h6Title);78 var divCardBody = document.createElement("div");79 divCardBody.classList.add('card-body');80 for (const task of course["tasks"]) {81 var form = document.createElement("form");82 var divFormRow = document.createElement("div");83 var divLeft = document.createElement("div");84 var checkbox = document.createElement("input");85 var labelTask = document.createElement("label");86 var divDate = document.createElement("div");87 form.style.marginBottom = '0';88 divFormRow.classList.add('form-row', 'form-check');89 divLeft.classList.add('col-auto', 'left');90 const _id2 = String(task["content"]) + String(task["date"])91 checkbox.type = "checkbox";92 checkbox.classList.add('form-check-input', 'xx-small');93 checkbox.id = _id2;94 checkbox.onclick = () => {95 const { checker_ } = require('./writer.js');96 checker_();97 loadData_();98 };99 labelTask.classList.add('form-check-label', 'small');100 labelTask.setAttribute('for', 'exampleCheck1')101 if (task["done"]) {102 checkbox.setAttribute('checked', '');103 labelTask.style.textDecoration = 'line-through';104 }105 labelTask.textContent = String(task["content"]);106 divLeft.appendChild(checkbox);107 divLeft.appendChild(labelTask);108 divFormRow.appendChild(divLeft);109 divDate.classList.add('date', 'right');110 divDate.textContent = String(task["date"]);111 divFormRow.appendChild(divDate);112 form.appendChild(divFormRow);113 divCardBody.appendChild(form);114 }115 divCard.appendChild(divCardBody);116 main.appendChild(divCard);117 }118 if (store.get('firstRun')) {119 loadCSS();120 }121}122function loadData_zoomField(caller) {123 console.log("Caller : " + String(caller));124 const store = new Store({125 configName: 'user-preferences',126 defaults: {}127 });128 const { courses } = store.get('data');129 var main = document.getElementById('zoomModalContent');130 while (main.firstChild) {131 main.removeChild(main.firstChild);132 }133 for (const course of courses) {134 if (course["name"] != caller) {135 continue;136 }137 var h6Title = document.createElement("h6");138 h6Title.classList.add('card-header', 'h7');139 h6Title.style.backgroundColor = (course["color"]);140 h6Title.textContent = course["name"];141 var inputBack = document.createElement("input");142 inputBack.type = "image";143 inputBack.src = "images/icons/50/back.png";144 inputBack.classList.add('zoomFieldBack');145 inputBack.onclick = () => {146 loadData_();147 }148 inputBack.setAttribute('data-dismiss', 'modal');149 h6Title.appendChild(inputBack);150 var ulContainer = document.createElement("ul");151 ulContainer.classList.add('list-group');152 for (const task of course["tasks"]) {153 var item = document.createElement('li');154 item.classList.add('list-group-item');155 item.style.fontSize = 'small';156 item.style.padding = '2';157 var inputCorbeille = document.createElement("input");158 inputCorbeille.style.margin = '5';159 inputCorbeille.style.marginLeft = '10';160 inputCorbeille.type = 'image';161 inputCorbeille.src = "images/icons/50/corbeille.png";162 inputCorbeille.classList.add('zoomField');163 inputCorbeille.onclick = () => {164 const { del_ } = require('./writer.js');165 del_(task["content"], course["name"]);166 loadData_zoomField(course["name"]);167 }168 inputCorbeille.id = "modal-" + String(task["content"]) + String(task["date"]);169 var divRow = document.createElement('div');170 divRow.classList.add('form-row');171 divRow.appendChild(inputCorbeille);172 var p = document.createElement('div');173 p.textContent = task["content"];174 if (task["done"]) {175 p.style.textDecoration = "line-through";176 }177 p.style.marginTop = '5';178 p.style.marginLeft = '5';179 divRow.appendChild(p);180 item.appendChild(divRow);181 ulContainer.appendChild(item);182 }183 main.appendChild(h6Title);184 main.appendChild(ulContainer);185 }186}187loadData_()188//setInterval(loadData(), 1000)189//setInterval(function () { alert("Hello"); }, 3000);...

Full Screen

Full Screen

ImageEditorHistoryEntry.es.js

Source:ImageEditorHistoryEntry.es.js Github

copy

Full Screen

...13 constructor(image) {14 this.dataPromise_ = new CancellablePromise((resolve, reject) => {15 // Preemtively fetch the imageData when all we have is the image url16 if (image.url && !image.data) {17 this.loadData_(image.url)18 .then((imageData) => resolve(imageData));19 }20 else {21 resolve(image.data);22 }23 });24 }25 /**26 * Fetches an ImageData for a given image url27 *28 * @param {String} imageURL The image url to load29 * @protected30 */31 loadData_(imageURL) {32 return new CancellablePromise((resolve, reject) => {33 let bufferImage = new Image();34 bufferImage.onload = () => {35 let bufferCanvas = document.createElement('canvas');36 let bufferContext = bufferCanvas.getContext('2d');37 let height = bufferImage.height;38 let width = bufferImage.width;39 bufferCanvas.width = width;40 bufferCanvas.height = height;41 bufferContext.drawImage(bufferImage, 0, 0, width, height);42 resolve(bufferContext.getImageData(0, 0, width, height));43 };44 bufferImage.src = imageURL;45 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 console.log('Test ID: ' + data.data.testId);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9 if (err) return console.error(err);10 console.log('Test status: ' + data.statusText);11 console.log('Test ID: ' + data.data.testId);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15wpt.getLocations(function(err, data) {16 if (err) return console.error(err);17 console.log(data);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getTesters(function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27wpt.getTestResults('140823_0T_7a7f8a8b7e1e2a1b7d2b9c8a7a9a3a3', function(err, data) {28 if (err) return console.error(err);29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.getTestStatus('140823_0T_7a7f8a8b7e

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.error(err);6 console.log(data.data.median.firstView.SpeedIndex);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data.median.firstView.SpeedIndex);10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org');14var options = {15};16 if (err) return console.error(err);17 console.log(data.data.median.firstView.SpeedIndex);18 wpt.getTestResults(data.data.testId, function(err, data) {19 if (err) return console.error(err);20 console.log(data.data.median.firstView.SpeedIndex);21 });22});23var wpt = require('webpagetest');24var wpt = new WebPageTest('www.webpagetest.org');25var options = {26};27 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.loadData_(function(err, result){3 if(err){4 console.log(err);5 }else{6 console.log(result);7 }8});9exports.loadData_ = function(callback){10 callback(null, data);11};12var wpt = require('wpt');13wpt.loadData_(function(err, result){14 if(err){15 console.log(err);16 }else{17 console.log(result);18 }19});20exports.loadData_ = function(callback){21 callback(null, data);22};23var wpt = require('wpt');24wpt.loadData_(function(err, result){25 if(err){26 console.log(err);27 }else{28 console.log(result);29 }30});31exports.loadData_ = function(callback){32 callback(null, data);33};34var wpt = require('wpt');35wpt.loadData_(function(err, result){36 if(err){37 console.log(err);38 }else{39 console.log(result);40 }41});42exports.loadData_ = function(callback){43 callback(null, data);44};45var wpt = require('wpt');46wpt.loadData_(function(err, result){47 if(err){48 console.log(err);49 }else{50 console.log(result);51 }52});53exports.loadData_ = function(callback){54 callback(null, data);55};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt.loadData_(url);3var util = require('util');4var exec = require('child_process').exec;5var child;6 console.log('stdout: ' + stdout);7 console.log('stderr: ' + stderr);8 if (error !== null) {9 console.log('exec error: ' + error);10 }11});12exports.loadData_ = function(url){13 child;14};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2wpt.loadData_(url, function(data){3 console.log(data);4});5var Wpt = function(){6 this.loadData_ = function(url, callback){7 var request = require('request');8 var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.8f4c4c4c4c4c4c4c4c4c4c4c4c4c4c4c');3 console.log(data.data.testId);4 wpt.getTestResults(data.data.testId, function(err, data) {5 console.log(data);6 });7});8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org', 'A.8f4c4c4c4c4c4c4c4c4c4c4c4c4c4c');10 console.log(data);11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org', 'A.8f4c4c4c4c4c4c4c4c4c4c4c4c4c4c');14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org', 'A.8f4c4c4c4c4c4c4c4c4c4c4c4c4c4c');18 console.log(data);19});20var wpt = require('webpagetest');21var wpt = new WebPageTest('www.webpagetest.org', 'A.8f4c4c4c4c4c4c4c4c4c4c4c4

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = require('wpt');3 if (err) {4 return console.log('Error: ' + err);5 }6 console.log('data: ' + data);7});8 if (err) {9 return console.log('Error: ' + err);10 }11 console.log('data: ' + data);12});13var wpt = require('wpt');14 if (err) {15 return console.log('Error: ' + err);16 }17 console.log('data: ' + data);18});19var wpt = require('wpt');20 if (err) {21 return console.log('Error: ' + err);22 }23 console.log('data: ' + data);24});25var wpt = require('wpt');26 if (err) {27 return console.log('Error: ' + err);28 }29 console.log('data: ' + data);30});31var wpt = require('wpt');32 if (err) {33 return console.log('Error: ' + err);34 }35 console.log('data: ' + data);36});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful