mqcommon.js
Summary
No overview generated for 'mqcommon.js'
function MQBrowser(){
this.name = null;
this.version = null;
this.os = null;
this.appname = null;
this.appVersion = null;
this.vMajor = null;
this.isNS = null;
this.isNS4 = null;
this.isNS6 = null;
this.isIE = null;
this.isIE4 = null;
this.isIE5 = null;
this.isDOM = null;
this.isSafari = null;
this.platform = null;
}
function mqGetBrowserInfo()
{
var browser = new MQBrowser();
browser.name = browser.version = browser.os = "unknown";
var userAgent = window.navigator.userAgent.toLowerCase();
var appname = window.navigator.appName;
var appVersion = window.navigator.appVersion;
var browserListArray = new Array("firefox", "msie", "netscape", "opera", "safari");
var osListArray = new Array("linux", "mac", "windows", "x11");
var browserListlength = browserListArray.length;
var strPosition = "";
for(var i = 0, n = browserListlength; i < n; i++)
{
strPosition = userAgent.indexOf(browserListArray[i]) + 1;
if(strPosition > 0)
{
browser.name = browserListArray[i];
var versionPosition = strPosition + browser.name.length;
var incr = ((browser.name == "safari") || (userAgent.charAt(versionPosition + 4) > 0 && userAgent.charAt(versionPosition + 4) < 9)) ? 5 : 3;
browser.version = userAgent.substring(versionPosition, versionPosition + incr);
}
}
var osListArrayLength = osListArray.length;
for(var j = 0, m = osListArrayLength; j < m; j++)
{
strPosition = userAgent.indexOf(osListArray[j]) + 1;
if(strPosition > 0)
{
browser.os = osListArray[j];
}
}
if (appname == "Netscape")
browser.appname = "ns";
else if (appname == "Microsoft Internet Explorer")
browser.appname = "ie";
browser.appVersion = appVersion;
browser.vMajor = parseInt(browser.appVersion);
browser.isNS = (browser.appname =="ns" && browser.vMajor >= 4);
browser.isNS4 = (browser.appname =="ns" && browser.vMajor == 4);
browser.isNS6 = (browser.appname =="ns" && browser.vMajor == 5);
browser.isIE = (browser.appname =="ie" && browser.vMajor >= 4);
browser.isIE4 = (browser.appVersion.indexOf ('MSIE 4') >0);
browser.isIE5 = (browser.appVersion.indexOf ('MSIE 5') >0);
browser.isDOM = (document.createElement
&& document.appendChild
&& document.getElementsByTagName) ? true : false;
browser.isSafari = (browser.name == "safari");
if (userAgent.indexOf ("win") > - 1)
browser.platform = "win";
else if (userAgent.indexOf("mac") > -1)
browser.platform = "mac";
else
browser.platform="other";
return browser;
}
var mqBrowserInfo = mqGetBrowserInfo();
function MQObject(){
var m_xmlDoc = null;
this.getM_XmlDoc = function() {
return m_xmlDoc;
};
this.setM_XmlDoc = function(xmlDoc) {
m_xmlDoc = xmlDoc;
};
var m_xpath = null;
this.getM_Xpath = function() {
return m_xpath;
};
this.setM_Xpath = function(xpath) {
m_xpath = xpath;
};
}
MQObject.prototype.getClassName = function(){
return "MQObject";
};
MQObject.prototype.getObjectVersion = function(){
return 0;
};
MQObject.prototype.setProperty = function (strPropName, strPropValue) {
var strXPathExpression;
if (strPropName!==null) strXPathExpression= "/" + this.getM_Xpath() + "/" + strPropName;
else strXPathExpression= "/" + this.getM_Xpath();
var ndNewProp = mqSetNodeText(this.getM_XmlDoc(),strXPathExpression,strPropValue);
if ( ndNewProp === null) {
var ndNewPropParent = this.getM_XmlDoc().createElement(strPropName);
var ndRoot = this.getM_XmlDoc().documentElement.appendChild(ndNewPropParent);
ndNewProp = mqSetNodeText(this.getM_XmlDoc(),strXPathExpression,strPropValue);
}
return ndNewProp;
};
MQObject.prototype.getProperty = function (strPropName) {
var strXPathExpression;
if (strPropName!==null) strXPathExpression= "/" + this.getM_Xpath() + "/" + strPropName;
else strXPathExpression= "/" + this.getM_Xpath();
return mqGetXPathNodeText(this.getM_XmlDoc(),strXPathExpression);
};
MQObject.prototype.copy = function () {
var cp = new this.constructor;
cp.loadXml(this.saveXml());
return cp;
};
MQObject.prototype.internalCopy = function (obj) {
var strXml = "<" + obj.getM_Xpath();
if(this.getObjectVersion() > 0){
strXml = strXml + " Version=\"" + this.getObjectVersion() + "\"";
}
strXml = strXml + ">";
var root = this.getM_XmlDoc().documentElement;
var nodes = root.childNodes;
var maxCount = nodes.length;
for (var count=0;count<maxCount;count++){
strXml = strXml + mqXmlToStr(nodes[count]);
}
strXml = strXml + "</" + obj.getM_Xpath() + ">";
var cp = new this.constructor;
cp.loadXml(strXml);
return cp;
};
MQPoint.prototype = new MQObject();
MQPoint.prototype.constructor = MQPoint;
function MQPoint(param1, param2) {
MQObject.call(this);
this.x = 0;
this.y = 0;
this.setM_Xpath("Point");
if (arguments.length == 1){
this.setM_Xpath(param1);
}
else if (arguments.length == 2){
this.x = parseInt(param1);
this.y = parseInt(param2);
if (isNaN(this.x) || isNaN(this.y))
throw new Error("MQPoint constructor called with invalid parameter");
}
else if (arguments.length > 2){
throw new Error("MQPoint constructor called with "
+ arguments.length
+ " arguments, but it expects 0, 1, or 2 arguments");
}
}
MQPoint.prototype.getClassName = function(){
return "MQPoint";
};
MQPoint.prototype.getObjectVersion = function(){
return 0;
};
MQPoint.prototype.loadXml = function (strXml) {
if("undefined" !== typeof(mqutils)){
this.setM_XmlDoc(mqCreateXMLDoc(strXml));
this.x = this.getProperty("X");
this.y = this.getProperty("Y");
}
};
MQPoint.prototype.saveXml = function () {
return "<" + this.getM_Xpath() + "><X>" + this.x + "</X><Y>" + this.y + "</Y></" + this.getM_Xpath() + ">";
};
MQPoint.prototype.setX = function(x){
this.x = parseInt(x);
if (isNaN(this.x))
throw new Error("MQPoint.setX called with invalid parameter");
};
MQPoint.prototype.getX = function(){
return this.x;
};
MQPoint.prototype.setY = function(y){
this.y = parseInt(y);
if (isNaN(this.y))
throw new Error("MQPoint.setY called with invalid parameter");
};
MQPoint.prototype.getY = function(){
return this.y;
};
MQPoint.prototype.setXY = function(x, y){
this.x = parseInt(x);
this.y = parseInt(y);
if (isNaN(this.x) || isNaN(this.y))
throw new Error("MQPoint.setXY called with invalid parameter");
};
MQPoint.prototype.valid = function(){
if("undefined" !== typeof(mqutils)){
return ( Math.abs(this.x != MQCONSTANT.MQPOINT_INVALID) &&
Math.abs(this.y != MQCONSTANT.MQPOINT_INVALID));
}
return false;
};
MQPoint.prototype.equals = function(pt){
if (pt){
return (this.x === pt.x && this.y === pt.y);
}
return false;
};
MQPoint.prototype.toString = function() {
return this.x + "," + this.y;
};
MQLatLng.prototype = new MQObject();
MQLatLng.prototype.constructor = MQLatLng;
function MQLatLng (param1, param2) {
MQObject.call(this);
this.lat = 0.0;
this.lng = 0.0;
this.setM_Xpath("LatLng");
if (arguments.length == 1){
this.setM_Xpath(param1);
}
else if (arguments.length == 2){
this.lat = parseFloat(param1);
this.lng = parseFloat(param2);
if (isNaN(this.lat) || isNaN(this.lng))
throw new Error("MQLatLng constructor called with invalid parameter");
}
else if (arguments.length > 2){
throw new Error("MQLatLng constructor called with "
+ arguments.length
+ " arguments, but it expects 0, 1, or 2 arguments.");
}
}
MQLatLng.prototype.getClassName = function(){
return "MQLatLng";
};
MQLatLng.prototype.getObjectVersion = function(){
return 0;
};
MQLatLng.prototype.loadXml = function (strXml) {
if("undefined" !== typeof(mqutils)){
this.setM_XmlDoc(mqCreateXMLDoc(strXml));
this.lat = this.getProperty("Lat");
this.lng = this.getProperty("Lng");
}
};
MQLatLng.prototype.saveXml = function () {
return "<" + this.getM_Xpath() + "><Lat>" + this.lat + "</Lat><Lng>" + this.lng + "</Lng></" + this.getM_Xpath() + ">";
};
MQLatLng.prototype.setLatitude = function(fLatitude){
this.lat = parseFloat(fLatitude);
if (isNaN(this.lat))
throw new Error("MQLatLng.setLatitude called with invalid parameter");
};
MQLatLng.prototype.getLatitude = function(){
return this.lat;
};
MQLatLng.prototype.setLongitude = function(fLongitude){
this.lng = parseFloat(fLongitude);
if (isNaN(this.lng))
throw new Error("MQLatLng.setLongitude called with invalid parameter");
};
MQLatLng.prototype.getLongitude = function(){
return this.lng;
};
MQLatLng.prototype.setLatLng = function(fLatitude, fLongitude){
this.lat = parseFloat(fLatitude);
this.lng = parseFloat(fLongitude);
if (isNaN(this.lat) || isNaN(this.lng))
throw new Error("MQLatLng.setLatLng called with invalid parameter");
};
MQLatLng.prototype.arcDistance = function( ll2, lUnits){
if("undefined" !== typeof(mqutils)){
if (ll2){
if(ll2.getClassName()!=="MQLatLng"){
alert("failure in arcDistance");
throw "failure in arcDistance";
}
} else {
alert("failure in arcDistance");
throw "failure in arcDistance";
}
if(lUnits){
mqIsClass("MQDistanceUnits", lUnits, false);
} else {
lUnits = new MQDistanceUnits(MQCONSTANT.MQDISTANCEUNITS_MILES);
}
if (this.getLatitude() == ll2.getLatitude() && this.getLongitude() == ll2.getLongitude()){
return 0.0;
}
var dLon = ll2.getLongitude() - this.getLongitude();
var a = MQCONSTANT.MQLATLNG_RADIANS * (90.0 - this.getLatitude());
var c = MQCONSTANT.MQLATLNG_RADIANS * (90.0 - ll2.getLatitude());
var cosB = (Math.cos(a) * Math.cos(c)) + (Math.sin(a) * Math.sin(c) *
Math.cos(MQCONSTANT.MQLATLNG_RADIANS * (dLon)));
var radius = (lUnits.getValue() === MQCONSTANT.MQDISTANCEUNITS_MILES) ? 3963.205 : 6378.160187;
if (cosB < -1.0)
return MQCONSTANT.PI * radius;
else if (cosB >= 1.0)
return 0;
else
return Math.acos(cosB) * radius;
}
return -1;
};
MQLatLng.prototype.valid = function(){
if("undefined" !== typeof(mqutils)){
return ( Math.abs(this.getLatitude() - MQCONSTANT.MQLATLNG_INVALID) > MQCONSTANT.MQLATLNG_TOLERANCE &&
Math.abs(this.getLongitude() - MQCONSTANT.MQLATLNG_INVALID) > MQCONSTANT.MQLATLNG_TOLERANCE );
}
return false;
};
MQLatLng.prototype.equals = function(ll){
if (ll!==null){
return (this.getLongitude() === ll.getLongitude() && this.getLatitude() === ll.getLatitude());
}
return false;
};
MQLatLng.prototype.toString = function() {
return this.lat + "," + this.lng;
};
function mqCreateXMLDoc(strXML) {
var newDoc;
if (document.implementation.createDocument){
var parser = new window.DOMParser();
if(mqBrowserInfo.isSafari)
strXML = strXML.replace( /&/g,'&');
newDoc = parser.parseFromString(strXML, "text/xml");
} else if (window.ActiveXObject){
newDoc = new window.ActiveXObject("Microsoft.XMLDOM");
newDoc.async="false";
newDoc.loadXML(strXML);
}
return newDoc;
}
function mqCreateXMLDocFromNode(ndNewRoot) {
var newDoc;
ndNewRoot = ndNewRoot.documentElement;
if (document.implementation.createDocument){
var newDoc = document.implementation.createDocument("", "", null);
try{newDoc.appendChild(newDoc.importNode(ndNewRoot,true))}catch(error){alert(error);alert(ndNewRoot.nodeName);};
} else if (window.ActiveXObject){
newDoc = new ActiveXObject("Microsoft.XMLDOM");
newDoc.async="false";
newDoc.loadXML(ndNewRoot.xml);
}
return newDoc;
}
function MQXMLDOC(){
this.AUTOGEOCODECOVSWITCH = null;
this.AUTOROUTECOVSWITCH = null;
this.AUTOMAPCOVSWITCH = null;
this.DBLAYERQUERY = null;
this.LINEPRIMITIVE = null;
this.POLYGONPRIMITIVE = null;
this.RECTANGLEPRIMITIVE = null;
this.ELLIPSEPRIMITIVE = null;
this.TEXTPRIMITIVE = null;
this.SYMBOLPRIMITIVE = null;
this.LATLNG = null;
this.POINT = null;
this.POINTFEATURE = null;
this.LINEFEATURE = null;
this.POLYGONFEATURE = null;
this.LOCATION = null;
this.ADDRESS = null;
this.SINGLELINEADDRESS = null;
this.GEOADDRESS = null;
this.GEOCODEOPTIONS = null;
this.MANEUVER = null;
this.ROUTEOPTIONS = null;
this.ROUTERESULTS = null;
this.ROUTEMATRIXRESULTS = null;
this.RADIUSSEARCHCRITERIA = null;
this.RECTSEARCHCRITERIA = null;
this.POLYSEARCHCRITERIA = null;
this.CORRIDORSEARCHCRITERIA = null;
this.SIGN = null;
this.TREKROUTE = null;
this.INTCOLLECTION = null;
this.DTCOLLECTION = null;
this.LATLNGCOLLECTION = null;
this.LOCATIONCOLLECTION = null;
this.LOCATIONCOLLECTIONCOLLECTION = null;
this.MANEUVERCOLLECTION = null;
this.SIGNCOLLECTION = null;
this.STRINGCOLLECTION = null;
this.STRCOLCOLLECTION = null;
this.FEATURECOLLECTION = null;
this.PRIMITIVECOLLECTION = null;
this.POINTCOLLECTION = null;
this.TREKROUTECOLLECTION = null;
this.FEATURESPECIFIERCOLLECTION = null;
this.GEOCODEOPTIONSCOLLECTION = null;
this.COVERAGESTYLE = null;
this.RECORDSET = null;
this.MAPSTATE = null;
this.SESSION = null;
this.SESSIONID = null;
this.DTSTYLE = null;
this.DTSTYLEEX = null;
this.DTFEATURESTYLEEX = null;
this.FEATURESPECIFIER = null;
this.BESTFIT = null;
this.BESTFITLL = null;
this.CENTER = null;
this.CENTERLATLNG = null;
this.PAN = null;
this.ZOOMIN = null;
this.ZOOMOUT = null;
this.ZOOMTO = null;
this.ZOOMTORECT = null;
this.ZOOMTORECTLATLNG = null;
this.getAUTOGEOCODECOVSWITCH = function() {
if (this.AUTOGEOCODECOVSWITCH===null)
this.AUTOGEOCODECOVSWITCH = mqCreateXMLDoc("<AutoGeocodeCovSwitch/>");
return this.AUTOGEOCODECOVSWITCH;
}
this.getAUTOROUTECOVSWITCH = function() {
if (this.AUTOROUTECOVSWITCH===null)
this.AUTOROUTECOVSWITCH = mqCreateXMLDoc("<AutoRouteCovSwitch><Name/><DataVendorCodeUsage>0</DataVendorCodeUsage><DataVendorCodes Count=\"0\"/></AutoRouteCovSwitch>");
return this.AUTOROUTECOVSWITCH;
}
this.getAUTOMAPCOVSWITCH = function() {
if (this.AUTOMAPCOVSWITCH===null)
this.AUTOMAPCOVSWITCH = mqCreateXMLDoc("<AutoMapCovSwitch><Name/><Style/><DataVendorCodeUsage>0</DataVendorCodeUsage><DataVendorCodes Count=\"0\"/><ZoomLevels Count=\"14\"><Item>6000</Item><Item>12000</Item><Item>24000</Item><Item>48000</Item><Item>96000</Item><Item>192000</Item><Item>400000</Item><Item>800000</Item><Item>1600000</Item><Item>3000000</Item><Item>6000000</Item><Item>12000000</Item><Item>24000000</Item><Item>48000000</Item></ZoomLevels></AutoMapCovSwitch>");
return this.AUTOMAPCOVSWITCH;
}
this.getDBLAYERQUERY = function() {
if (this.DBLAYERQUERY===null)
this.DBLAYERQUERY = mqCreateXMLDoc("<DBLayerQuery/>");
return this.DBLAYERQUERY;
}
this.getLINEPRIMITIVE = function() {
if (this.LINEPRIMITIVE===null)
this.LINEPRIMITIVE = mqCreateXMLDoc("<LinePrimitive Version=\"2\"/>");
return this.LINEPRIMITIVE;
}
this.getPOLYGONPRIMITIVE = function() {
if (this.POLYGONPRIMITIVE===null)
this.POLYGONPRIMITIVE = mqCreateXMLDoc("<PolygonPrimitive Version=\"2\"/>");
return this.POLYGONPRIMITIVE;
}
this.getRECTANGLEPRIMITIVE = function() {
if (this.RECTANGLEPRIMITIVE===null)
this.RECTANGLEPRIMITIVE = mqCreateXMLDoc("<RectanglePrimitive Version=\"2\"/>");
return this.RECTANGLEPRIMITIVE;
}
this.getELLIPSEPRIMITIVE = function() {
if (this.ELLIPSEPRIMITIVE===null)
this.ELLIPSEPRIMITIVE = mqCreateXMLDoc("<EllipsePrimitive Version=\"2\"/>");
return this.ELLIPSEPRIMITIVE;
}
this.getTEXTPRIMITIVE = function() {
if (this.TEXTPRIMITIVE===null)
this.TEXTPRIMITIVE = mqCreateXMLDoc("<TextPrimitive Version=\"2\"/>");
return this.TEXTPRIMITIVE;
}
this.getSYMBOLPRIMITIVE = function() {
if (this.SYMBOLPRIMITIVE===null)
this.SYMBOLPRIMITIVE = mqCreateXMLDoc("<SymbolPrimitive Version=\"2\"/>");
return this.SYMBOLPRIMITIVE;
}
this.getLATLNG = function() {
if (this.LATLNG===null)
this.LATLNG = mqCreateXMLDoc("<LatLng/>");
return this.LATLNG;
}
this.getPOINT = function() {
if (this.POINT===null)
this.POINT = mqCreateXMLDoc("<Point/>");
return this.POINT;
}
this.getPOINTFEATURE = function() {
if (this.POINTFEATURE===null)
this.POINTFEATURE = mqCreateXMLDoc("<PointFeature/>");
return this.POINTFEATURE;
}
this.getLINEFEATURE = function() {
if (this.LINEFEATURE===null)
this.LINEFEATURE = mqCreateXMLDoc("<LineFeature/>");
return this.LINEFEATURE;
}
this.getPOLYGONFEATURE = function() {
if (this.POLYGONFEATURE===null)
this.POLYGONFEATURE = mqCreateXMLDoc("<PolygonFeature/>");
return this.POLYGONFEATURE;
}
this.getLOCATION = function() {
if (this.LOCATION===null)
this.LOCATION = mqCreateXMLDoc("<Location/>");
return this.LOCATION;
}
this.getADDRESS = function() {
if (this.ADDRESS===null)
this.ADDRESS = mqCreateXMLDoc("<Address/>");
return this.ADDRESS;
}
this.getSINGLELINEADDRESS = function() {
if (this.SINGLELINEADDRESS===null)
this.SINGLELINEADDRESS = mqCreateXMLDoc("<SingleLineAddress/>");
return this.SINGLELINEADDRESS;
}
this.getGEOADDRESS = function() {
if (this.GEOADDRESS===null)
this.GEOADDRESS = mqCreateXMLDoc("<GeoAddress/>");
return this.GEOADDRESS;
}
this.getGEOCODEOPTIONS = function() {
if (this.GEOCODEOPTIONS===null)
this.GEOCODEOPTIONS = mqCreateXMLDoc("<GeocodeOptions/>");
return this.GEOCODEOPTIONS;
}
this.getMANEUVER = function() {
if (this.MANEUVER===null)
this.MANEUVER = mqCreateXMLDoc("<Maneuver Version=\"1\"><Narrative/><Streets Count=\"0\"/><TurnType>-1</TurnType><Distance>0.0</Distance><Time>-1</Time><Direction>0</Direction><ShapePoints Count=\"0\"/><GEFIDs Count=\"0\"/><Signs Count=\"0\"/></Maneuver>");
return this.MANEUVER;
}
this.getROUTEOPTIONS = function() {
if (this.ROUTEOPTIONS===null)
this.ROUTEOPTIONS = mqCreateXMLDoc("<RouteOptions Version=\"3\"><RouteType>0</RouteType><NarrativeType>1</NarrativeType><NarrativeDistanceUnitType>0</NarrativeDistanceUnitType><MaxShape>0</MaxShape><MaxGEFID>0</MaxGEFID><Language>English</Language><CoverageName>navt_r</CoverageName><CovSwitcher><Name></Name><DataVendorCodeUsage>0</DataVendorCodeUsage><DataVendorCodes Count=\"0\"/></CovSwitcher><AvoidAttributeList Count=\"0\"/><AvoidGefIdList Count=\"0\"/><AvoidAbsoluteGefIdList Count=\"0\"/><StateBoundaryDisplay>1</StateBoundaryDisplay><CountryBoundaryDisplay>1</CountryBoundaryDisplay></RouteOptions>");
return this.ROUTEOPTIONS;
}
this.getROUTERESULTS = function() {
if (this.ROUTERESULTS===null)
this.ROUTERESULTS = mqCreateXMLDoc("<RouteResults Version=\"1\"><Locations Count=\"0\"/><CoverageName/><ResultMessages Count=\"0\"/><TrekRoutes Count=\"0\"/></RouteResults>");
return this.ROUTERESULTS;
}
this.getROUTEMATRIXRESULTS = function() {
if (this.ROUTEMATRIXRESULTS===null)
this.ROUTEMATRIXRESULTS = mqCreateXMLDoc("<RouteMatrixResults/>");
return this.ROUTEMATRIXRESULTS;
}
this.getRADIUSSEARCHCRITERIA = function() {
if (this.RADIUSSEARCHCRITERIA===null)
this.RADIUSSEARCHCRITERIA = mqCreateXMLDoc("<RadiusSearchCriteria/>");
return this.RADIUSSEARCHCRITERIA;
}
this.getRECTSEARCHCRITERIA = function() {
if (this.RECTSEARCHCRITERIA===null)
this.RECTSEARCHCRITERIA = mqCreateXMLDoc("<RectSearchCriteria/>");
return this.RECTSEARCHCRITERIA;
}
this.getPOLYSEARCHCRITERIA = function() {
if (this.POLYSEARCHCRITERIA===null)
this.POLYSEARCHCRITERIA = mqCreateXMLDoc("<PolySearchCriteria/>");
return this.POLYSEARCHCRITERIA;
}
this.getCORRIDORSEARCHCRITERIA = function() {
if (this.CORRIDORSEARCHCRITERIA===null)
this.CORRIDORSEARCHCRITERIA = mqCreateXMLDoc("<CorridorSearchCriteria/>");
return this.CORRIDORSEARCHCRITERIA;
}
this.getSIGN = function() {
if (this.SIGN===null)
this.SIGN = mqCreateXMLDoc("<Sign><Type>0</Type><Text></Text><ExtraText></ExtraText><Direction>0</Direction></Sign>");
return this.SIGN;
}
this.getTREKROUTE = function() {
if (this.TREKROUTE===null)
this.TREKROUTE = mqCreateXMLDoc("<TrekRoute><Maneuvers Count=\"0\"/></TrekRoute>");
return this.TREKROUTE;
}
this.getINTCOLLECTION = function() {
if (this.INTCOLLECTION===null)
this.INTCOLLECTION = mqCreateXMLDoc("<IntCollection Count=\"0\"/>");
return this.INTCOLLECTION;
}
this.getDTCOLLECTION = function() {
if (this.DTCOLLECTION===null)
this.DTCOLLECTION = mqCreateXMLDoc("<DTCollection Version=\"1\" Count=\"0\"/>");
return this.DTCOLLECTION;
}
this.getLATLNGCOLLECTION = function() {
if (this.LATLNGCOLLECTION===null)
this.LATLNGCOLLECTION = mqCreateXMLDoc("<LatLngCollection Version=\"1\" Count=\"0\"/>");
return this.LATLNGCOLLECTION;
}
this.getLOCATIONCOLLECTION = function() {
if (this.LOCATIONCOLLECTION===null)
this.LOCATIONCOLLECTION = mqCreateXMLDoc("<LocationCollection Count=\"0\"/>");
return this.LOCATIONCOLLECTION;
}
this.getLOCATIONCOLLECTIONCOLLECTION = function() {
if (this.LOCATIONCOLLECTIONCOLLECTION===null)
this.LOCATIONCOLLECTIONCOLLECTION = mqCreateXMLDoc("<LocationCollectionCollection Count=\"0\"/>");
return this.LOCATIONCOLLECTIONCOLLECTION;
}
this.getMANEUVERCOLLECTION = function() {
if (this.MANEUVERCOLLECTION===null)
this.MANEUVERCOLLECTION = mqCreateXMLDoc("<ManeuverCollection Count=\"0\"/>");
return this.MANEUVERCOLLECTION;
}
this.getSIGNCOLLECTION = function() {
if (this.SIGNCOLLECTION===null)
this.SIGNCOLLECTION = mqCreateXMLDoc("<SignCollection Count=\"0\"/>");
return this.SIGNCOLLECTION;
}
this.getSTRINGCOLLECTION = function() {
if (this.STRINGCOLLECTION===null)
this.STRINGCOLLECTION = mqCreateXMLDoc("<StringCollection Count=\"0\"/>");
return this.STRINGCOLLECTION;
}
this.getSTRCOLCOLLECTION = function() {
if (this.STRCOLCOLLECTION===null)
this.STRCOLCOLLECTION = mqCreateXMLDoc("<StrColCollectin/>");
return this.STRCOLCOLLECTION;
}
this.getFEATURECOLLECTION = function() {
if (this.FEATURECOLLECTION===null)
this.FEATURECOLLECTION = mqCreateXMLDoc("<FeatureCollection Count=\"0\"/>");
return this.FEATURECOLLECTION;
}
this.getPRIMITIVECOLLECTION = function() {
if (this.PRIMITIVECOLLECTION===null)
this.PRIMITIVECOLLECTION = mqCreateXMLDoc("<PrimitiveCollection Count=\"0\"/>");
return this.PRIMITIVECOLLECTION;
}
this.getPOINTCOLLECTION = function() {
if (this.POINTCOLLECTION===null)
this.POINTCOLLECTION = mqCreateXMLDoc("<PointCollection Count=\"0\"/>");
return this.POINTCOLLECTION;
}
this.getTREKROUTECOLLECTION = function() {
if (this.TREKROUTECOLLECTION===null)
this.TREKROUTECOLLECTION = mqCreateXMLDoc("<TrekRouteCollection Count=\"0\"/>");
return this.TREKROUTECOLLECTION;
}
this.getFEATURESPECIFIERCOLLECTION = function() {
if (this.FEATURESPECIFIERCOLLECTION===null)
this.FEATURESPECIFIERCOLLECTION = mqCreateXMLDoc("<FeatureSpecifierCollection Count=\"0\"/>");
return this.FEATURESPECIFIERCOLLECTION;
}
this.getGEOCODEOPTIONSCOLLECTION = function() {
if (this.GEOCODEOPTIONSCOLLECTION===null)
this.GEOCODEOPTIONSCOLLECTION = mqCreateXMLDoc("<GeocodeOptionsCollection Count=\"0\"/>");
return this.GEOCODEOPTIONSCOLLECTION;
}
this.getCOVERAGESTYLE = function() {
if (this.COVERAGESTYLE===null)
this.COVERAGESTYLE = mqCreateXMLDoc("<CoverageStyle/>");
return this.COVERAGESTYLE;
}
this.getRECORDSET = function() {
if (this.RECORDSET===null)
this.RECORDSET = mqCreateXMLDoc("<RecordSet/>");
return this.RECORDSET;
}
this.getMAPSTATE = function() {
if (this.MAPSTATE===null)
this.MAPSTATE = mqCreateXMLDoc("<MapState/>");
return this.MAPSTATE;
}
this.getSESSION = function() {
if (this.SESSION===null)
this.SESSION = mqCreateXMLDoc("<Session Count=\"0\"/>");
return this.SESSION;
}
this.getSESSIONID = function() {
if (this.SESSIONID===null)
this.SESSIONID = mqCreateXMLDoc("<SessionID/>");
return this.SESSIONID;
}
this.getDTSTYLE = function() {
if (this.DTSTYLE===null)
this.DTSTYLE = mqCreateXMLDoc("<DTStyle/>");
return this.DTSTYLE;
}
this.getDTSTYLEEX = function() {
if (this.DTSTYLEEX===null)
this.DTSTYLEEX = mqCreateXMLDoc("<DTStyleEx/>");
return this.DTSTYLEEX;
}
this.getDTFEATURESTYLEEX = function() {
if (this.DTFEATURESTYLEEX===null)
this.DTFEATURESTYLEEX = mqCreateXMLDoc("<DTFeatureStyleEx/>");
return this.DTFEATURESTYLEEX;
}
this.getFEATURESPECIFIER = function() {
if (this.FEATURESPECIFIER===null)
this.FEATURESPECIFIER = mqCreateXMLDoc("<FeatureSpecifier/>");
return this.FEATURESPECIFIER;
}
this.getBESTFIT = function() {
if (this.BESTFIT===null)
this.BESTFIT = mqCreateXMLDoc("<BestFit Version=\"2\"/>");
return this.BESTFIT;
}
this.getBESTFITLL = function() {
if (this.BESTFITLL===null)
this.BESTFITLL = mqCreateXMLDoc("<BestFitLL Version=\"2\"/>");
return this.BESTFITLL;
}
this.getCENTER = function() {
if (this.CENTER===null)
this.CENTER = mqCreateXMLDoc("<Center/>");
return this.CENTER;
}
this.getCENTERLATLNG = function() {
if (this.CENTERLATLNG===null)
this.CENTERLATLNG = mqCreateXMLDoc("<CenterLatLng/>");
return this.CENTERLATLNG;
}
this.getPAN = function() {
if (this.PAN===null)
this.PAN = mqCreateXMLDoc("<Pan/>");
return this.PAN;
}
this.getZOOMIN = function() {
if (this.ZOOMIN===null)
this.ZOOMIN = mqCreateXMLDoc("<ZoomIn/>");
return this.ZOOMIN;
}
this.getZOOMOUT = function() {
if (this.ZOOMOUT===null)
this.ZOOMOUT = mqCreateXMLDoc("<ZoomOut/>");
return this.ZOOMOUT;
}
this.getZOOMTO = function() {
if (this.ZOOMTO===null)
this.ZOOMTO = mqCreateXMLDoc("<ZoomTo/>");
return this.ZOOMTO;
}
this.getZOOMTORECT = function() {
if (this.ZOOMTORECT===null)
this.ZOOMTORECT = mqCreateXMLDoc("<ZoomToRect/>");
return this.ZOOMTORECT;
}
this.getZOOMTORECTLATLNG = function() {
if (this.ZOOMTORECTLATLNG===null)
this.ZOOMTORECTLATLNG = mqCreateXMLDoc("<ZoomToRectLatLng/>");
return this.ZOOMTORECTLATLNG;
}
}
var MQXML = new MQXMLDOC();
MQObjectCollection.prototype = new MQObject();
MQObjectCollection.prototype.constructor = MQObjectCollection;
function MQObjectCollection(max) {
MQObject.call(this);
var m_items = new Array();
this.getM_Items = function(){
return m_items;
};
var m_maxItems = ( max !== null ) ? max : -1;
var validClassName = "MQObject";
this.getValidClassName = function(){
return validClassName;
};
this.setValidClassName = function(className){
validClassName = className;
};
this.add = function(obj){
if(this.isValidObject(obj)){
if (m_maxItems !== -1 && m_items.length === max) return;
m_items.push(obj);
return m_items.length;
}
return;
};
this.getSize = function () {
return m_items.length;
};
this.get = function(i){
return m_items[i];
};
this.remove = function (iIndex) {
return m_items.splice(iIndex, 1);
};
this.removeAll = function () {
m_items = null;
m_items = new Array();
};
this.contains = function (item) {
var size = this.getSize();
for (var count = 0; count < size; count++) {
if (m_items[count] === item) {
return true;
}
}
return false;
};
this.append = function(collection){
if(this.getClassName()===collection.getClassName()){
m_items = m_items.concat(collection.getM_Items());
} else {
alert("Invalid attempt to append " + this.getClassName() + " to " + collection.getClassName() + "!");
throw "Invalid attempt to append " + this.getClassName() + " to " + collection.getClassName() + "!";
}
};
this.set = function(i, newO){
var oldO = get(i);
m_items[i] = newO;
return oldO;
};
this.isValidObject = function(obj) {
if(obj!==null){
if(validClassName === "ALL"){
return true;
}else if(validClassName === "MQObject"){
return true;
}else if(validClassName === "String"){
return true;
} else if(validClassName === "int"){
if (isNaN(obj)){
return false;
} else if (obj === Math.floor(obj)){
return true;
}
} else if(obj.getClassName() === validClassName ){
return true;
}
}
return false;
};
var m_itemXpath = "Item";
this.getM_itemXpath = function() {
return m_itemXpath;
};
this.setM_itemXpath = function(itemXpath) {
m_itemXpath = itemXpath;
};
this.getById = function (strId) {
try{
for (var count = 0; count < this.getSize(); count++) {
if (m_items[count].getId() == strId) {
return m_items[count];
}
}
}catch(Error){
}
return null;
};
this.removeItem = function (item) {
for(var i = 0; i < m_items.length; i++)
{
if (m_items[i] == item)
{
this.remove(i);
i = m_items.length;
}
}
};
}
MQObjectCollection.prototype.getClassName = function(){
return "MQObjectCollection";
};
MQObjectCollection.prototype.getObjectVersion = function(){
return 0;
};
MQObjectCollection.prototype.getAt = function(i){
return this.get(i);
};
MQLatLngCollection.prototype = new MQObjectCollection(32678);
MQLatLngCollection.prototype.constructor = MQLatLngCollection;
function MQLatLngCollection() {
MQObjectCollection.call(this, 32678);
this.setValidClassName("MQLatLng");
this.setM_Xpath("LatLngCollection");
this.setM_XmlDoc(mqCreateXMLDocFromNode(MQXML.getLATLNGCOLLECTION()));
}
MQLatLngCollection.prototype.getClassName = function(){
return "MQLatLngCollection";
};
MQLatLngCollection.prototype.getObjectVersion = function(){
return 1;
};
MQLatLngCollection.prototype.loadXml = function (strXml) {
this.removeAll();
var xmlDoc = mqCreateXMLDoc(strXml);
this.setM_XmlDoc(xmlDoc);
if (xmlDoc!==null){
this._loadCollection(xmlDoc);
}
};
MQLatLngCollection.prototype.loadXmlFromNode = function (xmlNode) {
this.removeAll();
var xmlDoc = mqCreateXMLDocImportNode(xmlNode);
this.setM_XmlDoc(xmlDoc);
if (xmlDoc!==null){
this._loadCollection(xmlDoc);
}
};
MQLatLngCollection.prototype._loadCollection = function (xmlDoc) {
var root = xmlDoc.documentElement;
var nodes = root.childNodes;
var maxCount = nodes.length;
maxCount = (maxCount < 32678) ? maxCount : 32678;
var prevLat = 0;
var prevLng = 0;
var currentLat = 0;
var currentLng = 0;
var latlng = null;
if(this.getValidClassName()==="MQLatLng"){
for (var count = 0;count < maxCount; count++){
if(count==0){
if(nodes[count].firstChild!==null){
currentLat = nodes[count].firstChild.nodeValue/1000000;
}
count++;
if(nodes[count].firstChild!==null){
currentLng = nodes[count].firstChild.nodeValue/1000000;
}
} else {
if(nodes[count].firstChild!==null){
currentLat = prevLat + (nodes[count].firstChild.nodeValue/1000000);
}
count++;
if(nodes[count].firstChild!==null){
currentLng = prevLng + (nodes[count].firstChild.nodeValue/1000000);
}
}
prevLat = currentLat;
prevLng = currentLng;
latlng = new MQLatLng(currentLat, currentLng);
this.add(latlng);
}
}
};
MQLatLngCollection.prototype.saveXml = function () {
var strRet = "<" + this.getM_Xpath() + " Version=\"" + this.getObjectVersion() + "\" Count=\"" + this.getSize() + "\">";
var size = parseInt(this.getSize());
if(size >= 1){
var nLat = nLng = nPrevLat = nPrevLng = nDeltaLat = nDeltaLng = 0;
var latLng = null;
for(var i = 0; i < size; i++){
latLng = this.getAt(i);
nLat = parseInt(latLng.getLatitude() * 1000000);
nLng = parseInt(latLng.getLongitude() * 1000000);
nDeltaLat = nLat - nPrevLat;
nDeltaLng = nLng - nPrevLng;
strRet += "<Lat>" + nDeltaLat + "</Lat>";
strRet += "<Lng>" + nDeltaLng + "</Lng>";
nPrevLat = nLat;
nPrevLng = nLng;
}
}
strRet = strRet + "</" + this.getM_Xpath() + ">";
return strRet;
};
MQLatLngCollection.prototype.generalize = function(dDeviance) {
var SOrigPoint = function()
{
this.pLL = null;
this.dSegmentLength = 0.0;
this.dPriorLength = 0.0;
};
var SDerivedPoint = function()
{
this.pLL = null;
this.ulOriginalPoint = 0;
};
mqllAnchor = null;
var ulAnchor;
var i;
var dAccumLength = 0.0;
var nPoints = this.getSize();
var pOrigPoints = new Array(nPoints);
var pDerivedPoints = new Array(nPoints);
var nDerivedPoints = 0;
if (nPoints < 2)
return;
for (i = 0; i < nPoints; i++)
{
pOrigPoints[i] = new SOrigPoint();
pDerivedPoints[i] = new SDerivedPoint();
pOrigPoints[i].pLL = this.getAt(i);
}
for (i = 0; i < nPoints - 1; i++)
{
pOrigPoints[i].dSegmentLength = pOrigPoints[i].pLL.arcDistance(pOrigPoints[(i+1)].pLL);
if (i == 0)
pOrigPoints[i].dPriorLength = 0.0;
else
pOrigPoints[i].dPriorLength = dAccumLength;
dAccumLength += pOrigPoints[i].dSegmentLength;
}
mqllAnchor = pOrigPoints[0].pLL;
ulAnchor = 0;
pDerivedPoints[0].pLL = mqllAnchor;
pDerivedPoints[0].ulOriginalPoint = 0;
nDerivedPoints = 1;
for (i = 2; i < nPoints; i++)
{
if (!this.isEverybodyWithinDeviation(pOrigPoints, ulAnchor, i, dDeviance))
{
mqllAnchor = pOrigPoints[(i - 1)].pLL;
ulAnchor = (i - 1);
pDerivedPoints[nDerivedPoints].pLL = mqllAnchor;
pDerivedPoints[nDerivedPoints].ulOriginalPoint = (i - 1);
nDerivedPoints++;
}
}
pDerivedPoints[nDerivedPoints].pLL = pOrigPoints[nPoints - 1].pLL;
pDerivedPoints[nDerivedPoints].ulOriginalPoint = nPoints - 1;
nDerivedPoints++;
var nPrev = nPoints;
var nCount;
for (nCount=(nDerivedPoints-1);nCount>=0;nCount--)
{
if ((nPrev-1) != pDerivedPoints[nCount].ulOriginalPoint)
{
for (var x=(nPrev-1);x>pDerivedPoints[nCount].ulOriginalPoint;x--)
{
try
{
this.remove(x);
}
catch(e)
{
}
}
nPrev = pDerivedPoints[nCount].ulOriginalPoint;
}
else
{
nPrev--;
}
}
pOrigPoints=null;
pDerivedPoints=null;
};
MQLatLngCollection.prototype.isEverybodyWithinDeviation = function( pOrigPoints,
ulOrigStartPoint,
ulOrigEndPoint,
dMaxDeviation)
{
var dMilesPerLng=0.0;
var dMaxDeviationSquared=0.0;
var mqllStartPoint=null;
var mqllEndPoint=null;
var dLineLatMiles=0.0;
var dLineLngMiles=0.0;
var dLineLengthSquared=0.0;
var i;
var mqllPoint=null;
var dPointLatMiles=0.0;
var dPointLngMiles=0.0;
var dPointLengthSquared=0.0;
var dRatio=0.0;
var dNumerator=0.0;
var dDenominator=0.0;
var dProjectionLengthSquared=0.0;
var dDeviationLengthSquared=0.0;
dMilesPerLng = DistanceApproximation.getMilesPerLngDeg(pOrigPoints[ulOrigStartPoint].pLL.getLatitude());
dMaxDeviationSquared = dMaxDeviation * dMaxDeviation;
mqllStartPoint = pOrigPoints[ulOrigStartPoint].pLL;
mqllEndPoint = pOrigPoints[ulOrigEndPoint].pLL;
dLineLatMiles = (mqllEndPoint.getLatitude() - mqllStartPoint.getLatitude()) * DistanceApproximation.MILES_PER_LATITUDE;
dLineLngMiles = (mqllEndPoint.getLongitude() - mqllStartPoint.getLongitude()) * dMilesPerLng;
dLineLengthSquared = dLineLatMiles * dLineLatMiles + dLineLngMiles * dLineLngMiles;
for (i = ulOrigStartPoint + 1; i < ulOrigEndPoint; i++)
{
mqllPoint = pOrigPoints[i].pLL;
dPointLatMiles = (mqllPoint.getLatitude() - mqllStartPoint.getLatitude()) * DistanceApproximation.MILES_PER_LATITUDE;;
dPointLngMiles = (mqllPoint.getLongitude() - mqllStartPoint.getLongitude()) * dMilesPerLng;
dPointLengthSquared = dPointLatMiles * dPointLatMiles + dPointLngMiles * dPointLngMiles;
dNumerator = dLineLatMiles * dPointLatMiles + dLineLngMiles * dPointLngMiles;
dDenominator = dLineLatMiles * dLineLatMiles + dLineLngMiles * dLineLngMiles;
if (dDenominator == 0)
dRatio = 0;
else
dRatio = dNumerator / dDenominator;
dProjectionLengthSquared = dRatio * dRatio * dLineLengthSquared;
dDeviationLengthSquared = dPointLengthSquared - dProjectionLengthSquared;
if (dDeviationLengthSquared > dMaxDeviationSquared)
return false;
}
return true;
};
var DistanceApproximation = new function()
{
this.m_testLat;
this.m_testLng;
this.m_mpd;
this.m_milesPerLngDeg = new Array(69.170976, 69.160441, 69.128838, 69.076177, 69.002475,
68.907753, 68.792041, 68.655373, 68.497792, 68.319345,
68.120088, 67.900079, 67.659387, 67.398085, 67.116253,
66.813976, 66.491346, 66.148462, 65.785428, 65.402355,
64.999359, 64.576564, 64.134098, 63.672096, 63.190698,
62.690052, 62.170310, 61.631630, 61.074176, 60.498118,
59.903632, 59.290899, 58.660106, 58.011443, 57.345111,
56.661310, 55.960250, 55.242144, 54.507211, 53.755675,
52.987764, 52.203713, 51.403761, 50.588151, 49.757131,
48.910956, 48.049882, 47.174172, 46.284093, 45.379915,
44.461915, 43.530372, 42.585570, 41.627796, 40.657342,
39.674504, 38.679582, 37.672877, 36.654698, 35.625354,
34.585159, 33.534429, 32.473485, 31.402650, 30.322249,
29.232613, 28.134073, 27.026963, 25.911621, 24.788387,
23.657602, 22.519612, 21.374762, 20.223401, 19.065881,
17.902554, 16.733774, 15.559897, 14.381280, 13.198283,
12.011266, 10.820591, 9.626619, 8.429716, 7.230245,
6.028572, 4.825062, 3.620083, 2.414002, 1.207185,
1.000000);
this.MILES_PER_LATITUDE = 69.170976;
this.KILOMETERS_PER_MILE = 1.609347;
this.getMilesPerLngDeg = function(lat)
{
return (Math.abs(lat) <= 90.0) ? this.m_milesPerLngDeg[parseInt(Math.abs(lat) + 0.5)] : 69.170976;
}
};
Documentation generated by
JSDoc on Tue Oct 16 08:04:12 2007