ym4r-mapstraction 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +158 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/javascript/clusterer.js +410 -0
- data/javascript/mapquest-js/mqcommon.js +1740 -0
- data/javascript/mapquest-js/mqexec.js +977 -0
- data/javascript/mapquest-js/mqobjects.js +10733 -0
- data/javascript/mapquest-js/mqutils.js +1001 -0
- data/javascript/mapstraction-geocode.js +179 -0
- data/javascript/mapstraction-route.js +200 -0
- data/javascript/mapstraction.js +3570 -0
- data/javascript/ym4r-mapstraction.js +105 -0
- data/lib/mapstraction_plugin/helper.rb +14 -0
- data/lib/mapstraction_plugin/mapping.rb +120 -0
- data/lib/mapstraction_plugin/mapstraction.rb +309 -0
- data/lib/mapstraction_plugin/overlay.rb +105 -0
- data/lib/mapstraction_plugin/routing.rb +56 -0
- data/lib/ym4r_mapstraction.rb +43 -0
- data/tasks/ym4r_mapstraction_tasks.rake +4 -0
- data/test/ym4r_mapstraction_test.rb +8 -0
- data/ym4r-mapstraction.gemspec +69 -0
- metadata +84 -0
@@ -0,0 +1,1740 @@
|
|
1
|
+
//#############################################################################
|
2
|
+
// Begin class MQBrowser
|
3
|
+
//#############################################################################
|
4
|
+
/**
|
5
|
+
* Constructs a new MQBrowser object.
|
6
|
+
* @class Class that will contain all information about
|
7
|
+
* the browser in which the code is running.
|
8
|
+
* @private
|
9
|
+
*/
|
10
|
+
function MQBrowser(){
|
11
|
+
/** @type String
|
12
|
+
*/
|
13
|
+
this.name = null;
|
14
|
+
/** @type String
|
15
|
+
*/
|
16
|
+
this.version = null;
|
17
|
+
/** @type String
|
18
|
+
*/
|
19
|
+
this.os = null;
|
20
|
+
/** @type String
|
21
|
+
*/
|
22
|
+
this.appname = null;
|
23
|
+
/** @type String
|
24
|
+
*/
|
25
|
+
this.appVersion = null;
|
26
|
+
/** @type String
|
27
|
+
*/
|
28
|
+
this.vMajor = null;
|
29
|
+
/** @type Boolean
|
30
|
+
*/
|
31
|
+
this.isNS = null;
|
32
|
+
/** @type Boolean
|
33
|
+
*/
|
34
|
+
this.isNS4 = null;
|
35
|
+
/** @type Boolean
|
36
|
+
*/
|
37
|
+
this.isNS6 = null;
|
38
|
+
/** @type Boolean
|
39
|
+
*/
|
40
|
+
this.isIE = null;
|
41
|
+
/** @type Boolean
|
42
|
+
*/
|
43
|
+
this.isIE4 = null;
|
44
|
+
/** @type Boolean
|
45
|
+
*/
|
46
|
+
this.isIE5 = null;
|
47
|
+
/** @type Boolean
|
48
|
+
*/
|
49
|
+
this.isDOM = null;
|
50
|
+
/** @type Boolean
|
51
|
+
*/
|
52
|
+
this.isSafari = null;
|
53
|
+
/** @type String
|
54
|
+
*/
|
55
|
+
this.platform = null;
|
56
|
+
}
|
57
|
+
// End class MQBrowser
|
58
|
+
|
59
|
+
|
60
|
+
//#############################################################################
|
61
|
+
// Browser code
|
62
|
+
//#############################################################################
|
63
|
+
/**
|
64
|
+
* Get Browser info for functions.
|
65
|
+
* @return Returns a Browser object.
|
66
|
+
* @type MQBrowser
|
67
|
+
* @private
|
68
|
+
*/
|
69
|
+
function mqGetBrowserInfo()
|
70
|
+
{
|
71
|
+
var browser = new MQBrowser();
|
72
|
+
browser.name = browser.version = browser.os = "unknown";
|
73
|
+
var userAgent = window.navigator.userAgent.toLowerCase();
|
74
|
+
var appname = window.navigator.appName;
|
75
|
+
var appVersion = window.navigator.appVersion;
|
76
|
+
var browserListArray = new Array("firefox", "msie", "netscape", "opera", "safari");
|
77
|
+
var osListArray = new Array("linux", "mac", "windows", "x11");
|
78
|
+
var browserListlength = browserListArray.length;
|
79
|
+
var strPosition = "";
|
80
|
+
for(var i = 0, n = browserListlength; i < n; i++)
|
81
|
+
{ // get browser name and version
|
82
|
+
strPosition = userAgent.indexOf(browserListArray[i]) + 1;
|
83
|
+
if(strPosition > 0)
|
84
|
+
{
|
85
|
+
browser.name = browserListArray[i]; // browser name
|
86
|
+
|
87
|
+
var versionPosition = strPosition + browser.name.length;
|
88
|
+
var incr = ((browser.name == "safari") || (userAgent.charAt(versionPosition + 4) > 0 && userAgent.charAt(versionPosition + 4) < 9)) ? 5 : 3;
|
89
|
+
browser.version = userAgent.substring(versionPosition, versionPosition + incr); // browser version
|
90
|
+
}
|
91
|
+
}
|
92
|
+
var osListArrayLength = osListArray.length;
|
93
|
+
for(var j = 0, m = osListArrayLength; j < m; j++)
|
94
|
+
{
|
95
|
+
strPosition = userAgent.indexOf(osListArray[j]) + 1;
|
96
|
+
if(strPosition > 0)
|
97
|
+
{
|
98
|
+
browser.os = osListArray[j];
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
if (appname == "Netscape")
|
103
|
+
browser.appname = "ns";
|
104
|
+
else if (appname == "Microsoft Internet Explorer")
|
105
|
+
browser.appname = "ie";
|
106
|
+
|
107
|
+
browser.appVersion = appVersion;
|
108
|
+
browser.vMajor = parseInt(browser.appVersion);
|
109
|
+
browser.isNS = (browser.appname =="ns" && browser.vMajor >= 4);
|
110
|
+
browser.isNS4 = (browser.appname =="ns" && browser.vMajor == 4);
|
111
|
+
browser.isNS6 = (browser.appname =="ns" && browser.vMajor == 5);
|
112
|
+
browser.isIE = (browser.appname =="ie" && browser.vMajor >= 4);
|
113
|
+
browser.isIE4 = (browser.appVersion.indexOf ('MSIE 4') >0);
|
114
|
+
browser.isIE5 = (browser.appVersion.indexOf ('MSIE 5') >0);
|
115
|
+
browser.isDOM = (document.createElement
|
116
|
+
&& document.appendChild
|
117
|
+
&& document.getElementsByTagName) ? true : false;
|
118
|
+
|
119
|
+
browser.isSafari = (browser.name == "safari");
|
120
|
+
if (userAgent.indexOf ("win") > - 1)
|
121
|
+
browser.platform = "win";
|
122
|
+
else if (userAgent.indexOf("mac") > -1)
|
123
|
+
browser.platform = "mac";
|
124
|
+
else
|
125
|
+
browser.platform="other";
|
126
|
+
|
127
|
+
return browser;
|
128
|
+
|
129
|
+
} //getBrowserInfo()
|
130
|
+
|
131
|
+
var mqBrowserInfo = mqGetBrowserInfo();
|
132
|
+
|
133
|
+
|
134
|
+
//#############################################################################
|
135
|
+
// Begin class MQObject
|
136
|
+
//#############################################################################
|
137
|
+
/**
|
138
|
+
* Constructs a new MQObject object.
|
139
|
+
* @class Base class for almost all objects in
|
140
|
+
* the api.
|
141
|
+
*/
|
142
|
+
function MQObject(){
|
143
|
+
/**
|
144
|
+
* Value to represent the xml
|
145
|
+
* @type Document
|
146
|
+
*
|
147
|
+
*/
|
148
|
+
var m_xmlDoc = null;
|
149
|
+
/**
|
150
|
+
* Returns the m_xmlDoc object.
|
151
|
+
* @return The m_xmlDoc object.
|
152
|
+
* @type Document
|
153
|
+
*
|
154
|
+
*/
|
155
|
+
this.getM_XmlDoc = function() {
|
156
|
+
return m_xmlDoc;
|
157
|
+
};
|
158
|
+
/**
|
159
|
+
* Sets the m_xmlDoc object.
|
160
|
+
* @param {Document} xmlDoc the Document to set m_xmlDoc to.
|
161
|
+
* @type void
|
162
|
+
*
|
163
|
+
*/
|
164
|
+
this.setM_XmlDoc = function(xmlDoc) {
|
165
|
+
m_xmlDoc = xmlDoc;
|
166
|
+
};
|
167
|
+
/**
|
168
|
+
* Value to represent the xpath of this object
|
169
|
+
* @type Document
|
170
|
+
*
|
171
|
+
*/
|
172
|
+
var m_xpath = null;
|
173
|
+
/**
|
174
|
+
* Returns the m_xpath string.
|
175
|
+
* @return The m_xpath string.
|
176
|
+
* @type String
|
177
|
+
*
|
178
|
+
*/
|
179
|
+
this.getM_Xpath = function() {
|
180
|
+
return m_xpath;
|
181
|
+
};
|
182
|
+
/**
|
183
|
+
* Sets the m_xpath object.
|
184
|
+
* @param {String} xpath the String m_xpath is set to.
|
185
|
+
* @type void
|
186
|
+
*
|
187
|
+
*/
|
188
|
+
this.setM_Xpath = function(xpath) {
|
189
|
+
m_xpath = xpath;
|
190
|
+
};
|
191
|
+
}
|
192
|
+
/**
|
193
|
+
* Returns the text name of this class.
|
194
|
+
* @return The text name of this class.
|
195
|
+
* @type String
|
196
|
+
*/
|
197
|
+
MQObject.prototype.getClassName = function(){
|
198
|
+
return "MQObject";
|
199
|
+
};
|
200
|
+
/**
|
201
|
+
* Returns the version of this class.
|
202
|
+
* @return The version of this class.
|
203
|
+
* @type int
|
204
|
+
*/
|
205
|
+
MQObject.prototype.getObjectVersion = function(){
|
206
|
+
return 0;
|
207
|
+
};
|
208
|
+
|
209
|
+
/**
|
210
|
+
* Sets values in xml.
|
211
|
+
* @param {String} strPropName the property to set
|
212
|
+
* @param {String} strPropValue the value to set the property to
|
213
|
+
* @type void
|
214
|
+
*
|
215
|
+
*/
|
216
|
+
MQObject.prototype.setProperty = function (strPropName, strPropValue) {
|
217
|
+
var strXPathExpression;
|
218
|
+
if (strPropName!==null) strXPathExpression= "/" + this.getM_Xpath() + "/" + strPropName;
|
219
|
+
else strXPathExpression= "/" + this.getM_Xpath();
|
220
|
+
var ndNewProp = mqSetNodeText(this.getM_XmlDoc(),strXPathExpression,strPropValue);
|
221
|
+
if ( ndNewProp === null) {
|
222
|
+
var ndNewPropParent = this.getM_XmlDoc().createElement(strPropName);
|
223
|
+
var ndRoot = this.getM_XmlDoc().documentElement.appendChild(ndNewPropParent);
|
224
|
+
ndNewProp = mqSetNodeText(this.getM_XmlDoc(),strXPathExpression,strPropValue);
|
225
|
+
}
|
226
|
+
return ndNewProp;
|
227
|
+
};
|
228
|
+
/**
|
229
|
+
* Gets values from xml.
|
230
|
+
* @param {String} strPropName the property to get
|
231
|
+
* @return The property
|
232
|
+
* @type String
|
233
|
+
*
|
234
|
+
*/
|
235
|
+
MQObject.prototype.getProperty = function (strPropName) {
|
236
|
+
var strXPathExpression;
|
237
|
+
if (strPropName!==null) strXPathExpression= "/" + this.getM_Xpath() + "/" + strPropName;
|
238
|
+
else strXPathExpression= "/" + this.getM_Xpath();
|
239
|
+
return mqGetXPathNodeText(this.getM_XmlDoc(),strXPathExpression);
|
240
|
+
};
|
241
|
+
/**
|
242
|
+
* Create a copy of this object.
|
243
|
+
* @return The new object which is a copy of this
|
244
|
+
* @type MQObject
|
245
|
+
*/
|
246
|
+
MQObject.prototype.copy = function () {
|
247
|
+
var cp = new this.constructor;
|
248
|
+
cp.loadXml(this.saveXml());
|
249
|
+
return cp;
|
250
|
+
};
|
251
|
+
/**
|
252
|
+
* Create a copy of this object where the outermost tag remains the same.
|
253
|
+
* @return The new object which is a copy of this except the outermost tag.
|
254
|
+
* @type MQObject
|
255
|
+
* @private
|
256
|
+
*/
|
257
|
+
MQObject.prototype.internalCopy = function (obj) {
|
258
|
+
var strXml = "<" + obj.getM_Xpath();
|
259
|
+
if(this.getObjectVersion() > 0){
|
260
|
+
strXml = strXml + " Version=\"" + this.getObjectVersion() + "\"";
|
261
|
+
}
|
262
|
+
strXml = strXml + ">";
|
263
|
+
var root = this.getM_XmlDoc().documentElement;
|
264
|
+
var nodes = root.childNodes;
|
265
|
+
var maxCount = nodes.length;
|
266
|
+
for (var count=0;count<maxCount;count++){
|
267
|
+
strXml = strXml + mqXmlToStr(nodes[count]);
|
268
|
+
}
|
269
|
+
strXml = strXml + "</" + obj.getM_Xpath() + ">";
|
270
|
+
var cp = new this.constructor;
|
271
|
+
cp.loadXml(strXml);
|
272
|
+
return cp;
|
273
|
+
};
|
274
|
+
// End class MQObject
|
275
|
+
|
276
|
+
|
277
|
+
//#############################################################################
|
278
|
+
// Begin Class MQPoint
|
279
|
+
// Inheirit from MQObject
|
280
|
+
MQPoint.prototype = new MQObject();
|
281
|
+
MQPoint.prototype.constructor = MQPoint;
|
282
|
+
//#############################################################################
|
283
|
+
/**
|
284
|
+
* Constructs a new MQPoint object.
|
285
|
+
*
|
286
|
+
* @class Encapsulates X and Y coordinates.
|
287
|
+
* @param {int/string} param1 OPTIONAL: Depending on the absence of param2.
|
288
|
+
* If param2 exists then param1 is initial x (int - default is 0) otherwise
|
289
|
+
* param1 is xpath (string - default is "Point").
|
290
|
+
* @param {int} param2 OPTIONAL: initial y (default is 0).
|
291
|
+
* @extends MQObject
|
292
|
+
*/
|
293
|
+
function MQPoint(param1, param2) {
|
294
|
+
MQObject.call(this);
|
295
|
+
/**
|
296
|
+
* Value to represent the x value
|
297
|
+
* @type int
|
298
|
+
*/
|
299
|
+
this.x = 0;
|
300
|
+
/**
|
301
|
+
* Value to represent the y value
|
302
|
+
* @type int
|
303
|
+
*/
|
304
|
+
this.y = 0;
|
305
|
+
|
306
|
+
// Set default path
|
307
|
+
this.setM_Xpath("Point");
|
308
|
+
|
309
|
+
if (arguments.length == 1){
|
310
|
+
this.setM_Xpath(param1);
|
311
|
+
}
|
312
|
+
else if (arguments.length == 2){
|
313
|
+
this.x = parseInt(param1);
|
314
|
+
this.y = parseInt(param2);
|
315
|
+
if (isNaN(this.x) || isNaN(this.y))
|
316
|
+
throw new Error("MQPoint constructor called with invalid parameter");
|
317
|
+
}
|
318
|
+
else if (arguments.length > 2){
|
319
|
+
throw new Error("MQPoint constructor called with "
|
320
|
+
+ arguments.length
|
321
|
+
+ " arguments, but it expects 0, 1, or 2 arguments");
|
322
|
+
}
|
323
|
+
|
324
|
+
}
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Returns the text name of this class.
|
328
|
+
* @return The text name of this class.
|
329
|
+
* @type String
|
330
|
+
*/
|
331
|
+
MQPoint.prototype.getClassName = function(){
|
332
|
+
return "MQPoint";
|
333
|
+
};
|
334
|
+
/**
|
335
|
+
* Returns the version of this class.
|
336
|
+
* @return The version of this class.
|
337
|
+
* @type int
|
338
|
+
*/
|
339
|
+
MQPoint.prototype.getObjectVersion = function(){
|
340
|
+
return 0;
|
341
|
+
};
|
342
|
+
/**
|
343
|
+
* Assigns the xml that relates to this object.
|
344
|
+
* @param {String} strXml the xml to be assigned.
|
345
|
+
* @type void
|
346
|
+
*
|
347
|
+
*/
|
348
|
+
MQPoint.prototype.loadXml = function (strXml) {
|
349
|
+
if("undefined" !== typeof(mqutils)){
|
350
|
+
this.setM_XmlDoc(mqCreateXMLDoc(strXml));
|
351
|
+
this.x = this.getProperty("X");
|
352
|
+
this.y = this.getProperty("Y");
|
353
|
+
}
|
354
|
+
};
|
355
|
+
/**
|
356
|
+
* Build an xml string that represents this object.
|
357
|
+
* @return The xml string.
|
358
|
+
* @type String
|
359
|
+
*
|
360
|
+
*/
|
361
|
+
MQPoint.prototype.saveXml = function () {
|
362
|
+
return "<" + this.getM_Xpath() + "><X>" + this.x + "</X><Y>" + this.y + "</Y></" + this.getM_Xpath() + ">";
|
363
|
+
};
|
364
|
+
/**
|
365
|
+
* Sets X.
|
366
|
+
* @param {int} x the value to set X to
|
367
|
+
* @type void
|
368
|
+
*/
|
369
|
+
MQPoint.prototype.setX = function(x){
|
370
|
+
this.x = parseInt(x);
|
371
|
+
if (isNaN(this.x))
|
372
|
+
throw new Error("MQPoint.setX called with invalid parameter");
|
373
|
+
};
|
374
|
+
/**
|
375
|
+
* Gets X.
|
376
|
+
* @return The X value
|
377
|
+
* @type int
|
378
|
+
*/
|
379
|
+
MQPoint.prototype.getX = function(){
|
380
|
+
return this.x;
|
381
|
+
};
|
382
|
+
/**
|
383
|
+
* Sets Y.
|
384
|
+
* @param {int} y the value to set Y to
|
385
|
+
* @type void
|
386
|
+
*/
|
387
|
+
MQPoint.prototype.setY = function(y){
|
388
|
+
this.y = parseInt(y);
|
389
|
+
if (isNaN(this.y))
|
390
|
+
throw new Error("MQPoint.setY called with invalid parameter");
|
391
|
+
};
|
392
|
+
/**
|
393
|
+
* Gets Y.
|
394
|
+
* @return The Y value
|
395
|
+
* @type int
|
396
|
+
*/
|
397
|
+
MQPoint.prototype.getY = function(){
|
398
|
+
return this.y;
|
399
|
+
};
|
400
|
+
/**
|
401
|
+
* Sets the horizontal and vertical coordinates to the values passed in.
|
402
|
+
* @param {int} x the value to set X to
|
403
|
+
* @param {int} y the value to set Y to
|
404
|
+
* @type void
|
405
|
+
*/
|
406
|
+
MQPoint.prototype.setXY = function(x, y){
|
407
|
+
this.x = parseInt(x);
|
408
|
+
this.y = parseInt(y);
|
409
|
+
if (isNaN(this.x) || isNaN(this.y))
|
410
|
+
throw new Error("MQPoint.setXY called with invalid parameter");
|
411
|
+
};
|
412
|
+
/**
|
413
|
+
* Returns a true if both the X and Y values are set
|
414
|
+
* to a value other than the static "INVALID" value.
|
415
|
+
* @return True if both the X and Y values are not
|
416
|
+
* equal to the static "INVALID".
|
417
|
+
* @type Boolean
|
418
|
+
*/
|
419
|
+
MQPoint.prototype.valid = function(){
|
420
|
+
if("undefined" !== typeof(mqutils)){
|
421
|
+
return ( Math.abs(this.x != MQCONSTANT.MQPOINT_INVALID) &&
|
422
|
+
Math.abs(this.y != MQCONSTANT.MQPOINT_INVALID));
|
423
|
+
}
|
424
|
+
return false;
|
425
|
+
};
|
426
|
+
/**
|
427
|
+
* Determines whether or not two points are equal. Two instances
|
428
|
+
* of Point are equal if the values of their x and y member
|
429
|
+
* fields, representing their position in the coordinate space,
|
430
|
+
* are the same.
|
431
|
+
* @param {MQPoint} pt an MQPoint object to be compared with this MQPoint
|
432
|
+
* @return True if both the X and Y values are equal.
|
433
|
+
* @type Boolean
|
434
|
+
*/
|
435
|
+
MQPoint.prototype.equals = function(pt){
|
436
|
+
if (pt){
|
437
|
+
return (this.x === pt.x && this.y === pt.y);
|
438
|
+
}
|
439
|
+
return false;
|
440
|
+
};
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Returns a string representation of this <code>MQPoint</code>.
|
444
|
+
* The format is <code>"x,y"</code>.
|
445
|
+
*
|
446
|
+
* @returns {string} a string representation of this <code>MQPoint</code>.
|
447
|
+
*/
|
448
|
+
MQPoint.prototype.toString = function() {
|
449
|
+
return this.x + "," + this.y;
|
450
|
+
};
|
451
|
+
// End class MQPoint
|
452
|
+
|
453
|
+
|
454
|
+
//#############################################################################
|
455
|
+
// Begin Class MQLatLng
|
456
|
+
// Inheirit from MQObject
|
457
|
+
MQLatLng.prototype = new MQObject();
|
458
|
+
MQLatLng.prototype.constructor = MQLatLng;
|
459
|
+
//#############################################################################
|
460
|
+
/**
|
461
|
+
* Constructs a new MQLatLng object.
|
462
|
+
*
|
463
|
+
* @class Contains a latitude/longitude pair.
|
464
|
+
* @param {float/string} param1 OPTIONAL: Depending on the absence of param2.
|
465
|
+
* If param2 exists then param1 is initial latitude (float - default is 0.0)
|
466
|
+
* otherwise param1 is xpath (string - default is "LatLng").
|
467
|
+
* @param {float} param2 OPTIONAL: initial longitude (default is 0.0).
|
468
|
+
* @extends MQObject
|
469
|
+
*/
|
470
|
+
function MQLatLng (param1, param2) {
|
471
|
+
MQObject.call(this);
|
472
|
+
/**
|
473
|
+
* Value to represent the latitude
|
474
|
+
* @type float
|
475
|
+
*/
|
476
|
+
this.lat = 0.0;
|
477
|
+
/**
|
478
|
+
* Value to represent the longitude
|
479
|
+
* @type float
|
480
|
+
*/
|
481
|
+
this.lng = 0.0;
|
482
|
+
|
483
|
+
// Set default path
|
484
|
+
this.setM_Xpath("LatLng");
|
485
|
+
|
486
|
+
if (arguments.length == 1){
|
487
|
+
this.setM_Xpath(param1);
|
488
|
+
}
|
489
|
+
else if (arguments.length == 2){
|
490
|
+
this.lat = parseFloat(param1);
|
491
|
+
this.lng = parseFloat(param2);
|
492
|
+
if (isNaN(this.lat) || isNaN(this.lng))
|
493
|
+
throw new Error("MQLatLng constructor called with invalid parameter");
|
494
|
+
}
|
495
|
+
else if (arguments.length > 2){
|
496
|
+
throw new Error("MQLatLng constructor called with "
|
497
|
+
+ arguments.length
|
498
|
+
+ " arguments, but it expects 0, 1, or 2 arguments.");
|
499
|
+
}
|
500
|
+
|
501
|
+
}
|
502
|
+
/**
|
503
|
+
* Returns the text name of this class.
|
504
|
+
* @return The text name of this class.
|
505
|
+
* @type String
|
506
|
+
*/
|
507
|
+
MQLatLng.prototype.getClassName = function(){
|
508
|
+
return "MQLatLng";
|
509
|
+
};
|
510
|
+
/**
|
511
|
+
* Returns the version of this class.
|
512
|
+
* @return The version of this class.
|
513
|
+
* @type int
|
514
|
+
*/
|
515
|
+
MQLatLng.prototype.getObjectVersion = function(){
|
516
|
+
return 0;
|
517
|
+
};
|
518
|
+
/**
|
519
|
+
* Assigns the xml that relates to this object.
|
520
|
+
* @param {String} strXml the xml to be assigned.
|
521
|
+
* @type void
|
522
|
+
*
|
523
|
+
*/
|
524
|
+
MQLatLng.prototype.loadXml = function (strXml) {
|
525
|
+
if("undefined" !== typeof(mqutils)){
|
526
|
+
this.setM_XmlDoc(mqCreateXMLDoc(strXml));
|
527
|
+
this.lat = this.getProperty("Lat");
|
528
|
+
this.lng = this.getProperty("Lng");
|
529
|
+
}
|
530
|
+
};
|
531
|
+
/**
|
532
|
+
* Build an xml string that represents this object.
|
533
|
+
* @return The xml string.
|
534
|
+
* @type String
|
535
|
+
*
|
536
|
+
*/
|
537
|
+
MQLatLng.prototype.saveXml = function () {
|
538
|
+
return "<" + this.getM_Xpath() + "><Lat>" + this.lat + "</Lat><Lng>" + this.lng + "</Lng></" + this.getM_Xpath() + ">";
|
539
|
+
};
|
540
|
+
/**
|
541
|
+
* Sets the latitude value.
|
542
|
+
* @param {float} fLatitude the value to set lat to
|
543
|
+
* @type void
|
544
|
+
*/
|
545
|
+
MQLatLng.prototype.setLatitude = function(fLatitude){
|
546
|
+
this.lat = parseFloat(fLatitude);
|
547
|
+
if (isNaN(this.lat))
|
548
|
+
throw new Error("MQLatLng.setLatitude called with invalid parameter");
|
549
|
+
};
|
550
|
+
/**
|
551
|
+
* Returns the latitude value.
|
552
|
+
* @return the latitude value.
|
553
|
+
* @type float
|
554
|
+
*/
|
555
|
+
MQLatLng.prototype.getLatitude = function(){
|
556
|
+
return this.lat;
|
557
|
+
};
|
558
|
+
/**
|
559
|
+
* Sets the longitude value.
|
560
|
+
* @param {float} fLongitude the value to set lng to
|
561
|
+
* @type void
|
562
|
+
*/
|
563
|
+
MQLatLng.prototype.setLongitude = function(fLongitude){
|
564
|
+
this.lng = parseFloat(fLongitude);
|
565
|
+
if (isNaN(this.lng))
|
566
|
+
throw new Error("MQLatLng.setLongitude called with invalid parameter");
|
567
|
+
};
|
568
|
+
/**
|
569
|
+
* Returns the longitude value.
|
570
|
+
* @return the longitude value.
|
571
|
+
* @type float
|
572
|
+
*/
|
573
|
+
MQLatLng.prototype.getLongitude = function(){
|
574
|
+
return this.lng;
|
575
|
+
};
|
576
|
+
/**
|
577
|
+
* Sets the latitude and longitude values.
|
578
|
+
* @param {float} fLatitude the value to set lat to
|
579
|
+
* @param {float} fLongitude the value to set lng to
|
580
|
+
* @type void
|
581
|
+
*/
|
582
|
+
MQLatLng.prototype.setLatLng = function(fLatitude, fLongitude){
|
583
|
+
this.lat = parseFloat(fLatitude);
|
584
|
+
this.lng = parseFloat(fLongitude);
|
585
|
+
if (isNaN(this.lat) || isNaN(this.lng))
|
586
|
+
throw new Error("MQLatLng.setLatLng called with invalid parameter");
|
587
|
+
};
|
588
|
+
/**
|
589
|
+
* Calculates the distance between two lat/lng's in miles or meters. If LUnits not
|
590
|
+
* provide then miles will be the default.
|
591
|
+
* @param {MQLatLng} ll2 Second lat,lng position to calculate distance to.
|
592
|
+
* @param {MQDistanceUnits} lUnits Units to calculate distance
|
593
|
+
* @return Returns the distance in meters or miles.
|
594
|
+
* @throws SomeException If the ll2 parameter is not the type MQLatLng
|
595
|
+
* @throws SomeException If the lUnits parameter exists and is not the type MQDistanceUnits
|
596
|
+
* @type double
|
597
|
+
*/
|
598
|
+
MQLatLng.prototype.arcDistance = function( ll2, lUnits){
|
599
|
+
if("undefined" !== typeof(mqutils)){
|
600
|
+
// type checks
|
601
|
+
if (ll2){
|
602
|
+
if(ll2.getClassName()!=="MQLatLng"){
|
603
|
+
alert("failure in arcDistance");
|
604
|
+
throw "failure in arcDistance";
|
605
|
+
}
|
606
|
+
} else {
|
607
|
+
alert("failure in arcDistance");
|
608
|
+
throw "failure in arcDistance";
|
609
|
+
}
|
610
|
+
if(lUnits){
|
611
|
+
mqIsClass("MQDistanceUnits", lUnits, false);
|
612
|
+
} else {
|
613
|
+
lUnits = new MQDistanceUnits(MQCONSTANT.MQDISTANCEUNITS_MILES);
|
614
|
+
}
|
615
|
+
|
616
|
+
// Check for same position
|
617
|
+
if (this.getLatitude() == ll2.getLatitude() && this.getLongitude() == ll2.getLongitude()){
|
618
|
+
return 0.0;
|
619
|
+
}
|
620
|
+
// Get the Lng difference. Don't need to worry about
|
621
|
+
// crossing 180 since cos(x) = cos(-x)
|
622
|
+
var dLon = ll2.getLongitude() - this.getLongitude();
|
623
|
+
var a = MQCONSTANT.MQLATLNG_RADIANS * (90.0 - this.getLatitude());
|
624
|
+
var c = MQCONSTANT.MQLATLNG_RADIANS * (90.0 - ll2.getLatitude());
|
625
|
+
var cosB = (Math.cos(a) * Math.cos(c)) + (Math.sin(a) * Math.sin(c) *
|
626
|
+
Math.cos(MQCONSTANT.MQLATLNG_RADIANS * (dLon)));
|
627
|
+
var radius = (lUnits.getValue() === MQCONSTANT.MQDISTANCEUNITS_MILES) ? 3963.205 : 6378.160187;
|
628
|
+
|
629
|
+
// Find angle subtended (with some bounds checking) in radians and
|
630
|
+
// multiply by earth radius to find the arc distance
|
631
|
+
if (cosB < -1.0)
|
632
|
+
return MQCONSTANT.PI * radius;
|
633
|
+
else if (cosB >= 1.0)
|
634
|
+
return 0;
|
635
|
+
else
|
636
|
+
return Math.acos(cosB) * radius;
|
637
|
+
}
|
638
|
+
return -1;
|
639
|
+
};
|
640
|
+
/**
|
641
|
+
* Returns a true if both the latitude and longitude values are set
|
642
|
+
* to a value other than the static "INVALID" value.
|
643
|
+
* @return True if both the latitude and longitude values are not
|
644
|
+
* equal to the static "INVALID".
|
645
|
+
* @type Boolean
|
646
|
+
*/
|
647
|
+
MQLatLng.prototype.valid = function(){
|
648
|
+
if("undefined" !== typeof(mqutils)){
|
649
|
+
return ( Math.abs(this.getLatitude() - MQCONSTANT.MQLATLNG_INVALID) > MQCONSTANT.MQLATLNG_TOLERANCE &&
|
650
|
+
Math.abs(this.getLongitude() - MQCONSTANT.MQLATLNG_INVALID) > MQCONSTANT.MQLATLNG_TOLERANCE );
|
651
|
+
}
|
652
|
+
return false;
|
653
|
+
};
|
654
|
+
/**
|
655
|
+
* Determines whether or not two latlngs are equal. Two instances
|
656
|
+
* of MQLatLng are equal if the values of their latitude and longitude member
|
657
|
+
* fields, representing their position in the coordinate space,
|
658
|
+
* are the same.
|
659
|
+
* @param {MQLatLng} ll an MQLatLng object to be compared with this MQLatLng
|
660
|
+
* @return True if both the latitude and longitude values are equal.
|
661
|
+
* @type Boolean
|
662
|
+
*/
|
663
|
+
MQLatLng.prototype.equals = function(ll){
|
664
|
+
if (ll!==null){
|
665
|
+
return (this.getLongitude() === ll.getLongitude() && this.getLatitude() === ll.getLatitude());
|
666
|
+
}
|
667
|
+
return false;
|
668
|
+
};
|
669
|
+
|
670
|
+
/**
|
671
|
+
* Returns a string representation of this <code>MQLatLng</code>.
|
672
|
+
* The format is <code>"latitude,longitude"</code>.
|
673
|
+
*
|
674
|
+
* @returns {string} a string representation of this <code>MQLatLng</code>.
|
675
|
+
*/
|
676
|
+
MQLatLng.prototype.toString = function() {
|
677
|
+
return this.lat + "," + this.lng;
|
678
|
+
};
|
679
|
+
// End class MQLatLng
|
680
|
+
|
681
|
+
|
682
|
+
//crossbrowser wrapper to create an xml document object
|
683
|
+
//from a given string
|
684
|
+
/**
|
685
|
+
* Crossbrowser wrapper to create an xml document object
|
686
|
+
* from a given string
|
687
|
+
* @param String strXML String to be converted into a Xml Document
|
688
|
+
* @return Returns the converted String as a Document.
|
689
|
+
* @type Document
|
690
|
+
* @private
|
691
|
+
*/
|
692
|
+
function mqCreateXMLDoc(strXML) {
|
693
|
+
var newDoc;
|
694
|
+
|
695
|
+
if (document.implementation.createDocument){
|
696
|
+
// Mozilla, create a new DOMParser
|
697
|
+
var parser = new window.DOMParser();
|
698
|
+
//escaping & for safari -start
|
699
|
+
if(mqBrowserInfo.isSafari)
|
700
|
+
strXML = strXML.replace( /&/g,'&');
|
701
|
+
//escaping & for safari -stop
|
702
|
+
newDoc = parser.parseFromString(strXML, "text/xml");
|
703
|
+
} else if (window.ActiveXObject){
|
704
|
+
// Internet Explorer, create a new XML document using ActiveX
|
705
|
+
// and use loadXML as a DOM parser.
|
706
|
+
newDoc = new window.ActiveXObject("Microsoft.XMLDOM");
|
707
|
+
newDoc.async="false";
|
708
|
+
newDoc.loadXML(strXML);
|
709
|
+
}
|
710
|
+
|
711
|
+
return newDoc;
|
712
|
+
}
|
713
|
+
|
714
|
+
|
715
|
+
//crossbrowser wrapper to create an xml document object
|
716
|
+
//from a node
|
717
|
+
function mqCreateXMLDocFromNode(ndNewRoot) {
|
718
|
+
var newDoc;
|
719
|
+
ndNewRoot = ndNewRoot.documentElement;
|
720
|
+
if (document.implementation.createDocument){
|
721
|
+
var newDoc = document.implementation.createDocument("", "", null);
|
722
|
+
try{newDoc.appendChild(newDoc.importNode(ndNewRoot,true))}catch(error){alert(error);alert(ndNewRoot.nodeName);};
|
723
|
+
} else if (window.ActiveXObject){
|
724
|
+
// Internet Explorer, create a new XML document using ActiveX
|
725
|
+
// and use loadXML as a DOM parser.
|
726
|
+
newDoc = new ActiveXObject("Microsoft.XMLDOM");
|
727
|
+
newDoc.async="false";
|
728
|
+
newDoc.loadXML(ndNewRoot.xml);
|
729
|
+
}
|
730
|
+
|
731
|
+
return newDoc;
|
732
|
+
}
|
733
|
+
|
734
|
+
|
735
|
+
// Begin class MQXMLDOC
|
736
|
+
function MQXMLDOC(){
|
737
|
+
this.AUTOGEOCODECOVSWITCH = null;
|
738
|
+
this.AUTOROUTECOVSWITCH = null;
|
739
|
+
this.AUTOMAPCOVSWITCH = null;
|
740
|
+
this.DBLAYERQUERY = null;
|
741
|
+
this.LINEPRIMITIVE = null;
|
742
|
+
this.POLYGONPRIMITIVE = null;
|
743
|
+
this.RECTANGLEPRIMITIVE = null;
|
744
|
+
this.ELLIPSEPRIMITIVE = null;
|
745
|
+
this.TEXTPRIMITIVE = null;
|
746
|
+
this.SYMBOLPRIMITIVE = null;
|
747
|
+
this.LATLNG = null;
|
748
|
+
this.POINT = null;
|
749
|
+
this.POINTFEATURE = null;
|
750
|
+
this.LINEFEATURE = null;
|
751
|
+
this.POLYGONFEATURE = null;
|
752
|
+
this.LOCATION = null;
|
753
|
+
this.ADDRESS = null;
|
754
|
+
this.SINGLELINEADDRESS = null;
|
755
|
+
this.GEOADDRESS = null;
|
756
|
+
this.GEOCODEOPTIONS = null;
|
757
|
+
this.MANEUVER = null;
|
758
|
+
this.ROUTEOPTIONS = null;
|
759
|
+
this.ROUTERESULTS = null;
|
760
|
+
this.ROUTEMATRIXRESULTS = null;
|
761
|
+
this.RADIUSSEARCHCRITERIA = null;
|
762
|
+
this.RECTSEARCHCRITERIA = null;
|
763
|
+
this.POLYSEARCHCRITERIA = null;
|
764
|
+
this.CORRIDORSEARCHCRITERIA = null;
|
765
|
+
this.SIGN = null;
|
766
|
+
this.TREKROUTE = null;
|
767
|
+
this.INTCOLLECTION = null;
|
768
|
+
this.DTCOLLECTION = null;
|
769
|
+
this.LATLNGCOLLECTION = null;
|
770
|
+
this.LOCATIONCOLLECTION = null;
|
771
|
+
this.LOCATIONCOLLECTIONCOLLECTION = null;
|
772
|
+
this.MANEUVERCOLLECTION = null;
|
773
|
+
this.SIGNCOLLECTION = null;
|
774
|
+
this.STRINGCOLLECTION = null;
|
775
|
+
this.STRCOLCOLLECTION = null;
|
776
|
+
this.FEATURECOLLECTION = null;
|
777
|
+
this.PRIMITIVECOLLECTION = null;
|
778
|
+
this.POINTCOLLECTION = null;
|
779
|
+
this.TREKROUTECOLLECTION = null;
|
780
|
+
this.FEATURESPECIFIERCOLLECTION = null;
|
781
|
+
this.GEOCODEOPTIONSCOLLECTION = null;
|
782
|
+
this.COVERAGESTYLE = null;
|
783
|
+
this.RECORDSET = null;
|
784
|
+
this.MAPSTATE = null;
|
785
|
+
this.SESSION = null;
|
786
|
+
this.SESSIONID = null;
|
787
|
+
this.DTSTYLE = null;
|
788
|
+
this.DTSTYLEEX = null;
|
789
|
+
this.DTFEATURESTYLEEX = null;
|
790
|
+
this.FEATURESPECIFIER = null;
|
791
|
+
this.BESTFIT = null;
|
792
|
+
this.BESTFITLL = null;
|
793
|
+
this.CENTER = null;
|
794
|
+
this.CENTERLATLNG = null;
|
795
|
+
this.PAN = null;
|
796
|
+
this.ZOOMIN = null;
|
797
|
+
this.ZOOMOUT = null;
|
798
|
+
this.ZOOMTO = null;
|
799
|
+
this.ZOOMTORECT = null;
|
800
|
+
this.ZOOMTORECTLATLNG = null;
|
801
|
+
this.getAUTOGEOCODECOVSWITCH = function() {
|
802
|
+
if (this.AUTOGEOCODECOVSWITCH===null)
|
803
|
+
this.AUTOGEOCODECOVSWITCH = mqCreateXMLDoc("<AutoGeocodeCovSwitch/>");
|
804
|
+
return this.AUTOGEOCODECOVSWITCH;
|
805
|
+
}
|
806
|
+
this.getAUTOROUTECOVSWITCH = function() {
|
807
|
+
if (this.AUTOROUTECOVSWITCH===null)
|
808
|
+
this.AUTOROUTECOVSWITCH = mqCreateXMLDoc("<AutoRouteCovSwitch><Name/><DataVendorCodeUsage>0</DataVendorCodeUsage><DataVendorCodes Count=\"0\"/></AutoRouteCovSwitch>");
|
809
|
+
return this.AUTOROUTECOVSWITCH;
|
810
|
+
}
|
811
|
+
this.getAUTOMAPCOVSWITCH = function() {
|
812
|
+
if (this.AUTOMAPCOVSWITCH===null)
|
813
|
+
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>");
|
814
|
+
return this.AUTOMAPCOVSWITCH;
|
815
|
+
}
|
816
|
+
this.getDBLAYERQUERY = function() {
|
817
|
+
if (this.DBLAYERQUERY===null)
|
818
|
+
this.DBLAYERQUERY = mqCreateXMLDoc("<DBLayerQuery/>");
|
819
|
+
return this.DBLAYERQUERY;
|
820
|
+
}
|
821
|
+
this.getLINEPRIMITIVE = function() {
|
822
|
+
if (this.LINEPRIMITIVE===null)
|
823
|
+
this.LINEPRIMITIVE = mqCreateXMLDoc("<LinePrimitive Version=\"2\"/>");
|
824
|
+
return this.LINEPRIMITIVE;
|
825
|
+
}
|
826
|
+
this.getPOLYGONPRIMITIVE = function() {
|
827
|
+
if (this.POLYGONPRIMITIVE===null)
|
828
|
+
this.POLYGONPRIMITIVE = mqCreateXMLDoc("<PolygonPrimitive Version=\"2\"/>");
|
829
|
+
return this.POLYGONPRIMITIVE;
|
830
|
+
}
|
831
|
+
this.getRECTANGLEPRIMITIVE = function() {
|
832
|
+
if (this.RECTANGLEPRIMITIVE===null)
|
833
|
+
this.RECTANGLEPRIMITIVE = mqCreateXMLDoc("<RectanglePrimitive Version=\"2\"/>");
|
834
|
+
return this.RECTANGLEPRIMITIVE;
|
835
|
+
}
|
836
|
+
this.getELLIPSEPRIMITIVE = function() {
|
837
|
+
if (this.ELLIPSEPRIMITIVE===null)
|
838
|
+
this.ELLIPSEPRIMITIVE = mqCreateXMLDoc("<EllipsePrimitive Version=\"2\"/>");
|
839
|
+
return this.ELLIPSEPRIMITIVE;
|
840
|
+
}
|
841
|
+
this.getTEXTPRIMITIVE = function() {
|
842
|
+
if (this.TEXTPRIMITIVE===null)
|
843
|
+
this.TEXTPRIMITIVE = mqCreateXMLDoc("<TextPrimitive Version=\"2\"/>");
|
844
|
+
return this.TEXTPRIMITIVE;
|
845
|
+
}
|
846
|
+
this.getSYMBOLPRIMITIVE = function() {
|
847
|
+
if (this.SYMBOLPRIMITIVE===null)
|
848
|
+
this.SYMBOLPRIMITIVE = mqCreateXMLDoc("<SymbolPrimitive Version=\"2\"/>");
|
849
|
+
return this.SYMBOLPRIMITIVE;
|
850
|
+
}
|
851
|
+
this.getLATLNG = function() {
|
852
|
+
if (this.LATLNG===null)
|
853
|
+
this.LATLNG = mqCreateXMLDoc("<LatLng/>");
|
854
|
+
return this.LATLNG;
|
855
|
+
}
|
856
|
+
this.getPOINT = function() {
|
857
|
+
if (this.POINT===null)
|
858
|
+
this.POINT = mqCreateXMLDoc("<Point/>");
|
859
|
+
return this.POINT;
|
860
|
+
}
|
861
|
+
this.getPOINTFEATURE = function() {
|
862
|
+
if (this.POINTFEATURE===null)
|
863
|
+
this.POINTFEATURE = mqCreateXMLDoc("<PointFeature/>");
|
864
|
+
return this.POINTFEATURE;
|
865
|
+
}
|
866
|
+
this.getLINEFEATURE = function() {
|
867
|
+
if (this.LINEFEATURE===null)
|
868
|
+
this.LINEFEATURE = mqCreateXMLDoc("<LineFeature/>");
|
869
|
+
return this.LINEFEATURE;
|
870
|
+
}
|
871
|
+
this.getPOLYGONFEATURE = function() {
|
872
|
+
if (this.POLYGONFEATURE===null)
|
873
|
+
this.POLYGONFEATURE = mqCreateXMLDoc("<PolygonFeature/>");
|
874
|
+
return this.POLYGONFEATURE;
|
875
|
+
}
|
876
|
+
this.getLOCATION = function() {
|
877
|
+
if (this.LOCATION===null)
|
878
|
+
this.LOCATION = mqCreateXMLDoc("<Location/>");
|
879
|
+
return this.LOCATION;
|
880
|
+
}
|
881
|
+
this.getADDRESS = function() {
|
882
|
+
if (this.ADDRESS===null)
|
883
|
+
this.ADDRESS = mqCreateXMLDoc("<Address/>");
|
884
|
+
return this.ADDRESS;
|
885
|
+
}
|
886
|
+
this.getSINGLELINEADDRESS = function() {
|
887
|
+
if (this.SINGLELINEADDRESS===null)
|
888
|
+
this.SINGLELINEADDRESS = mqCreateXMLDoc("<SingleLineAddress/>");
|
889
|
+
return this.SINGLELINEADDRESS;
|
890
|
+
}
|
891
|
+
this.getGEOADDRESS = function() {
|
892
|
+
if (this.GEOADDRESS===null)
|
893
|
+
this.GEOADDRESS = mqCreateXMLDoc("<GeoAddress/>");
|
894
|
+
return this.GEOADDRESS;
|
895
|
+
}
|
896
|
+
this.getGEOCODEOPTIONS = function() {
|
897
|
+
if (this.GEOCODEOPTIONS===null)
|
898
|
+
this.GEOCODEOPTIONS = mqCreateXMLDoc("<GeocodeOptions/>");
|
899
|
+
return this.GEOCODEOPTIONS;
|
900
|
+
}
|
901
|
+
this.getMANEUVER = function() {
|
902
|
+
if (this.MANEUVER===null)
|
903
|
+
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>");
|
904
|
+
return this.MANEUVER;
|
905
|
+
}
|
906
|
+
this.getROUTEOPTIONS = function() {
|
907
|
+
if (this.ROUTEOPTIONS===null)
|
908
|
+
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>");
|
909
|
+
return this.ROUTEOPTIONS;
|
910
|
+
}
|
911
|
+
this.getROUTERESULTS = function() {
|
912
|
+
if (this.ROUTERESULTS===null)
|
913
|
+
this.ROUTERESULTS = mqCreateXMLDoc("<RouteResults Version=\"1\"><Locations Count=\"0\"/><CoverageName/><ResultMessages Count=\"0\"/><TrekRoutes Count=\"0\"/></RouteResults>");
|
914
|
+
return this.ROUTERESULTS;
|
915
|
+
}
|
916
|
+
this.getROUTEMATRIXRESULTS = function() {
|
917
|
+
if (this.ROUTEMATRIXRESULTS===null)
|
918
|
+
this.ROUTEMATRIXRESULTS = mqCreateXMLDoc("<RouteMatrixResults/>");
|
919
|
+
return this.ROUTEMATRIXRESULTS;
|
920
|
+
}
|
921
|
+
this.getRADIUSSEARCHCRITERIA = function() {
|
922
|
+
if (this.RADIUSSEARCHCRITERIA===null)
|
923
|
+
this.RADIUSSEARCHCRITERIA = mqCreateXMLDoc("<RadiusSearchCriteria/>");
|
924
|
+
return this.RADIUSSEARCHCRITERIA;
|
925
|
+
}
|
926
|
+
this.getRECTSEARCHCRITERIA = function() {
|
927
|
+
if (this.RECTSEARCHCRITERIA===null)
|
928
|
+
this.RECTSEARCHCRITERIA = mqCreateXMLDoc("<RectSearchCriteria/>");
|
929
|
+
return this.RECTSEARCHCRITERIA;
|
930
|
+
}
|
931
|
+
this.getPOLYSEARCHCRITERIA = function() {
|
932
|
+
if (this.POLYSEARCHCRITERIA===null)
|
933
|
+
this.POLYSEARCHCRITERIA = mqCreateXMLDoc("<PolySearchCriteria/>");
|
934
|
+
return this.POLYSEARCHCRITERIA;
|
935
|
+
}
|
936
|
+
this.getCORRIDORSEARCHCRITERIA = function() {
|
937
|
+
if (this.CORRIDORSEARCHCRITERIA===null)
|
938
|
+
this.CORRIDORSEARCHCRITERIA = mqCreateXMLDoc("<CorridorSearchCriteria/>");
|
939
|
+
return this.CORRIDORSEARCHCRITERIA;
|
940
|
+
}
|
941
|
+
this.getSIGN = function() {
|
942
|
+
if (this.SIGN===null)
|
943
|
+
this.SIGN = mqCreateXMLDoc("<Sign><Type>0</Type><Text></Text><ExtraText></ExtraText><Direction>0</Direction></Sign>");
|
944
|
+
return this.SIGN;
|
945
|
+
}
|
946
|
+
this.getTREKROUTE = function() {
|
947
|
+
if (this.TREKROUTE===null)
|
948
|
+
this.TREKROUTE = mqCreateXMLDoc("<TrekRoute><Maneuvers Count=\"0\"/></TrekRoute>");
|
949
|
+
return this.TREKROUTE;
|
950
|
+
}
|
951
|
+
this.getINTCOLLECTION = function() {
|
952
|
+
if (this.INTCOLLECTION===null)
|
953
|
+
this.INTCOLLECTION = mqCreateXMLDoc("<IntCollection Count=\"0\"/>");
|
954
|
+
return this.INTCOLLECTION;
|
955
|
+
}
|
956
|
+
this.getDTCOLLECTION = function() {
|
957
|
+
if (this.DTCOLLECTION===null)
|
958
|
+
this.DTCOLLECTION = mqCreateXMLDoc("<DTCollection Version=\"1\" Count=\"0\"/>");
|
959
|
+
return this.DTCOLLECTION;
|
960
|
+
}
|
961
|
+
this.getLATLNGCOLLECTION = function() {
|
962
|
+
if (this.LATLNGCOLLECTION===null)
|
963
|
+
this.LATLNGCOLLECTION = mqCreateXMLDoc("<LatLngCollection Version=\"1\" Count=\"0\"/>");
|
964
|
+
return this.LATLNGCOLLECTION;
|
965
|
+
}
|
966
|
+
this.getLOCATIONCOLLECTION = function() {
|
967
|
+
if (this.LOCATIONCOLLECTION===null)
|
968
|
+
this.LOCATIONCOLLECTION = mqCreateXMLDoc("<LocationCollection Count=\"0\"/>");
|
969
|
+
return this.LOCATIONCOLLECTION;
|
970
|
+
}
|
971
|
+
this.getLOCATIONCOLLECTIONCOLLECTION = function() {
|
972
|
+
if (this.LOCATIONCOLLECTIONCOLLECTION===null)
|
973
|
+
this.LOCATIONCOLLECTIONCOLLECTION = mqCreateXMLDoc("<LocationCollectionCollection Count=\"0\"/>");
|
974
|
+
return this.LOCATIONCOLLECTIONCOLLECTION;
|
975
|
+
}
|
976
|
+
this.getMANEUVERCOLLECTION = function() {
|
977
|
+
if (this.MANEUVERCOLLECTION===null)
|
978
|
+
this.MANEUVERCOLLECTION = mqCreateXMLDoc("<ManeuverCollection Count=\"0\"/>");
|
979
|
+
return this.MANEUVERCOLLECTION;
|
980
|
+
}
|
981
|
+
this.getSIGNCOLLECTION = function() {
|
982
|
+
if (this.SIGNCOLLECTION===null)
|
983
|
+
this.SIGNCOLLECTION = mqCreateXMLDoc("<SignCollection Count=\"0\"/>");
|
984
|
+
return this.SIGNCOLLECTION;
|
985
|
+
}
|
986
|
+
this.getSTRINGCOLLECTION = function() {
|
987
|
+
if (this.STRINGCOLLECTION===null)
|
988
|
+
this.STRINGCOLLECTION = mqCreateXMLDoc("<StringCollection Count=\"0\"/>");
|
989
|
+
return this.STRINGCOLLECTION;
|
990
|
+
}
|
991
|
+
this.getSTRCOLCOLLECTION = function() {
|
992
|
+
if (this.STRCOLCOLLECTION===null)
|
993
|
+
this.STRCOLCOLLECTION = mqCreateXMLDoc("<StrColCollectin/>");
|
994
|
+
return this.STRCOLCOLLECTION;
|
995
|
+
}
|
996
|
+
this.getFEATURECOLLECTION = function() {
|
997
|
+
if (this.FEATURECOLLECTION===null)
|
998
|
+
this.FEATURECOLLECTION = mqCreateXMLDoc("<FeatureCollection Count=\"0\"/>");
|
999
|
+
return this.FEATURECOLLECTION;
|
1000
|
+
}
|
1001
|
+
this.getPRIMITIVECOLLECTION = function() {
|
1002
|
+
if (this.PRIMITIVECOLLECTION===null)
|
1003
|
+
this.PRIMITIVECOLLECTION = mqCreateXMLDoc("<PrimitiveCollection Count=\"0\"/>");
|
1004
|
+
return this.PRIMITIVECOLLECTION;
|
1005
|
+
}
|
1006
|
+
this.getPOINTCOLLECTION = function() {
|
1007
|
+
if (this.POINTCOLLECTION===null)
|
1008
|
+
this.POINTCOLLECTION = mqCreateXMLDoc("<PointCollection Count=\"0\"/>");
|
1009
|
+
return this.POINTCOLLECTION;
|
1010
|
+
}
|
1011
|
+
this.getTREKROUTECOLLECTION = function() {
|
1012
|
+
if (this.TREKROUTECOLLECTION===null)
|
1013
|
+
this.TREKROUTECOLLECTION = mqCreateXMLDoc("<TrekRouteCollection Count=\"0\"/>");
|
1014
|
+
return this.TREKROUTECOLLECTION;
|
1015
|
+
}
|
1016
|
+
this.getFEATURESPECIFIERCOLLECTION = function() {
|
1017
|
+
if (this.FEATURESPECIFIERCOLLECTION===null)
|
1018
|
+
this.FEATURESPECIFIERCOLLECTION = mqCreateXMLDoc("<FeatureSpecifierCollection Count=\"0\"/>");
|
1019
|
+
return this.FEATURESPECIFIERCOLLECTION;
|
1020
|
+
}
|
1021
|
+
this.getGEOCODEOPTIONSCOLLECTION = function() {
|
1022
|
+
if (this.GEOCODEOPTIONSCOLLECTION===null)
|
1023
|
+
this.GEOCODEOPTIONSCOLLECTION = mqCreateXMLDoc("<GeocodeOptionsCollection Count=\"0\"/>");
|
1024
|
+
return this.GEOCODEOPTIONSCOLLECTION;
|
1025
|
+
}
|
1026
|
+
this.getCOVERAGESTYLE = function() {
|
1027
|
+
if (this.COVERAGESTYLE===null)
|
1028
|
+
this.COVERAGESTYLE = mqCreateXMLDoc("<CoverageStyle/>");
|
1029
|
+
return this.COVERAGESTYLE;
|
1030
|
+
}
|
1031
|
+
this.getRECORDSET = function() {
|
1032
|
+
if (this.RECORDSET===null)
|
1033
|
+
this.RECORDSET = mqCreateXMLDoc("<RecordSet/>");
|
1034
|
+
return this.RECORDSET;
|
1035
|
+
}
|
1036
|
+
this.getMAPSTATE = function() {
|
1037
|
+
if (this.MAPSTATE===null)
|
1038
|
+
this.MAPSTATE = mqCreateXMLDoc("<MapState/>");
|
1039
|
+
return this.MAPSTATE;
|
1040
|
+
}
|
1041
|
+
this.getSESSION = function() {
|
1042
|
+
if (this.SESSION===null)
|
1043
|
+
this.SESSION = mqCreateXMLDoc("<Session Count=\"0\"/>");
|
1044
|
+
return this.SESSION;
|
1045
|
+
}
|
1046
|
+
this.getSESSIONID = function() {
|
1047
|
+
if (this.SESSIONID===null)
|
1048
|
+
this.SESSIONID = mqCreateXMLDoc("<SessionID/>");
|
1049
|
+
return this.SESSIONID;
|
1050
|
+
}
|
1051
|
+
this.getDTSTYLE = function() {
|
1052
|
+
if (this.DTSTYLE===null)
|
1053
|
+
this.DTSTYLE = mqCreateXMLDoc("<DTStyle/>");
|
1054
|
+
return this.DTSTYLE;
|
1055
|
+
}
|
1056
|
+
this.getDTSTYLEEX = function() {
|
1057
|
+
if (this.DTSTYLEEX===null)
|
1058
|
+
this.DTSTYLEEX = mqCreateXMLDoc("<DTStyleEx/>");
|
1059
|
+
return this.DTSTYLEEX;
|
1060
|
+
}
|
1061
|
+
this.getDTFEATURESTYLEEX = function() {
|
1062
|
+
if (this.DTFEATURESTYLEEX===null)
|
1063
|
+
this.DTFEATURESTYLEEX = mqCreateXMLDoc("<DTFeatureStyleEx/>");
|
1064
|
+
return this.DTFEATURESTYLEEX;
|
1065
|
+
}
|
1066
|
+
this.getFEATURESPECIFIER = function() {
|
1067
|
+
if (this.FEATURESPECIFIER===null)
|
1068
|
+
this.FEATURESPECIFIER = mqCreateXMLDoc("<FeatureSpecifier/>");
|
1069
|
+
return this.FEATURESPECIFIER;
|
1070
|
+
}
|
1071
|
+
this.getBESTFIT = function() {
|
1072
|
+
if (this.BESTFIT===null)
|
1073
|
+
this.BESTFIT = mqCreateXMLDoc("<BestFit Version=\"2\"/>");
|
1074
|
+
return this.BESTFIT;
|
1075
|
+
}
|
1076
|
+
this.getBESTFITLL = function() {
|
1077
|
+
if (this.BESTFITLL===null)
|
1078
|
+
this.BESTFITLL = mqCreateXMLDoc("<BestFitLL Version=\"2\"/>");
|
1079
|
+
return this.BESTFITLL;
|
1080
|
+
}
|
1081
|
+
this.getCENTER = function() {
|
1082
|
+
if (this.CENTER===null)
|
1083
|
+
this.CENTER = mqCreateXMLDoc("<Center/>");
|
1084
|
+
return this.CENTER;
|
1085
|
+
}
|
1086
|
+
this.getCENTERLATLNG = function() {
|
1087
|
+
if (this.CENTERLATLNG===null)
|
1088
|
+
this.CENTERLATLNG = mqCreateXMLDoc("<CenterLatLng/>");
|
1089
|
+
return this.CENTERLATLNG;
|
1090
|
+
}
|
1091
|
+
this.getPAN = function() {
|
1092
|
+
if (this.PAN===null)
|
1093
|
+
this.PAN = mqCreateXMLDoc("<Pan/>");
|
1094
|
+
return this.PAN;
|
1095
|
+
}
|
1096
|
+
this.getZOOMIN = function() {
|
1097
|
+
if (this.ZOOMIN===null)
|
1098
|
+
this.ZOOMIN = mqCreateXMLDoc("<ZoomIn/>");
|
1099
|
+
return this.ZOOMIN;
|
1100
|
+
}
|
1101
|
+
this.getZOOMOUT = function() {
|
1102
|
+
if (this.ZOOMOUT===null)
|
1103
|
+
this.ZOOMOUT = mqCreateXMLDoc("<ZoomOut/>");
|
1104
|
+
return this.ZOOMOUT;
|
1105
|
+
}
|
1106
|
+
this.getZOOMTO = function() {
|
1107
|
+
if (this.ZOOMTO===null)
|
1108
|
+
this.ZOOMTO = mqCreateXMLDoc("<ZoomTo/>");
|
1109
|
+
return this.ZOOMTO;
|
1110
|
+
}
|
1111
|
+
this.getZOOMTORECT = function() {
|
1112
|
+
if (this.ZOOMTORECT===null)
|
1113
|
+
this.ZOOMTORECT = mqCreateXMLDoc("<ZoomToRect/>");
|
1114
|
+
return this.ZOOMTORECT;
|
1115
|
+
}
|
1116
|
+
this.getZOOMTORECTLATLNG = function() {
|
1117
|
+
if (this.ZOOMTORECTLATLNG===null)
|
1118
|
+
this.ZOOMTORECTLATLNG = mqCreateXMLDoc("<ZoomToRectLatLng/>");
|
1119
|
+
return this.ZOOMTORECTLATLNG;
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
var MQXML = new MQXMLDOC();
|
1123
|
+
// End class MQXMLDOC
|
1124
|
+
|
1125
|
+
|
1126
|
+
|
1127
|
+
// Begin class MQObjectCollection
|
1128
|
+
/* Inheirit from MQObject */
|
1129
|
+
MQObjectCollection.prototype = new MQObject();
|
1130
|
+
MQObjectCollection.prototype.constructor = MQObjectCollection;
|
1131
|
+
/**
|
1132
|
+
* Constructs a new MQObjectCollection object.
|
1133
|
+
* @class Base class for collections. Takes care of basic functionality
|
1134
|
+
* @param {int} max The initial size of the collection array
|
1135
|
+
* @param {String} strMQObjectType The type of MQObject descedent to check for
|
1136
|
+
* @extends MQObject
|
1137
|
+
*/
|
1138
|
+
function MQObjectCollection(max) {
|
1139
|
+
MQObject.call(this);
|
1140
|
+
/**
|
1141
|
+
* Value to represent collection
|
1142
|
+
* @type Array
|
1143
|
+
*
|
1144
|
+
*/
|
1145
|
+
var m_items = new Array();
|
1146
|
+
/**
|
1147
|
+
* Accessor method for m_items
|
1148
|
+
* @return The Array of m_items
|
1149
|
+
* @type Array
|
1150
|
+
*
|
1151
|
+
*/
|
1152
|
+
this.getM_Items = function(){
|
1153
|
+
return m_items;
|
1154
|
+
};
|
1155
|
+
/**
|
1156
|
+
* Value to represent maximum number of items
|
1157
|
+
* @type int
|
1158
|
+
*
|
1159
|
+
*/
|
1160
|
+
var m_maxItems = ( max !== null ) ? max : -1;
|
1161
|
+
/**
|
1162
|
+
* Value to represent className to check for
|
1163
|
+
* @type String
|
1164
|
+
*
|
1165
|
+
*/
|
1166
|
+
var validClassName = "MQObject";
|
1167
|
+
/**
|
1168
|
+
* Accessor method for ValidClassName
|
1169
|
+
* @return Value of ValidClassName
|
1170
|
+
* @type String
|
1171
|
+
*
|
1172
|
+
*/
|
1173
|
+
this.getValidClassName = function(){
|
1174
|
+
return validClassName;
|
1175
|
+
};
|
1176
|
+
/**
|
1177
|
+
* Accessor method for ValidClassName
|
1178
|
+
* @param {String} className Value of ValidClassName
|
1179
|
+
* @type void
|
1180
|
+
*
|
1181
|
+
*/
|
1182
|
+
this.setValidClassName = function(className){
|
1183
|
+
validClassName = className;
|
1184
|
+
};
|
1185
|
+
/**
|
1186
|
+
* Adds this object to the array if it has not reached the maximum size.
|
1187
|
+
* Type Checking is left to the descendent class.
|
1188
|
+
* @return The new number of items in the array or nothing if it is unsuccessful
|
1189
|
+
* @type int
|
1190
|
+
*
|
1191
|
+
*/
|
1192
|
+
this.add = function(obj){
|
1193
|
+
if(this.isValidObject(obj)){
|
1194
|
+
if (m_maxItems !== -1 && m_items.length === max) return;
|
1195
|
+
m_items.push(obj);
|
1196
|
+
return m_items.length;
|
1197
|
+
}
|
1198
|
+
return;
|
1199
|
+
};
|
1200
|
+
/**
|
1201
|
+
* Get the maximum size.
|
1202
|
+
* @return The size of the array
|
1203
|
+
* @type int
|
1204
|
+
*
|
1205
|
+
*/
|
1206
|
+
this.getSize = function () {
|
1207
|
+
return m_items.length;
|
1208
|
+
};
|
1209
|
+
/**
|
1210
|
+
* Get the item at postion i
|
1211
|
+
* @return The object
|
1212
|
+
* @param {int} i The position in the array from which to pull the object
|
1213
|
+
* @type Object
|
1214
|
+
*
|
1215
|
+
*/
|
1216
|
+
this.get = function(i){
|
1217
|
+
return m_items[i];
|
1218
|
+
};
|
1219
|
+
/**
|
1220
|
+
* Remove the item at postion iIndex
|
1221
|
+
* @return The object to be removed
|
1222
|
+
* @param {int} iIndex The position in the array from which to pull the object
|
1223
|
+
* @type MQObject
|
1224
|
+
*
|
1225
|
+
*/
|
1226
|
+
this.remove = function (iIndex) {
|
1227
|
+
return m_items.splice(iIndex, 1);
|
1228
|
+
};
|
1229
|
+
/**
|
1230
|
+
* Remove all the items in the array
|
1231
|
+
* @type void
|
1232
|
+
*
|
1233
|
+
*/
|
1234
|
+
this.removeAll = function () {
|
1235
|
+
m_items = null;
|
1236
|
+
m_items = new Array();
|
1237
|
+
};
|
1238
|
+
/**
|
1239
|
+
* Check if the array contains a specific object
|
1240
|
+
* @return True if the object is in the collection, false otherwise
|
1241
|
+
* @param {MQObject} item The object to search for
|
1242
|
+
* @type Boolean
|
1243
|
+
*
|
1244
|
+
*/
|
1245
|
+
this.contains = function (item) {
|
1246
|
+
var size = this.getSize();
|
1247
|
+
for (var count = 0; count < size; count++) {
|
1248
|
+
if (m_items[count] === item) {
|
1249
|
+
return true;
|
1250
|
+
}
|
1251
|
+
}
|
1252
|
+
return false;
|
1253
|
+
};
|
1254
|
+
/**
|
1255
|
+
* Append a collection to this one
|
1256
|
+
* @param {MQObjectCollection} collection The collection to append to this one
|
1257
|
+
* @type void
|
1258
|
+
*
|
1259
|
+
*/
|
1260
|
+
this.append = function(collection){
|
1261
|
+
if(this.getClassName()===collection.getClassName()){
|
1262
|
+
m_items = m_items.concat(collection.getM_Items());
|
1263
|
+
} else {
|
1264
|
+
alert("Invalid attempt to append " + this.getClassName() + " to " + collection.getClassName() + "!");
|
1265
|
+
throw "Invalid attempt to append " + this.getClassName() + " to " + collection.getClassName() + "!";
|
1266
|
+
}
|
1267
|
+
};
|
1268
|
+
/**
|
1269
|
+
* Replace an object at position i and return the old object.
|
1270
|
+
* @return True if valid, false otherwise
|
1271
|
+
* @type MQObject
|
1272
|
+
*
|
1273
|
+
*/
|
1274
|
+
this.set = function(i, newO){
|
1275
|
+
var oldO = get(i);
|
1276
|
+
m_items[i] = newO;
|
1277
|
+
return oldO;
|
1278
|
+
};
|
1279
|
+
/**
|
1280
|
+
* Is this object a valid object for this collection.
|
1281
|
+
* @return True if valid, false otherwise
|
1282
|
+
* @type MQObject
|
1283
|
+
*
|
1284
|
+
*/
|
1285
|
+
this.isValidObject = function(obj) {
|
1286
|
+
if(obj!==null){
|
1287
|
+
if(validClassName === "ALL"){
|
1288
|
+
return true;
|
1289
|
+
}else if(validClassName === "MQObject"){
|
1290
|
+
return true;
|
1291
|
+
}else if(validClassName === "String"){
|
1292
|
+
return true;
|
1293
|
+
} else if(validClassName === "int"){
|
1294
|
+
if (isNaN(obj)){
|
1295
|
+
return false;
|
1296
|
+
} else if (obj === Math.floor(obj)){
|
1297
|
+
return true;
|
1298
|
+
}
|
1299
|
+
} else if(obj.getClassName() === validClassName ){
|
1300
|
+
return true;
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
return false;
|
1304
|
+
};
|
1305
|
+
/**
|
1306
|
+
* Value to represent the xpath of items in this collections
|
1307
|
+
* @type String
|
1308
|
+
*
|
1309
|
+
*/
|
1310
|
+
var m_itemXpath = "Item";
|
1311
|
+
/**
|
1312
|
+
* Returns the m_itemXpath string.
|
1313
|
+
* @return The m_itemXpath string.
|
1314
|
+
* @type String
|
1315
|
+
*
|
1316
|
+
*/
|
1317
|
+
this.getM_itemXpath = function() {
|
1318
|
+
return m_itemXpath;
|
1319
|
+
};
|
1320
|
+
/**
|
1321
|
+
* Sets the m_itemXpath string.
|
1322
|
+
* @param {String} itemXpath the String m_xpath is set to.
|
1323
|
+
* @type void
|
1324
|
+
*
|
1325
|
+
*/
|
1326
|
+
this.setM_itemXpath = function(itemXpath) {
|
1327
|
+
m_itemXpath = itemXpath;
|
1328
|
+
};
|
1329
|
+
/**
|
1330
|
+
* Return the object, if it exists, with the id strId
|
1331
|
+
* @param {String} strId The id to check for.
|
1332
|
+
* @return The object if it exists.
|
1333
|
+
* @type Object
|
1334
|
+
*
|
1335
|
+
*/
|
1336
|
+
this.getById = function (strId) {
|
1337
|
+
try{
|
1338
|
+
for (var count = 0; count < this.getSize(); count++) {
|
1339
|
+
if (m_items[count].getId() == strId) {
|
1340
|
+
return m_items[count];
|
1341
|
+
}
|
1342
|
+
}
|
1343
|
+
}catch(Error){
|
1344
|
+
// do nothing
|
1345
|
+
// if here then the objects in question don't support the getbyid method
|
1346
|
+
}
|
1347
|
+
return null;
|
1348
|
+
};
|
1349
|
+
/**
|
1350
|
+
* Remove an item by it's pointer.
|
1351
|
+
* @param {Object} item pointer to the item to remove.
|
1352
|
+
* @type void
|
1353
|
+
*/
|
1354
|
+
this.removeItem = function (item) {
|
1355
|
+
for(var i = 0; i < m_items.length; i++)
|
1356
|
+
{
|
1357
|
+
if (m_items[i] == item)
|
1358
|
+
{
|
1359
|
+
this.remove(i);
|
1360
|
+
i = m_items.length;
|
1361
|
+
}
|
1362
|
+
}
|
1363
|
+
};
|
1364
|
+
}
|
1365
|
+
/**
|
1366
|
+
* Returns the text name of this class.
|
1367
|
+
* @return The text name of this class.
|
1368
|
+
* @type String
|
1369
|
+
*/
|
1370
|
+
MQObjectCollection.prototype.getClassName = function(){
|
1371
|
+
return "MQObjectCollection";
|
1372
|
+
};
|
1373
|
+
/**
|
1374
|
+
* Returns the version of this class.
|
1375
|
+
* @return The version of this class.
|
1376
|
+
* @type int
|
1377
|
+
*/
|
1378
|
+
MQObjectCollection.prototype.getObjectVersion = function(){
|
1379
|
+
return 0;
|
1380
|
+
};
|
1381
|
+
/**
|
1382
|
+
* Wraps the get(i) method
|
1383
|
+
* @return The object
|
1384
|
+
* @param {int} i The position in the array from which to pull the object
|
1385
|
+
* @type Object
|
1386
|
+
*/
|
1387
|
+
MQObjectCollection.prototype.getAt = function(i){
|
1388
|
+
return this.get(i);
|
1389
|
+
};
|
1390
|
+
|
1391
|
+
//************* BEGIN MQLatLngCollection ***************
|
1392
|
+
// Begin class MQLatLngCollection
|
1393
|
+
/* Inheirit from MQObjectCollection */
|
1394
|
+
MQLatLngCollection.prototype = new MQObjectCollection(32678);
|
1395
|
+
MQLatLngCollection.prototype.constructor = MQLatLngCollection;
|
1396
|
+
/**
|
1397
|
+
* Constructs a new MQLatLngCollection object. The first MQLatLng in the collection
|
1398
|
+
* is expected to be a latlng but the rest are assumed to be deltas from the first.
|
1399
|
+
* When adding the latlngs or loading from xml the user will need to make the calculations.
|
1400
|
+
* @class Contains a collection of LatLng objects.
|
1401
|
+
* @extends MQObjectCollection
|
1402
|
+
* @see MQLatLng
|
1403
|
+
* @see MQDistanceUnits
|
1404
|
+
*/
|
1405
|
+
function MQLatLngCollection() {
|
1406
|
+
MQObjectCollection.call(this, 32678);
|
1407
|
+
this.setValidClassName("MQLatLng");
|
1408
|
+
this.setM_Xpath("LatLngCollection");
|
1409
|
+
this.setM_XmlDoc(mqCreateXMLDocFromNode(MQXML.getLATLNGCOLLECTION()));
|
1410
|
+
}
|
1411
|
+
/**
|
1412
|
+
* Returns the text name of this class.
|
1413
|
+
* @return The text name of this class.
|
1414
|
+
* @type String
|
1415
|
+
*/
|
1416
|
+
MQLatLngCollection.prototype.getClassName = function(){
|
1417
|
+
return "MQLatLngCollection";
|
1418
|
+
};
|
1419
|
+
/**
|
1420
|
+
* Returns the version of this class.
|
1421
|
+
* @return The version of this class.
|
1422
|
+
* @type int
|
1423
|
+
*/
|
1424
|
+
MQLatLngCollection.prototype.getObjectVersion = function(){
|
1425
|
+
return 1;
|
1426
|
+
};
|
1427
|
+
/**
|
1428
|
+
* Assigns the xml that relates to this object.
|
1429
|
+
* @param {String} strXml the xml to be assigned.
|
1430
|
+
* @type void
|
1431
|
+
*
|
1432
|
+
*/
|
1433
|
+
MQLatLngCollection.prototype.loadXml = function (strXml) {
|
1434
|
+
this.removeAll();
|
1435
|
+
var xmlDoc = mqCreateXMLDoc(strXml);
|
1436
|
+
this.setM_XmlDoc(xmlDoc);
|
1437
|
+
if (xmlDoc!==null){
|
1438
|
+
this._loadCollection(xmlDoc);
|
1439
|
+
}
|
1440
|
+
};
|
1441
|
+
/**
|
1442
|
+
* Assigns the xml that relates to this object using the create xml from node method.
|
1443
|
+
* @param {XmlNode} xmlNode the xml to be assigned.
|
1444
|
+
* @type void
|
1445
|
+
*
|
1446
|
+
*/
|
1447
|
+
MQLatLngCollection.prototype.loadXmlFromNode = function (xmlNode) {
|
1448
|
+
this.removeAll();
|
1449
|
+
var xmlDoc = mqCreateXMLDocImportNode(xmlNode);
|
1450
|
+
this.setM_XmlDoc(xmlDoc);
|
1451
|
+
if (xmlDoc!==null){
|
1452
|
+
this._loadCollection(xmlDoc);
|
1453
|
+
}
|
1454
|
+
};
|
1455
|
+
/** hidden */
|
1456
|
+
MQLatLngCollection.prototype._loadCollection = function (xmlDoc) {
|
1457
|
+
var root = xmlDoc.documentElement;
|
1458
|
+
var nodes = root.childNodes;
|
1459
|
+
var maxCount = nodes.length;
|
1460
|
+
maxCount = (maxCount < 32678) ? maxCount : 32678;
|
1461
|
+
var prevLat = 0;
|
1462
|
+
var prevLng = 0;
|
1463
|
+
var currentLat = 0;
|
1464
|
+
var currentLng = 0;
|
1465
|
+
var latlng = null;
|
1466
|
+
// iterate through xml and create objects for collection
|
1467
|
+
if(this.getValidClassName()==="MQLatLng"){
|
1468
|
+
for (var count = 0;count < maxCount; count++){
|
1469
|
+
if(count==0){
|
1470
|
+
if(nodes[count].firstChild!==null){
|
1471
|
+
currentLat = nodes[count].firstChild.nodeValue/1000000;
|
1472
|
+
}
|
1473
|
+
count++;
|
1474
|
+
if(nodes[count].firstChild!==null){
|
1475
|
+
currentLng = nodes[count].firstChild.nodeValue/1000000;
|
1476
|
+
}
|
1477
|
+
} else {
|
1478
|
+
if(nodes[count].firstChild!==null){
|
1479
|
+
currentLat = prevLat + (nodes[count].firstChild.nodeValue/1000000);
|
1480
|
+
}
|
1481
|
+
count++;
|
1482
|
+
if(nodes[count].firstChild!==null){
|
1483
|
+
currentLng = prevLng + (nodes[count].firstChild.nodeValue/1000000);
|
1484
|
+
}
|
1485
|
+
}
|
1486
|
+
prevLat = currentLat;
|
1487
|
+
prevLng = currentLng;
|
1488
|
+
latlng = new MQLatLng(currentLat, currentLng);
|
1489
|
+
this.add(latlng);
|
1490
|
+
}
|
1491
|
+
}
|
1492
|
+
};
|
1493
|
+
/**
|
1494
|
+
* Build an xml string that represents this object.
|
1495
|
+
* @return The xml string.
|
1496
|
+
* @type String
|
1497
|
+
*
|
1498
|
+
*/
|
1499
|
+
MQLatLngCollection.prototype.saveXml = function () {
|
1500
|
+
var strRet = "<" + this.getM_Xpath() + " Version=\"" + this.getObjectVersion() + "\" Count=\"" + this.getSize() + "\">";
|
1501
|
+
|
1502
|
+
var size = parseInt(this.getSize());
|
1503
|
+
if(size >= 1){
|
1504
|
+
var nLat = nLng = nPrevLat = nPrevLng = nDeltaLat = nDeltaLng = 0;
|
1505
|
+
var latLng = null;
|
1506
|
+
for(var i = 0; i < size; i++){
|
1507
|
+
latLng = this.getAt(i);
|
1508
|
+
nLat = parseInt(latLng.getLatitude() * 1000000);
|
1509
|
+
nLng = parseInt(latLng.getLongitude() * 1000000);
|
1510
|
+
nDeltaLat = nLat - nPrevLat;
|
1511
|
+
nDeltaLng = nLng - nPrevLng;
|
1512
|
+
strRet += "<Lat>" + nDeltaLat + "</Lat>";
|
1513
|
+
strRet += "<Lng>" + nDeltaLng + "</Lng>";
|
1514
|
+
nPrevLat = nLat;
|
1515
|
+
nPrevLng = nLng;
|
1516
|
+
}
|
1517
|
+
}
|
1518
|
+
strRet = strRet + "</" + this.getM_Xpath() + ">";
|
1519
|
+
return strRet;
|
1520
|
+
};
|
1521
|
+
// End class MQLatLngCollection
|
1522
|
+
|
1523
|
+
/******************************************************************************************
|
1524
|
+
/**
|
1525
|
+
*
|
1526
|
+
* Reduce the points in the lat/lng collection. All points that deviate
|
1527
|
+
* from a straight line by less than dDeviance are eliminated.
|
1528
|
+
*
|
1529
|
+
* @param dDeviance the deviance
|
1530
|
+
*/
|
1531
|
+
MQLatLngCollection.prototype.generalize = function(dDeviance) {
|
1532
|
+
|
1533
|
+
var SOrigPoint = function()
|
1534
|
+
{
|
1535
|
+
this.pLL = null; // Decimal position of the point.
|
1536
|
+
this.dSegmentLength = 0.0; // Length of segment that begins here.
|
1537
|
+
this.dPriorLength = 0.0; // Accum. length of prior segments.
|
1538
|
+
}; // end class SOrigPoint
|
1539
|
+
|
1540
|
+
var SDerivedPoint = function()
|
1541
|
+
{
|
1542
|
+
this.pLL = null; // Decimal position of the point.
|
1543
|
+
this.ulOriginalPoint = 0; // Number of original point.
|
1544
|
+
}; // end class SDerivedPoint
|
1545
|
+
|
1546
|
+
|
1547
|
+
/********** PJL: generalize main ************/
|
1548
|
+
mqllAnchor = null;
|
1549
|
+
var ulAnchor; //int
|
1550
|
+
var i; //int
|
1551
|
+
var dAccumLength = 0.0;
|
1552
|
+
var nPoints = this.getSize(); // int
|
1553
|
+
var pOrigPoints = new Array(nPoints); //new SOrigPoint[nPoints];
|
1554
|
+
var pDerivedPoints = new Array(nPoints);
|
1555
|
+
var nDerivedPoints = 0; //int
|
1556
|
+
|
1557
|
+
if (nPoints < 2)
|
1558
|
+
return;
|
1559
|
+
|
1560
|
+
|
1561
|
+
//store off our l/ls
|
1562
|
+
for (i = 0; i < nPoints; i++)
|
1563
|
+
{
|
1564
|
+
pOrigPoints[i] = new SOrigPoint();
|
1565
|
+
pDerivedPoints[i] = new SDerivedPoint();
|
1566
|
+
pOrigPoints[i].pLL = this.getAt(i);
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
//determine line segment lengths
|
1570
|
+
for (i = 0; i < nPoints - 1; i++)
|
1571
|
+
{
|
1572
|
+
pOrigPoints[i].dSegmentLength = pOrigPoints[i].pLL.arcDistance(pOrigPoints[(i+1)].pLL);
|
1573
|
+
if (i == 0)
|
1574
|
+
pOrigPoints[i].dPriorLength = 0.0;
|
1575
|
+
else
|
1576
|
+
pOrigPoints[i].dPriorLength = dAccumLength;
|
1577
|
+
dAccumLength += pOrigPoints[i].dSegmentLength;
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
//allocate space for our derived points
|
1581
|
+
mqllAnchor = pOrigPoints[0].pLL;
|
1582
|
+
ulAnchor = 0;
|
1583
|
+
pDerivedPoints[0].pLL = mqllAnchor;
|
1584
|
+
pDerivedPoints[0].ulOriginalPoint = 0;
|
1585
|
+
nDerivedPoints = 1;
|
1586
|
+
|
1587
|
+
for (i = 2; i < nPoints; i++)
|
1588
|
+
{
|
1589
|
+
if (!this.isEverybodyWithinDeviation(pOrigPoints, ulAnchor, i, dDeviance))
|
1590
|
+
{
|
1591
|
+
mqllAnchor = pOrigPoints[(i - 1)].pLL;
|
1592
|
+
ulAnchor = (i - 1);
|
1593
|
+
pDerivedPoints[nDerivedPoints].pLL = mqllAnchor;
|
1594
|
+
pDerivedPoints[nDerivedPoints].ulOriginalPoint = (i - 1);
|
1595
|
+
nDerivedPoints++;
|
1596
|
+
}
|
1597
|
+
}
|
1598
|
+
|
1599
|
+
pDerivedPoints[nDerivedPoints].pLL = pOrigPoints[nPoints - 1].pLL;
|
1600
|
+
pDerivedPoints[nDerivedPoints].ulOriginalPoint = nPoints - 1;
|
1601
|
+
nDerivedPoints++;
|
1602
|
+
|
1603
|
+
//iterate backwards through the derivedPoints list removing unused points from the collection
|
1604
|
+
var nPrev = nPoints; //int
|
1605
|
+
var nCount;
|
1606
|
+
for (nCount=(nDerivedPoints-1);nCount>=0;nCount--)
|
1607
|
+
{
|
1608
|
+
if ((nPrev-1) != pDerivedPoints[nCount].ulOriginalPoint)
|
1609
|
+
{
|
1610
|
+
for (var x=(nPrev-1);x>pDerivedPoints[nCount].ulOriginalPoint;x--)
|
1611
|
+
{
|
1612
|
+
try
|
1613
|
+
{
|
1614
|
+
this.remove(x);
|
1615
|
+
}
|
1616
|
+
catch(e)
|
1617
|
+
{
|
1618
|
+
}
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
nPrev = pDerivedPoints[nCount].ulOriginalPoint;
|
1622
|
+
}
|
1623
|
+
else
|
1624
|
+
{
|
1625
|
+
nPrev--;
|
1626
|
+
}
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
pOrigPoints=null;
|
1630
|
+
pDerivedPoints=null;
|
1631
|
+
};
|
1632
|
+
|
1633
|
+
MQLatLngCollection.prototype.isEverybodyWithinDeviation = function( pOrigPoints,
|
1634
|
+
ulOrigStartPoint, //(IN) The first point
|
1635
|
+
ulOrigEndPoint, //(IN) The last point
|
1636
|
+
dMaxDeviation) //(IN) The max deviation permitted
|
1637
|
+
{
|
1638
|
+
var dMilesPerLng=0.0;
|
1639
|
+
var dMaxDeviationSquared=0.0;
|
1640
|
+
|
1641
|
+
var mqllStartPoint=null;
|
1642
|
+
var mqllEndPoint=null;
|
1643
|
+
var dLineLatMiles=0.0;
|
1644
|
+
var dLineLngMiles=0.0;
|
1645
|
+
var dLineLengthSquared=0.0;
|
1646
|
+
|
1647
|
+
var i;
|
1648
|
+
|
1649
|
+
var mqllPoint=null;
|
1650
|
+
var dPointLatMiles=0.0;
|
1651
|
+
var dPointLngMiles=0.0;
|
1652
|
+
var dPointLengthSquared=0.0;
|
1653
|
+
|
1654
|
+
var dRatio=0.0;
|
1655
|
+
var dNumerator=0.0;
|
1656
|
+
var dDenominator=0.0;
|
1657
|
+
|
1658
|
+
var dProjectionLengthSquared=0.0;
|
1659
|
+
var dDeviationLengthSquared=0.0;
|
1660
|
+
|
1661
|
+
// Calculate miles/longitude. Also calc. the square of the max deviation.
|
1662
|
+
|
1663
|
+
dMilesPerLng = DistanceApproximation.getMilesPerLngDeg(pOrigPoints[ulOrigStartPoint].pLL.getLatitude());
|
1664
|
+
dMaxDeviationSquared = dMaxDeviation * dMaxDeviation;
|
1665
|
+
|
1666
|
+
// Build the vector, and it's length, between the start and end points.
|
1667
|
+
|
1668
|
+
mqllStartPoint = pOrigPoints[ulOrigStartPoint].pLL;
|
1669
|
+
mqllEndPoint = pOrigPoints[ulOrigEndPoint].pLL;
|
1670
|
+
dLineLatMiles = (mqllEndPoint.getLatitude() - mqllStartPoint.getLatitude()) * DistanceApproximation.MILES_PER_LATITUDE;
|
1671
|
+
dLineLngMiles = (mqllEndPoint.getLongitude() - mqllStartPoint.getLongitude()) * dMilesPerLng;
|
1672
|
+
dLineLengthSquared = dLineLatMiles * dLineLatMiles + dLineLngMiles * dLineLngMiles;
|
1673
|
+
|
1674
|
+
// Test each intermediate point.
|
1675
|
+
|
1676
|
+
for (i = ulOrigStartPoint + 1; i < ulOrigEndPoint; i++)
|
1677
|
+
{
|
1678
|
+
// Build the vector, and it's length, between the start and test points.
|
1679
|
+
mqllPoint = pOrigPoints[i].pLL;
|
1680
|
+
dPointLatMiles = (mqllPoint.getLatitude() - mqllStartPoint.getLatitude()) * DistanceApproximation.MILES_PER_LATITUDE;;
|
1681
|
+
dPointLngMiles = (mqllPoint.getLongitude() - mqllStartPoint.getLongitude()) * dMilesPerLng;
|
1682
|
+
dPointLengthSquared = dPointLatMiles * dPointLatMiles + dPointLngMiles * dPointLngMiles;
|
1683
|
+
|
1684
|
+
// To produce the projection of the length of imaginary line from the
|
1685
|
+
// origin to the test point onto the original line, generate it's ratio,
|
1686
|
+
// which is the dot product of the two vectors, divided by the dot product
|
1687
|
+
// of the line segment with itself.
|
1688
|
+
|
1689
|
+
dNumerator = dLineLatMiles * dPointLatMiles + dLineLngMiles * dPointLngMiles;
|
1690
|
+
dDenominator = dLineLatMiles * dLineLatMiles + dLineLngMiles * dLineLngMiles;
|
1691
|
+
if (dDenominator == 0)
|
1692
|
+
dRatio = 0;
|
1693
|
+
else
|
1694
|
+
dRatio = dNumerator / dDenominator;
|
1695
|
+
|
1696
|
+
dProjectionLengthSquared = dRatio * dRatio * dLineLengthSquared;
|
1697
|
+
|
1698
|
+
dDeviationLengthSquared = dPointLengthSquared - dProjectionLengthSquared;
|
1699
|
+
|
1700
|
+
if (dDeviationLengthSquared > dMaxDeviationSquared)
|
1701
|
+
return false;
|
1702
|
+
}
|
1703
|
+
return true;
|
1704
|
+
};// END this.prototype.isEverybodyWithinDeviation
|
1705
|
+
|
1706
|
+
var DistanceApproximation = new function()
|
1707
|
+
{
|
1708
|
+
this.m_testLat;
|
1709
|
+
this.m_testLng;
|
1710
|
+
this.m_mpd;
|
1711
|
+
this.m_milesPerLngDeg = new Array(69.170976, 69.160441, 69.128838, 69.076177, 69.002475,
|
1712
|
+
68.907753, 68.792041, 68.655373, 68.497792, 68.319345,
|
1713
|
+
68.120088, 67.900079, 67.659387, 67.398085, 67.116253,
|
1714
|
+
66.813976, 66.491346, 66.148462, 65.785428, 65.402355,
|
1715
|
+
64.999359, 64.576564, 64.134098, 63.672096, 63.190698,
|
1716
|
+
62.690052, 62.170310, 61.631630, 61.074176, 60.498118,
|
1717
|
+
59.903632, 59.290899, 58.660106, 58.011443, 57.345111,
|
1718
|
+
56.661310, 55.960250, 55.242144, 54.507211, 53.755675,
|
1719
|
+
52.987764, 52.203713, 51.403761, 50.588151, 49.757131,
|
1720
|
+
48.910956, 48.049882, 47.174172, 46.284093, 45.379915,
|
1721
|
+
44.461915, 43.530372, 42.585570, 41.627796, 40.657342,
|
1722
|
+
39.674504, 38.679582, 37.672877, 36.654698, 35.625354,
|
1723
|
+
34.585159, 33.534429, 32.473485, 31.402650, 30.322249,
|
1724
|
+
29.232613, 28.134073, 27.026963, 25.911621, 24.788387,
|
1725
|
+
23.657602, 22.519612, 21.374762, 20.223401, 19.065881,
|
1726
|
+
17.902554, 16.733774, 15.559897, 14.381280, 13.198283,
|
1727
|
+
12.011266, 10.820591, 9.626619, 8.429716, 7.230245,
|
1728
|
+
6.028572, 4.825062, 3.620083, 2.414002, 1.207185,
|
1729
|
+
1.000000);
|
1730
|
+
|
1731
|
+
this.MILES_PER_LATITUDE = 69.170976;
|
1732
|
+
this.KILOMETERS_PER_MILE = 1.609347;
|
1733
|
+
|
1734
|
+
// Return the number of miles per degree of longitude
|
1735
|
+
this.getMilesPerLngDeg = function(lat)
|
1736
|
+
{
|
1737
|
+
// needed to have parseInt to do rounding for array indexing
|
1738
|
+
return (Math.abs(lat) <= 90.0) ? this.m_milesPerLngDeg[parseInt(Math.abs(lat) + 0.5)] : 69.170976;
|
1739
|
+
}
|
1740
|
+
};
|