/**** JQuery was removed from toolsCommon70. You should include one of the JQuery files under the "JQuery" folder ****/ if(!this.JSON){this.JSON={};} (function(){function f(n){return n<10?'0'+n:n;} if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+ f(this.getUTCMonth()+1)+'-'+ f(this.getUTCDate())+'T'+ f(this.getUTCHours())+':'+ f(this.getUTCMinutes())+':'+ f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};} var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);} if(typeof rep==='function'){value=rep.call(holder,key,value);} switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';} gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i will be used to determine the appropriate * dictionary. Dictionaries are stored in . * * Parameters: * key - {String} The key for an i18n string value in the dictionary. * context - {Object} Optional context to be used with * . * * Returns: * {String} A internationalized string. */ i18n: function(key, context) { var message = SGLang.lang[key]; if(!message) { // Message not found, fall back to message key message = key; } if(context) { message = SGLang.format(message, context); } return message; }, i18nFile: function(file) { var code = this.getCode(); if(code == "0" || code == "1033") return file; return code + "/" + file; }, format: function(template, context, args) { if(!context) { context = window; } // Example matching: // str = ${foo.bar} // match = foo.bar var replacer = function(str, match) { var replacement; // Loop through all subs. Example: ${a.b.c} // 0 -> replacement = context[a]; // 1 -> replacement = context[a][b]; // 2 -> replacement = context[a][b][c]; var subs = match.split(/\.+/); for (var i=0; i< subs.length; i++) { if (i == 0) { replacement = context; } replacement = replacement[subs[i]]; } if(typeof replacement == "function") { replacement = args ? replacement.apply(null, args) : replacement(); } // If replacement is undefined, return the string 'undefined'. // This is a workaround for a bugs in browsers not properly // dealing with non-participating groups in regular expressions: // http://blog.stevenlevithan.com/archives/npcg-javascript if (typeof replacement == 'undefined') { return 'undefined'; } else { return replacement; } }; return template.replace(SGLang.tokenRegEx, replacer); }, /** * Property: SGLang.tokenRegEx * Used to find tokens in a string. * Examples: ${a}, ${a.b.c}, ${a-b}, ${5} */ tokenRegEx: /\$\{([\w.]+?)\}/g }; //------------------- // load requested lang file (function() { // document.write(""); // var code = SGLang.getCode(); // document.write(""); var head = document.head || document.getElementsByTagName("head")[0]; // New way to support IE10 firstScript = head.getElementsByTagName("script")[0]; var script = document.createElement("script"); script.setAttribute("src", "Lang.js"); head.insertBefore(script, firstScript); var code = SGLang.getCode(); var script2 = document.createElement("script"); script2.setAttribute("src", code + "/Lang.js"); head.insertBefore(script2, firstScript); })(); // hide document body, so that TextXXX won't be visible until we replace them on document ready $(document.body).hide(); //------------------- $(document).ready(function () { $(document.body).hide(); var translateDocument = function() { document.title = SGLang.i18n(document.title); $(".i18n").each(function () { if (this.tagName == "INPUT") { this.value = SGLang.i18n(this.value); } else if (this.tagName == "IMG") { $(this).attr("src",SGLang.i18n($(this).attr("src"))); $(this).attr("alt", SGLang.i18n($(this).attr("alt"))); $(this).attr("title", SGLang.i18n($(this).attr("title"))); } else { $(this).attr("title", SGLang.i18n($(this).attr("title"))); $(this).attr("alt", SGLang.i18n($(this).attr("alt"))); // set element html only if it does not contain any other html elements. // otherwise it will erase them. if ($(this).children().length == 0) { $(this).html(SGLang.i18n($.trim($(this).text()))); } } }); $(".i18nFile").each(function () { if (this.tagName == "IMG") { $(this).attr("src",SGLang.i18nFile($(this).attr("src"))); } }); $(document.body).show(); } // make sure that hiding document body really worked. // I am not sure if IE will update the document view, until the function has finished executing. // so I am giving it here a few milliseconds of unused time. setTimeout(translateDocument,1); }); $(document).ready(function () { if (GetParamValue("inSG","") == "1") { document.getElementById("TopAreaTD").style.height = "57"; document.getElementById("TitleTD").align = "left"; document.getElementById("CloseHelpTd").style.display = "none"; } }); //------------------- // DisplayHelpPopup function DisplayHelpPopup(HTMLSrc, title) { if (title == null || title == "") title = "?"; var Cont = TE.interface("IContainer2"); Cont.HTMLPopup(1, 5, 5, 850, 500, title, abspath() + "/" + HTMLSrc, 10, -1); } //------------------- // DisplayMessagePopup function DisplayMessagePopup(title, header, icon,body, x, y, width, height, CloseButton) { var HTMLString = ""; HTMLString += ""; if (icon != "") HTMLString += ""; if (header != "") HTMLString += ""; HTMLString += ""; if (CloseButton) HTMLString += ""; HTMLString += ""; var popupMsg = SGWorld.Creator.CreatePopupMessage(title, "", x, y, width, height, -1); popupMsg.Flags = 2 + 32; popupMsg.InnerText = HTMLString; SGWorld.Window.ShowPopup(popupMsg); } //------------------- // DisplayHelpPopup6 function DisplayHelpPopup6(HTMLSrc, title) { if (title == null || title == "") title = "?"; var popup = SGWorld.Creator.CreatePopupMessage(title, abspath() + "/" + HTMLSrc, 5, 5, 850, 500); popup.AllowDrag = true; popup.AllowResize = true; SGWorld.Window.ShowPopup(popup); } //------------------- // CloseTool function CloseTool (ToolName) { var Cont = TE.interface("IContainer2"); Cont.RemoveURL (1,ToolName); } //------------------- // SGAPIDisplayHelpPopup function SGAPIDisplayHelpPopup(HTMLSrc,title) { //globe.teCore.IContainer.HTMLPopup (1, 5,5,500,500,"Help", SGAPI.toAbspath(HTMLSrc), 10, -1 ); if (title == null || title == "") title = "?"; var popup = new SGPopup(title, HTMLSrc,0,0,650,500); popup.align = "TopLeft"; globe.showPopup(popup); } //------------------- // SGAPICloseTool function SGAPICloseTool (ToolName) { globe.teCore.IContainer.RemoveURL (1,ToolName); } //-------------- // abspath function abspath() { var abspath = unescape(window.location.href); // Remove query String var index=abspath.indexOf("?"); if (index > 0) abspath = abspath.substr (0,index-1); index=abspath.lastIndexOf("/"); var index2 = abspath.lastIndexOf("\\"); index = (index > index2) ? index : index2; if (index <= 0) return abspath; abspath = abspath.substring(0,index); if(abspath.substring(0,1) == "/") abspath = abspath.slice(1); var re = /file:\/\/\//gi; if (abspath.match(re) != null) abspath = abspath.replace(re,""); // if this is indeed a local file, we strip the "file://" prefix from it. return(abspath); } // GetParamValue function GetParamValue(findParam, defaultValue) { var arr = document.location.href.split("?"); if (arr.length <= 1) return defaultValue; arr = arr[1].split("&"); for (var i = 0; i < arr.length; i++) { if (arr[i].indexOf(findParam) == 0 && arr[i].indexOf("=") == findParam.length) { arr = arr[i].split("="); return arr[1]; } } return defaultValue; } //----------------- // validateNumber function validateNumber(strNum) { strNum = strNum.replace(/,/, "."); return parseFloat (strNum); } //-------------- // validateNumberEx function validateNumberEx(field, defVal, MinNum, MaxNum) { try { field.val (validateNumber(field.val())); if (field.val() < MinNum) field.val(MinNum); if (field.val() > MaxNum) field.val( MaxNum); } catch (e) {field.val(defVal); } } //******************************************** var gDrawPolyAltitudeType = 2; //---------- // DrawPolyLButtonDown //---------- function DrawPolyLButtonDown(Flags, X, Y) { DrawPolyLButtonClicked(Flags, X, Y); } //---------- // DrawPolyLButtonClicked //---------- function DrawPolyLButtonClicked(Flags, X, Y) { var CursorCoord = SGWorld.Window.pixelToWorld(X, Y, -1 & ~(128 | 1024)); if (gPolyObj == null) { // We always start with a polyline and change it to Polygon (for area) after the second click) var myGeometry = SGWorld.Creator.GeometryCreator.CreateLineStringGeometry([CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude, CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude]) gPolyObj = SGWorld.Creator.createPolyline(myGeometry, SGWorld.Creator.CreateColor(0, 255, 0, 1), gDrawPolyAltitudeType, -1, gPolylineText); gPolyObj.LineStyle.Width = -2; gPolyObj.Geometry.StartEdit(); } else { if (gPolyMethod == 2) // Polygon { if (gPolyObj.ObjectType == 1) { // Deleting the temporary line var x = gPolyObj.Geometry.Points.Item(0).X; var y = gPolyObj.Geometry.Points.Item(0).Y; var z = gPolyObj.Geometry.Points.Item(0).Z; SGWorld.Creator.DeleteObject(gPolyObj.ID); if (typeof gPolyHorizontal !== "undefined" && gPolyHorizontal==true) CursorCoord.Position.Altitude = z; // Creating the polygon var myGeometry = SGWorld.Creator.GeometryCreator.CreateLinearRingGeometry([x, y, z, CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude, CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude]) gPolyObj = SGWorld.Creator.createPolygon(myGeometry, SGWorld.Creator.CreateColor(0, 255, 0, 1), SGWorld.Creator.CreateColor(0, 255, 0, 0.5), gDrawPolyAltitudeType, -1, gPolygonText); gPolyObj.LineStyle.Width = -2; // gPolyObj.Terrain.GroundObject = true; // Arik removed it. Caused a bug in Viewshed query (got wrong GetGroundHeight values because of the polygon) gPolyObj.Geometry.StartEdit(); } else { gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).X = CursorCoord.Position.x; gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Y = CursorCoord.Position.y; gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Z = CursorCoord.Position.Altitude; if (typeof gPolyHorizontal !== "undefined" && gPolyHorizontal==true) gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Z = gPolyObj.Geometry.Rings(0).Points.Item(0).Z; gPolyObj.Geometry.Rings(0).Points.AddPoint(CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude); } } else { gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).X = CursorCoord.Position.x; gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Y = CursorCoord.Position.y; gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Z = CursorCoord.Position.Altitude; if (typeof gPolyHorizontal !== "undefined" && gPolyHorizontal==true) gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Z = gPolyObj.Geometry.Points.Item(0).Z; gPolyObj.Geometry.Points.AddPoint(CursorCoord.Position.x, CursorCoord.Position.y, CursorCoord.Position.Altitude); } } if (gDrawPolyClick != null) gDrawPolyClick(gPolyObj.Geometry, gPolyObj.ObjectType); gPolyObj.SetParam(5440, 1); return false; } //----------- // onFrame //----------- function DrawPolyOnFrame() { if (gPolyObj != null) { try { var mouseInfo = SGWorld.Window.GetMouseInfo() var CursorCoord = SGWorld.Window.pixelToWorld(mouseInfo.X, mouseInfo.Y, -1 & ~(128|1024)); if (CursorCoord == null) return false; if (gPolyObj.ObjectType == 2) { gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).X = CursorCoord.Position.x; gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Y = CursorCoord.Position.y; gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Z = CursorCoord.Position.Altitude; if (typeof gPolyHorizontal !== "undefined" && gPolyHorizontal==true) gPolyObj.Geometry.Rings(0).Points.Item(gPolyObj.Geometry.Rings(0).Points.count - 1).Z = gPolyObj.Geometry.Rings(0).Points.Item(0).Z; } else { gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).X = CursorCoord.Position.x; gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Y = CursorCoord.Position.y; gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Z = CursorCoord.Position.Altitude; if (typeof gPolyHorizontal !== "undefined" && gPolyHorizontal==true) gPolyObj.Geometry.Points.Item(gPolyObj.Geometry.Points.count - 1).Z = gPolyObj.Geometry.Points.Item(0).Z; } gPolyObj.SetParam(5440, 1); } catch (e) { } } } //------------- //DrawPolyInputModeChanged function DrawPolyInputModeChanged(NewMode) { if (NewMode != 1) if (gPolyObj != null) Reset(0, 1); } //------------- // DrawPolyRButtonUp function DrawPolyRButtonUp(Flags, X, Y) { if (gPolyObj == null || ((gPolyObj.ObjectType == 1 && gPolyObj.Geometry.Points.count <= 2) || (gPolyObj.ObjectType == 2 && gPolyObj.Geometry.Rings(0).Points.count <= 3))) { Reset(0, 0); return false; } if (gPolyObj.ObjectType == 1) gPolyObj.Geometry.Points.DeletePoint(gPolyObj.Geometry.Points.count - 1); else gPolyObj.Geometry.Rings(0).Points.DeletePoint(gPolyObj.Geometry.Rings(0).Points.count - 1); gPolyObj.Geometry.EndEdit(); gEndDrawPoly(gPolyObj.Geometry, gPolyObj.ObjectType, gPolyObj.Position.AltitudeType); Reset(0, 0); return true; } //------------------- //searchGeometries function searchGeometries2(parentNode, callbackFunc) { SGWorld.ProjectTree.EnableRedraw(0); searchGeometriesLeaf2(parentNode, callbackFunc); SGWorld.ProjectTree.EnableRedraw(1); } //------------------- // searchGeometries function searchGeometriesLeaf2(parentNode, callbackFunc) { if (SGWorld.ProjectTree.IsLayer(parentNode)) // Layer { var layer = SGWorld.ProjectTree.GetLayer(parentNode); var featureGroups = layer.FeatureGroups; for (var i = 0; i < featureGroups.Count; i++) // Traverse all sub-layers { var featureGroup = featureGroups.Item(i); var altitudeType = AltitudeMethodToAltitudeType(featureGroup.GetProperty("Altitude Method")); var features = featureGroup.Features; for (var j = 0; j < features.Count; j++) { var ret; if (featureGroup.GeometryType != 0) ret = callbackFunc(features.Item(j).Geometry, featureGroup.GeometryType, altitudeType); else { if (features.Item(j).Geometry.GeometryType == 0) // Point { var position = SGWorld.Creator.CreatePosition(features.Item(j).Geometry.X, features.Item(j).Geometry.Y, features.Item(j).Geometry.Z); ret = callbackFunc(position, featureGroup.GeometryType, altitudeType); } } if (!ret) return; } } } else { var node = SGWorld.ProjectTree.GetNextItem(parentNode, 11); while (node != "") { if (SGWorld.ProjectTree.IsGroup(node) || SGWorld.ProjectTree.IsLayer(node)) searchGeometriesLeaf2(node, callbackFunc); else { var Object = SGWorld.Creator.GetObject(node); if (Object != null) { var altitudeType = Object.Position.AltitudeType; var ret; if (Object.ObjectType == 1 || Object.ObjectType == 2) ret = callbackFunc(Object.Geometry, Object.ObjectType, altitudeType, Object.Position); else ret = callbackFunc(Object.Position, Object.ObjectType, altitudeType, Object.Position); if (!ret) return; } } node = SGWorld.ProjectTree.GetNextItem(node, 13); } } } function AltitudeMethodToAltitudeType(altitudeMethod) { switch(altitudeMethod) { case 10: return AltitudeTypeCode.ATC_TERRAIN_RELATIVE; case 11: return AltitudeTypeCode.ATC_TERRAIN_ABSOLUTE; case 12: return AltitudeTypeCode.ATC_ON_TERRAIN; case 13: return AltitudeTypeCode.ATC_PIVOT_RELATIVE; } } //------------------- //searchGeometriesClipbaord function searchGeometriesClipboard(callbackFunc) { SGWorld.ProjectTree.EnableRedraw(0); var Object; for (var i = 0; i < SGWorld.Application.Clipboard.Count; i++) { try { Object = SGWorld.Application.Clipboard.Item(i); var altitudeType = Object.Position.AltitudeType; var ret; if (Object.ObjectType == 1 || Object.ObjectType == 2) ret = callbackFunc(Object.Geometry, Object.ObjectType, altitudeType, Object.Position); else ret = callbackFunc(Object.Position, Object.ObjectType, altitudeType, Object.Position); if (!ret) { SGWorld.ProjectTree.EnableRedraw(1); return; } } catch (e) { } } SGWorld.ProjectTree.EnableRedraw(1); }
" + header + "
" + body + "