📄 svg_interactive_map.cpp
字号:
"//see http://www.mathe-online.at/mathint/vect2/i.html#Winkel\n"
"function angleBetwTwoLines(a1,a2,b1,b2) {\n"
" angle = Math.acos((a1 * b1 + a2 * b2) / (Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2)) * Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2))));\n"
" return(angle);\n"
"}\n"
"\n"
"//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is new vector c2 returned as array\n"
"//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n"
"//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n"
"function calcBisectorVector(a1,a2,b1,b2) {\n"
" betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n"
" betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n"
" c = new Array();\n"
" c[0] = a1 / betraga + b1 / betragb;\n"
" c[1] = a2 / betraga + b2 / betragb;\n"
" return(c);\n"
"}\n"
"\n"
"//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is angle in radian\n"
"//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n"
"//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n"
"function calcBisectorAngle(a1,a2,b1,b2) {\n"
" betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n"
" betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n"
" c1 = a1 / betraga + b1 / betragb;\n"
" c2 = a2 / betraga + b2 / betragb;\n"
" angle = toPolarDir(c1,c2);\n"
" return(angle);\n"
"}\n"
"\n"
"function intersect2lines(line1x1,line1y1,line1x2,line1y2,line2x1,line2y1,line2x2,line2y2) {\n"
" //formula see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/\n"
" var result = new Array();\n"
" var denominator = (line2y2 - line2y1)*(line1x2 - line1x1) - (line2x2 - line2x1)*(line1y2 - line1y1);\n"
" if (denominator == 0) {\n"
" alert(\"lines are parallel\"));\n"
" }\n"
" else {\n"
" ua = ((line2x2 - line2x1)*(line1y1 - line2y1) - (line2y2 - line2y1)*(line1x1 - line2x1)) / denominator;\n"
" ub = ((line1x2 - line1x1)*(line1y1 - line2y1) - (line1y2 - line1y1)*(line1x1 - line2x1)) / denominator;\n"
" }\n"
" result[\"x\"] = line1x1 + ua * (line1x2 - line1x1);\n"
" result[\"y\"] = line1y1 + ua * (line1y2 - line1y1);\n"
" return(result);\n"
"}\n"
"\n"
"/* ----------------------- helper function to sort arrays ---------------- */\n"
"/* ----------------------------------------------------------------------- */\n"
"//my own sort function, uses only first part of string (population value)\n"
"function mySort(a,b) {\n"
" var myResulta = a.split(\"+\"));\n"
" var myResultb = b.split(\"+\"));\n"
" if (parseFloat(myResulta[0]) < parseFloat(myResultb[0])) {\n"
" return 1;\n"
" }\n"
" else {\n"
" return -1;\n"
" }\n"
"}\n"
"\n"
"/* ----------------------- helper function format number strings -------------- */\n"
"/* ---------------------------------------------------------------------------- */\n"
"//formatting number strings\n"
"//this function add's \"'\" to a number every third digit\n"
"function formatNumberString(myString) {\n"
" //check if of type string, if number, convert it to string\n"
" if (typeof(myString) == \"number\")) {\n"
" myTempString = myString.toString();\n"
" }\n"
" else {\n"
" myTempString = myString;\n"
" }\n"
" var myNewString=\"\");\n"
" //if it contains a comma, it will be split\n"
" var splitResults = myTempString.split(\".\"));\n"
" var myCounter= splitResults[0].length;\n"
" if (myCounter > 3) {\n"
" while(myCounter > 0) {\n"
" if (myCounter > 3) {\n"
" myNewString = \"),\" + splitResults[0].substr(myCounter - 3,3) + myNewString;\n"
" }\n"
" else {\n"
" myNewString = splitResults[0].substr(0,myCounter) + myNewString;\n"
" }\n"
" myCounter -= 3;\n"
" }\n"
" }\n"
" else {\n"
" myNewString = splitResults[0];\n"
" }\n"
" //concatenate if it contains a comma\n"
" if (splitResults[1]) {\n"
" myNewString = myNewString + \".\" + splitResults[1];\n"
" }\n"
" return myNewString;\n"
"}\n"
"\n"
"//function for status Bar\n"
"function statusChange(statusText) {\n"
" document.getElementById(\"statusText\")).firstChild.nodeValue = \"Statusbar: \" + statusText;\n"
"}\n"
"\n"
"//scale an object\n"
"function scaleObject(evt,factor) {\n"
"//reference to the currently selected object\n"
" var element = evt.currentTarget;\n"
" var myX = element.getAttributeNS(null,\"x\"));\n"
" var myY = element.getAttributeNS(null,\"y\"));\n"
" var newtransform = \"scale(\" + factor + \")) translate(\" + (myX * 1 / factor - myX) + \" \" + (myY * 1 / factor - myY) +\"))\");\n"
" element.setAttributeNS(null,'transform', newtransform);\n"
"}\n"
"\n"
"//this code is copied from Kevin Lindsey\n"
"//http://www.kevlindev.com/tutorials/basics/transformations/toUserSpace/index.htm\n"
"function getTransformToRootElement(node) {\n"
" try {\n"
" //this part is for fully conformant players\n"
" var CTM = node.getTransformToElement(document.documentElement);\n"
" }\n"
" catch (ex) {\n"
" //this part is for ASV3 or other non-conformant players\n"
" // Initialize our CTM the node's Current Transformation Matrix\n"
" var CTM = node.getCTM();\n"
" // Work our way through the ancestor nodes stopping at the SVG Document\n"
" while ( ( node = node.parentNode ) != document ) {\n"
" // Multiply the new CTM to the one with what we have accumulated so far\n"
" CTM = node.getCTM().multiply(CTM);\n"
" }\n"
" }\n"
" return CTM;\n"
"}\n"
"\n"
"//calculate HSV 2 RGB: HSV (h 0 to 360, sat and val are between 0 and 1), RGB between 0 and 255\n"
"function hsv2rgb(hue,sat,val) {\n"
" //alert(\"Hue:\"+hue);\n"
" var rgbArr = new Array();\n"
" if ( sat == 0) {\n"
" rgbArr[\"red\"] = Math.round(val * 255);\n"
" rgbArr[\"green\"] = Math.round(val * 255);\n"
" rgbArr[\"blue\"] = Math.round(val * 255);\n"
" }\n"
" else {\n"
" var h = hue / 60;\n"
" var i = Math.floor(h);\n"
" var f = h - i;\n"
" if (i % 2 == 0) {\n"
" f = 1 - f;\n"
" }\n"
" var m = val * (1 - sat); \n"
" var n = val * (1 - sat * f);\n"
" switch(i) {\n"
" case 0:\n"
" rgbArr[\"red\"] = val;\n"
" rgbArr[\"green\"] = n;\n"
" rgbArr[\"blue\"] = m;\n"
" break;\n"
" case 1:\n"
" rgbArr[\"red\"] = n;\n"
" rgbArr[\"green\"] = val;\n"
" rgbArr[\"blue\"] = m;\n"
" break;\n"
" case 2:\n"
" rgbArr[\"red\"] = m;\n"
" rgbArr[\"green\"] = val;\n"
" rgbArr[\"blue\"] = n;\n"
" break;\n"
" case 3:\n"
" rgbArr[\"red\"] = m;\n"
" rgbArr[\"green\"] = n;\n"
" rgbArr[\"blue\"] = val;\n"
" break;\n"
" case 4:\n"
" rgbArr[\"red\"] = n;\n"
" rgbArr[\"green\"] = m;\n"
" rgbArr[\"blue\"] = val;\n"
" break;\n"
" case 5:\n"
" rgbArr[\"red\"] = val;\n"
" rgbArr[\"green\"] = m;\n"
" rgbArr[\"blue\"] = n;\n"
" break;\n"
" case 6:\n"
" rgbArr[\"red\"] = val;\n"
" rgbArr[\"green\"] = n;\n"
" rgbArr[\"blue\"] = m;\n"
" break;\n"
" }\n"
" rgbArr[\"red\"] = Math.round(rgbArr[\"red\"] * 255);\n"
" rgbArr[\"green\"] = Math.round(rgbArr[\"green\"] * 255);\n"
" rgbArr[\"blue\"] = Math.round(rgbArr[\"blue\"] * 255);\n"
" }\n"
" return rgbArr;\n"
"}\n"
"\n"
"//calculate rgb to hsv values\n"
"function rgb2hsv (red,green,blue) {\n"
" //input between 0 and 255 --> normalize to 0 to 1\n"
" //result = \n"
" var hsvArr = new Array();\n"
" red = red / 255;\n"
" green = green / 255;\n"
" blue = blue / 255;\n"
" myMax = Math.max(red, Math.max(green,blue));\n"
" myMin = Math.min(red, Math.min(green,blue));\n"
" v = myMax;\n"
" if (myMax > 0) {\n"
" s = (myMax - myMin) / myMax;\n"
" }\n"
" else {\n"
" s = 0;\n"
" }\n"
" if (s > 0) {\n"
" myDiff = myMax - myMin;\n"
" rc = (myMax - red) / myDiff;\n"
" gc = (myMax - green) / myDiff;\n"
" bc = (myMax - blue) / myDiff;\n"
" if (red == myMax) {\n"
" h = (bc - gc) / 6;\n"
" }\n"
" if (green == myMax) {\n"
" h = (2 + rc - bc) / 6;\n"
" }\n"
" if (blue == myMax) {\n"
" h = (4 + gc - rc) / 6;\n"
" }\n"
" }\n"
" else {\n"
" h = 0;\n"
" }\n"
" if (h < 0) {\n"
" h += 1;\n"
" }\n"
" hsvArr[\"hue\"] = Math.round(h * 360);\n"
" hsvArr[\"sat\"] = s;\n"
" hsvArr[\"val\"] = v;\n"
" return hsvArr;\n"
"}\n"
"\n"
"//populate an array that can be addressed by both a key or an index nr\n"
"function assArrayPopulate(arrayKeys,arrayValues) {\n"
" var returnArray = new Array();\n"
" if (arrayKeys.length != arrayValues.length) {\n"
" alert(\"error: arrays do not have same length!\"));\n"
" }\n"
" else {\n"
" for (i=0;i<arrayKeys.length;i++) {\n"
" returnArray[arrayKeys[i]] = arrayValues[i];\n"
" }\n"
" }\n"
" return returnArray;\n"
"}\n"
"\n"
"//replace special (non-ASCII) characters with their charCode\n"
"function replaceSpecialChars(myString) {\n"
" for (i=161;i<256;i++) {\n"
" re = new RegExp(\"&#\"+i+\");\"),\"g\"));\n"
" myString = myString.replace(re,String.fromCharCode(i));\n"
" }\n"
" return myString;\n"
"}\n"
"\n"
"/* ----------------------- getXMLData object ----------------------------- */\n"
"/* ----------------------------------------------------------------------- */\n"
"//this object allows to make network requests using getURL or XMLHttpRequest\n"
"//you may specify a url and a callBackFunction\n"
"//the callBackFunction receives a XML node representing the rootElement of the fragment received\n"
"function getXMLData(url,callBackFunction) {\n"
" this.url = url;\n"
" this.callBackFunction = callBackFunction;\n"
" this.xmlRequest = null;\n"
"} \n"
"\n"
"getXMLData.prototype.getData = function() {\n"
" //call getURL() if available\n"
" if (window.getURL) {\n"
" getURL(this.url,this);\n"
" }\n"
" //or call XMLHttpRequest() if available\n"
" else if (window.XMLHttpRequest) {\n"
" this.xmlRequest = new XMLHttpRequest();\n"
" this.xmlRequest.overrideMimeType(\"text/xml\"));\n"
" this.xmlRequest.open(\"GET\"),this.url,true);\n"
" this.xmlRequest.onreadystatechange = this;\n"
" this.xmlRequest.send(null);\n"
" }\n"
" //write an error message if neither method is available\n"
" else {\n"
" alert(\"your browser/svg viewer neither supports window.getURL nor window.XMLHttpRequest!\"));\n"
" } \n"
"}\n"
"\n"
"//this is the callback method for the getURL function\n"
"getXMLData.prototype.operationComplete = function(data) {\n"
" //check if data has a success property\n"
" if (data.success) {\n"
" //parse content of the XML format to the variable \"node\"\n"
" var node = parseXML(data.content,document);\n"
" this.callBackFunction(node.firstChild);\n"
" }\n"
" else {\n"
" alert(\"something went wrong with dynamic loading of geometry!\"));\n"
" }\n"
"}\n"
"\n"
"//this method receives data from XMLHttpRequest\n"
"getXMLData.prototype.handleEvent = function() {\n"
" if (this.xmlRequest.readyState == 4) {\n"
" this.callBackFunction(this.xmlRequest.responseXML.documentElement);\n"
" } \n"
"}\n"
"\n"
));
}
//---------------------------------------------------------
const wxChar * CSVG_Interactive_Map::_Get_Code_Buttons(void)
{
return( SG_STR_MBTOSG(
"function button(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n"
" if (arguments.length > 0) {\n"
" this.init(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -