forked from sitna/api-sitna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcmap.js
1941 lines (1751 loc) · 66 KB
/
tcmap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*! async-js descargado de https://www.npmjs.com/package/async-js en 2015-04-23 (Ver https://github.com/th507/asyncJS) */
/**
* Async JavaScript Loader
* https://github.com/th507/asyncJS
*
* Slightly Deferent JavaScript loader and dependency manager
*
* @author Jingwei "John" Liu <[email protected]>
*/
(function (name, context) {
/*jshint plusplus:false, curly:false, bitwise:false, laxbreak:true*/
"use strict";
// some useful shims and variables
var dataURIPrefix = "data:application/javascript,";
// do not record return value for asynchronous task
// if handler is OMITTED
var OMITTED = "OMITTED";
// for better compression
var Document = document;
var Window = window;
var ArrayPrototype = Array.prototype;
// detect Data URI support
var supportDataURI = true;
// As much as I love to use a semantic way to
// detect Data URI support, all the detection
// methods I could think of are asynchronous,
// which makes them less reliable when calling
// asyncJS immediately after its instantiation
// IE 8 or below does not support Data URI.
// IE 8 or below returns false
// http://tanalin.com/en/articles/ie-version-js
if (Document.all && !Document.addEventListener) {
supportDataURI = false;
}
/**
* @private
* @name getCutoffLength
* Get cut-off length for iteration
*
* @param {Array} arr
* @param {Number} cutoff
*/
function getCutoffLength(arr, cutoff) {
//because AsyncQueue#then could add sync task at any time
// we must read directly from this.tasks.length
var length = arr.length;
if (~cutoff && cutoff < length) length = cutoff;
return length;
}
/**
* @private
* @name timeout
* Run callback in setTimeout
*
* @param {Function} fn
*/
function timeout(fn, s) {
Window.setTimeout(fn, s || 0);
}
/**
* @private
* @name immediate
* Run callback asynchronously (almost immediately)
*
* @param {Function} fn
*/
var immediate = Window.requestAnimationFrame
|| Window.webkitRequestAnimationFrame
|| Window.mozRequestAnimationFrame
|| timeout;
/**
* @private
* @name throwLater
* Throw Error asynchronously
*
* @param {Object} error
*/
function throwLater(error) {
timeout(function () { throw error; });
}
/**
* @private
* @name isURL
* Check if str is a URL
*
* @param {String} str
*/
function isURL(str) {
// supports URL starts with http://, https://, and //
// or a single line that ends with .js or .php
return (
/(^(https?:)?\/\/)|(\.(js|php)$)/.test(str) &&
!/(\n|\r)/m.test(str)
);
}
/**
* @private
* @name isFunction
* Check if fn is a function
*
* @param {Function} fn
*/
// This is duck typing, aka. guessing
function isFunction(fn) {
return fn && fn.constructor && fn.call && fn.apply;
}
/**
* @private
* @name makeArray
* Make an array out of given object
*
* @param {Object} obj
*/
function makeArray(obj) {
var isArray;
if ((isArray = Array.isArray)) {
return isArray(obj) ? obj : [obj];
}
return ArrayPrototype.concat(obj);
}
/**
* @private
* @name slice
* Convert array-like object to array
*
* @param {Object} arr
*/
function slice(arr) {
return ArrayPrototype.slice.call(arr);
}
/**
* @private
* @name factory
* Factory Method producing function
* that receives reduced arguments
*
* @param {Function} fn
*/
// http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming
var call = Function.call;
function factory() {
var defaults = slice(arguments);
return function () {
// keep this as simple as possible
return call.apply(call, defaults.concat(slice(arguments)));
};
}
// end of shims
/**
* @private
* @name resolveScriptEvent
* Script event handler
*
* @param {Object} resolver
* @param {Object} evt
*/
function resolveScriptEvent(resolver, evt) {
/*jshint validthis:true */
var script = this;
// run only when ready
// script.readyState is completed or loaded
if (script.readyState &&
!(/^c|loade/.test(script.readyState))
) return;
// never rerun callback
if (script.loadStatus) return;
// unbind to avoid rerun
script.onload = script.onreadystatechange = script.onerror = null;
script.loadStatus = true;
if (evt && evt.type === "error") {
var src = script.src || "Resource",
fails = " fails to load.";
// custom error
// TODO: create a more specific stack for this Error
var error = {
name: "ConnectionError",
source: src,
evt: evt,
stack: src + fails,
message: fails,
toString: function () {
return this.source + this.message;
}
};
throwLater(error);
resolver.reject(error);
return;
}
resolver.resolve();
}
/**
* @private
* @name appendScript
* Append asynchronous script to DOM
*
* @param {String|Function} str
* @param {Object} resolver
*/
function appendScript(str, resolver) {
var ScriptTagName = "script";
var script = Document.createElement(ScriptTagName);
// at least one script could be found,
// the one which wraps around asyncJS
var scripts = Document.getElementsByTagName(ScriptTagName);
var lastScript = scripts[scripts.length - 1];
script.async = true;
script.src = str;
if (!resolver) return;
// executes callback if given
script.loadStatus = false;
var resolveScript = factory(resolveScriptEvent, script, resolver);
// onload for all sane browsers
// onreadystatechange for legacy IE
script.onload = script.onreadystatechange = script.onerror = resolveScript;
// inline script tends to change nearby DOM elements
// so we append script closer to the caller
// this is at best a ballpark guess and
// might not work well with some inline script
var slot = lastScript;
// in case running from Console
// we might encounter a scriptless page
slot = slot || document.body.firstChild;
slot.parentNode.insertBefore(script, slot);
}
/**
* @private
* @name loadFunction
* Loads JS function or script string for
* browser that does not support Data URI
*
* @param {String|Function} js
* @param {Function} fn
*/
function loadFunction(js, resolver) {
immediate(function () {
try {
js.call(null, resolver);
}
catch (e) {
resolver.reject(e);
}
});
}
/**
* @private
* @name load
* Loads one request or executes one chunk of code
*
* @param {String|Function} js
* @param {Function} resolve
*/
function load(js, resolver) {
/*jshint newcap:false, evil:true*/
// js is not a function
if (!isFunction(js)) {
if (isURL(js)) {
appendScript(js, resolver);
return;
}
if (supportDataURI) {
// wraps up inline JavaScript into external script
js = dataURIPrefix + encodeURIComponent(js);
appendScript(js, resolver);
return;
}
}
var fn = isFunction(js) ? js : Function(js);
// a synchronous function is wrapped into a special function
// so that we could use the same logic as an asynchronous function
if (!resolver.async) {
var task = fn;
fn = function (resolver) {
try {
task.call(null);
resolver.resolve();
}
catch (e) {
resolver.reject(e);
}
};
}
loadFunction(fn, resolver);
}
/**
* @public
* @name AsyncQueue
* Create a semi-Promise for asyncJS
* @constructor
*
* @param {Array|String|Function} tasks
* @param {Function} fn
*/
function AsyncQueue(tasks, fn) {
// better compression for shrinking `this`
var self = this;
// TODO: exposing this is not safe
self.tasks = [];
self.callbacks = [];
self.errors = [];
// return values of Promise
self.data = {};
// resolved task index
self.nextTask = 0;
// resolved callback index
self.nextCallback = 0;
// -1 (default) means not waiting for AsyncQueue#then
self.until = -1;
// queue is executing callback
self.digest = false;
// add tasks and callbacks
self.add(tasks).whenDone(fn);
}
/**
* @private
* @name resolveCallback
* Resolve next asyncJS callback
*/
function resolveCallback() {
/*jshint validthis:true*/
var self = this;
// if current digestion circle is still active
// then try again later
if (self.digest) {
timeout(factory(resolveCallback, self), 50 / 3);
return;
}
self.digest = true;
var fn, next, i = self.nextCallback;
// always update length for next iteration
for (; i < getCutoffLength(self.callbacks, self.until) ; i++) {
if (self.nextTask !== self.tasks.length) continue;
next = self.nextCallback;
fn = self.callbacks[next];
if (fn) {
self.nextCallback = i + 1;
// passing in current taskIndex
fn.call(null, self.data, self.nextTask - 1, self.errors);
// if callback is not to generated function
// then it would advance to the next iteration
if (!fn.untilThen) continue;
// reduce nextCallback count
self.nextCallback--;
// release iteration lock
self.until = -1;
}
// remove invalid or untilThen function
self.callbacks.splice(next, 1);
}
self.digest = false;
}
/**
* @private
* @name nextTick
* Advance to next tick in the queue
* For AsyncQueue#reject or AsyncQueue#resolve
*
* @param {String} handle
* @param {Object} data
*/
function nextTick() {
/*jshint validthis:true*/
var self = this;
// never resolve when tasks are finished
if (self.nextTask < self.tasks.length) {
// if tasks are still queueing
// increment nextTask
if (++self.nextTask !== self.tasks.length) return self;
}
// check callbacks if all tasks are finished
resolveCallback.call(self);
return self;
}
/**
* @private
* @name resolve
* Resolve next asyncJS queue
* Normally, you never have to call this
*
* @param {String} handle
* @param {Object} data
*/
AsyncQueue.prototype.resolve = function (handle, data) {
/*jshint validthis:true*/
var self = this;
// save data if available and necessary
if (handle && handle !== OMITTED) self.data[handle] = data;
return nextTick.call(self);
};
/**
* @private
* @name reject
* Reject and continue next asyncJS queue
*
* @param {Object} error
*/
AsyncQueue.prototype.reject = function (error) {
/*jshint validthis:true*/
var self = this;
if (error) {
throwLater(error);
self.errors.push(error);
}
// keep executing other stacked tasks
return nextTick.call(self);
};
/**
* @public
* @name AsyncQueue#whenDone
* Attach extra callback to next asyncJS queue
*
* @param {Function} fn
*/
AsyncQueue.prototype.whenDone = function (fn) {
// save a few bytes
var self = this;
if (!fn) return self;
// tasks undone
if (self.nextTask > self.tasks.length) return self;
// add callback function
self.callbacks.push(fn);
// try resolve
if (self.nextTask === self.tasks.length) self.resolve();
return self;
};
/**
* @public
* @name AsyncQueue#add
* Add tasks to next asyncJS queue
*
* @param {Array|String|Function} tasks
*/
AsyncQueue.prototype.add = function (tasks, handle) {
var self = this;
if (!tasks) return self;
// warn user if returned data could overwrite
// existing data, without stopping further execution
if (handle && self[handle]) {
var error = new Error("Callback value name: " + handle + " is registered");
throwLater(error);
self.errors.push(error);
}
tasks = makeArray(tasks);
var resolver = {
resolve: factory(self.resolve, self, handle),
reject: self.reject,
async: !!handle
};
for (var i = 0, fn; i < tasks.length; i++) {
fn = tasks[i];
if (!fn) continue;
// this is just for future reference
self.tasks.push(fn);
// resolve function
load(fn, self);
}
return self;
};
/**
* @public
* @name AsyncQueue#then
* Add a SINGLE dependent task to next asyncJS queue
* which blocks all following callbacks
* until this task is finished
*
* @param {Array|String|Function} task
*/
AsyncQueue.prototype.then = function (task, handle) {
var self = this;
if (!task) return self;
// if there are still tasks unfinished
// add new tasks when this function
// that has a `untilthen` property
function addDependent() {
// when `resolveCallback` sees the
// property, it will stop executing
// all other callbacks until it is done
self.until = self.nextCallback;
self.add(task, handle);
}
addDependent.untilThen = true;
return self.whenDone(addDependent);
};
/**
* @public
* @name asyncJS
* Loads multiple requests or executes inline code
*
* @param {String|Array} js
* @param {Function} fn
*
* @return {Object} asyncJS queue
*/
function asyncJS(js, fn) {
return new AsyncQueue(js, fn);
}
// export asyncJS
/*jshint node:true*/
/*global define*/
if (typeof module !== 'undefined' && module.exports) {
module.exports = asyncJS;
}
else if (typeof define === "function" && define.amd) {
define(function () { return asyncJS; });
}
else {
context[name] = asyncJS;
}
}("asyncJS", this));
var TC = TC || {};
/*
* Initialization
*/
TC.version = '1.3.0';
(function () {
if (!TC.apiLocation) {
var src;
var script;
if (document.currentScript) {
script = document.currentScript;
}
else {
var scripts = document.getElementsByTagName('script');
script = scripts[scripts.length - 1];
}
var src = script.getAttribute('src');
TC.apiLocation = src.substr(0, src.lastIndexOf('/') + 1);
}
})();
if (!TC.Consts) {
TC.Consts = {};
TC.Consts.OLNS_LEGACY = 'OpenLayers';
TC.Consts.OLNS = 'ol';
TC.Consts.PROJ4JSOBJ_LEGACY = 'Proj4js';
TC.Consts.PROJ4JSOBJ = 'proj4';
TC.Consts.GEOGRAPHIC = 'geographic';
TC.Consts.UTM = 'UTM';
TC.Consts.OLD_BROWSER_ALERT = 'TC.oldBrowserAlert';
TC.Consts.CLUSTER_ANIMATION_DURATION = 200;
TC.Consts.ZOOM_ANIMATION_DURATION = 300;
TC.Consts.URL_MAX_LENGTH = 2048;
TC.Consts.METER_PRECISION = 0;
TC.Consts.DEGREE_PRECISION = 5;
TC.Consts.EXTENT_TOLERANCE = 0.9998;/*URI: debido al redondeo del extente en el hash se obtiene un nivel de resolución mayor al debido. Con este valor definimos una tolerancia para que use una resolución si es muy muy muy próxima*/
TC.Consts.url = {
SPLIT_REGEX: /([^:]*:)?\/\/([^:]*:?[^@]*@)?([^:\/\?]*):?([^\/\?]*)/,
MODERNIZR: 'lib/modernizr.js',
JQUERY_LEGACY: TC.apiLocation + 'lib/jquery/jquery.1.10.2.js',
JQUERY: '//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js',
OL_LEGACY: 'lib/OpenLayers/OpenLayers.debug.js',
OL: 'lib/ol/build/ol-custom.js',
OL_CONNECTOR_LEGACY: 'TC/ol/ol2.js',
OL_CONNECTOR: 'TC/ol/ol.js',
TEMPLATING: 'lib/dust/dust-full-helpers.min.js',
TEMPLATING_I18N: 'lib/dust/dustjs-i18n.min.js',
TEMPLATING_OVERRIDES: 'lib/dust/dust.overrides.js',
PROJ4JS_LEGACY: 'lib/proj4js/legacy/proj4js-compressed.js',
PROJ4JS: 'lib/proj4js/proj4-src.js',
SPATIALREFERENCE: 'http://spatialreference.org/',
LOCALFORAGE: TC.apiLocation + 'lib/localForage/localforage.min.js',
D3C3: TC.apiLocation + 'lib/d3c3/d3c3.min.js',
CESIUM: TC.apiLocation + 'lib/cesium/release/Cesium.js',
JSNLOG: 'lib/jsnlog/jsnlog.min.js',
ERROR_LOGGER: TC.apiLocation + 'errors/logger.ashx',
PDFMAKE: TC.apiLocation + 'lib/pdfmake/pdfmake-fonts.min.js',
JSONPACK: 'lib/jsonpack/jsonpack.min.js'
};
TC.Consts.classes = {
MAP: 'tc-map',
POINT: 'tc-point',
MARKER: 'tc-marker',
VISIBLE: 'tc-visible',
HIDDEN: 'tc-hidden',
COLLAPSED: 'tc-collapsed',
CHECKED: 'tc-checked',
DISABLED: 'tc-disabled',
ACTIVE: 'tc-active',
LASTCHILD: 'tc-lastchild',
TRANSPARENT: 'tc-transparent',
DROP: 'tc-drop',
LOADING: 'tc-loading',
IPAD_IOS7_FIX: 'tc-ipad-ios7-fix',
INFO: 'tc-msg-info',
WARNING: 'tc-msg-warning',
ERROR: 'tc-msg-error'
};
TC.Consts.msgType = {
INFO: 'info',
WARNING: 'warning',
ERROR: 'error'
};
TC.Consts.msgErrorMode = {
TOAST: 'toast',
CONSOLE: 'console',
EMAIL: 'email'
};
TC.Consts.event = {
/**
* Se lanza cuando el mapa ha cargado todas sus capas iniciales y todos sus controles
* @event mapload
*/
MAPLOAD: 'mapload.tc',
MAPREADY: 'mapready.tc',
BEFORELAYERADD: 'beforelayeradd.tc',
LAYERADD: 'layeradd.tc',
LAYERREMOVE: 'layerremove.tc',
LAYERORDER: 'layerorder.tc',
BEFORELAYERUPDATE: 'beforelayerupdate.tc',
LAYERUPDATE: 'layerupdate.tc',
LAYERERROR: 'layererror.tc',
BEFOREBASELAYERCHANGE: 'beforebaselayerchange.tc',
BASELAYERCHANGE: 'baselayerchange.tc',
BEFOREUPDATE: 'beforeupdate.tc',
UPDATE: 'update.tc',
BEFOREZOOM: 'beforezoom.tc',
ZOOM: 'zoom.tc',
BEFOREUPDATEPARAMS: 'beforeupdateparams.tc',
UPDATEPARAMS: 'updateparams.tc',
VECTORUPDATE: 'vectorupdate.tc',
FEATUREADD: 'featureadd.tc',
BEFOREFEATURESADD: 'beforefeaturesadd.tc',
FEATURESADD: 'featuresadd.tc',
FEATUREREMOVE: 'featureremove.tc',
FEATURESCLEAR: 'featuresclear.tc',
FEATURESIMPORT: 'featuresimport.tc',
FEATURESIMPORTERROR: 'featuresimporterror.tc',
BEFORETILELOAD: 'beforetileload.tc',
TILELOAD: 'tileload.tc',
TILELOADERROR: 'tileloaderror.tc',
CONTROLADD: 'controladd.tc',
CONTROLACTIVATE: 'controlactivate.tc',
CONTROLDEACTIVATE: 'controldeactivate.tc',
BEFORECONTROLRENDER: 'beforecontrolrender.tc',
CONTROLRENDER: 'controlrender.tc',
BEFORELAYOUTLOAD: 'beforelayoutload.tc',
LAYOUTLOAD: 'layoutload.tc',
LAYERVISIBILITY: 'layervisibility.tc',
LAYEROPACITY: 'layeropacity.tc',
FEATURECLICK: 'featureclick.tc',
NOFEATURECLICK: 'nofeatureclick.tc',
FEATUREOVER: 'featureover.tc',
FEATUREOUT: 'featureout.tc',
BEFOREFEATUREINFO: 'beforefeatureinfo.tc',
FEATUREINFO: 'featureinfo.tc',
NOFEATUREINFO: 'nofeatureinfo.tc',
FEATUREINFOERROR: 'featureinfoerror.tc',
CLICK: 'click.tc',
MOUSEUP: 'mouseup.tc',
STARTLOADING: 'startloading.tc',
STOPLOADING: 'stoploading.tc',
EXTERNALSERVICEADDED: 'externalserviceadded.tc',
ZOOMTO: 'zoomto.tc',
};
TC.Consts.layer = {
IDENA_ORTHOPHOTO: 'ortofoto',
IDENA_BASEMAP: 'mapabase',
IDENA_CADASTER: 'catastro',
IDENA_CARTO: 'cartografia',
IDENA_ORTHOPHOTO2012: 'ortofoto2012',
IDENA_DYNBASEMAP: 'mapabase_dinamico',
IDENA_BW_RELIEF: 'relieve_bn',
IDENA_BASEMAP_ORTHOPHOTO: 'base_orto',
BLANK: 'ninguno'
};
TC.Consts.text = {
API_ERROR: 'Error API SITNA',
APP_ERROR: 'Error de aplicación'
};
/**
* Colección de identificadores de tipo de capa.
* No se deberían modificar las propiedades de esta clase.
* @class TC.consts.LayerType
* @static
*/
/**
* Identificador de capa de tipo WMS.
* @property WMS
* @type string
* @final
*/
/**
* Identificador de capa de tipo WMTS.
* @property WMTS
* @type string
* @final
*/
/**
* Identificador de capa de tipo WFS.
* @property WFS
* @type string
* @final
*/
/**
* Identificador de capa de tipo KML.
* @property KML
* @type string
* @final
*/
/**
* Identificador de capa de tipo GPX.
* @property GPX
* @type string
* @final
*/
/**
* Identificador de capa de tipo vectorial. Este tipo de capa es la que se utiliza para dibujar marcadores.
* @property VECTOR
* @type string
* @final
*/
/**
* Identificador de capa de grupo.
* @property GROUP
* @type string
* @final
*/
TC.Consts.layerType = {
WMS: 'WMS',
WMTS: 'WMTS',
WFS: 'WFS',
VECTOR: 'vector',
KML: 'KML',
GPX: 'GPX',
GEOJSON: 'GeoJSON',
GROUP: 'group'
};
TC.Consts.geom = {
POINT: 'point',
MULTIPOINT: 'multipoint',
POLYLINE: 'polyline',
POLYGON: 'polygon',
MULTIPOLYLINE: 'multipolyline',
MULTIPOLYGON: 'multipolygon',
CIRCLE: 'circle',
RECTANGLE: 'rectangle'
};
TC.Consts.searchType = {
CADASTRAL: 'cadastral',
COORDINATES: 'coordinates',
MUNICIPALITY: 'municipality',
COUNCIL: 'council',
LOCALITY: 'locality',
STREET: 'street',
NUMBER: 'number',
URBAN: 'urban',
COMMONWEALTH: 'commonwealth',
ROAD: 'road',
ROADPK: 'roadpk'
};
TC.Consts.mapSearchType = {
MUNICIPALITY: TC.Consts.searchType.MUNICIPALITY,
COUNCIL: TC.Consts.searchType.COUNCIL,
URBAN: TC.Consts.searchType.URBAN,
COMMONWEALTH: TC.Consts.searchType.COMMONWEALTH,
GENERIC: 'generic'
};
TC.Consts.comparison = {
EQUAL_TO: '=='
};
TC.Consts.WMTSEncoding = {
KVP: 'KVP',
RESTFUL: 'RESTful'
};
TC.Consts.mimeType = {
PNG: 'image/png',
JPEG: 'image/jpeg',
JSON: 'application/json',
KML: 'application/vnd.google-earth.kml+xml',
GML: 'application/gml+xml',
XML: 'application/xml'
};
TC.Consts.format = {
JSON: 'JSON',
KML: 'KML',
GML: 'GML',
GML2: 'GML2',
GML3: 'GML2',
GEOJSON: 'GeoJSON',
TOPOJSON: 'TopoJSON',
GPX: 'GPX',
WKT: 'WKT'
};
/**
* Colección de identificadores de estados de visibilidad.
* No se deberían modificar las propiedades de esta clase.
* @class TC.consts.Visibility
* @static
*/
/**
* Identificador de nodo no visible.
* @property NOT_VISIBLE
* @type number
* @final
*/
/**
* Identificador de nodo no visible a la resolución actual.
* @property NOT_VISIBLE_AT_RESOLUTION
* @type number
* @final
*/
/**
* Identificador de nodo no visible pero que tiene nodos hijos visibles.
* @property HAS_VISIBLE
* @type number
* @final
*/
/**
* Identificador de nodo visible.
* @property VISIBLE
* @type number
* @final
*/
TC.Consts.visibility = {
NOT_VISIBLE: 0,
NOT_VISIBLE_AT_RESOLUTION: 1,
HAS_VISIBLE: 2,
VISIBLE: 4
};
TC.Consts.MARKER = 'marker';
TC.Defaults = (function () {
var clusterRadii = {};
var getClusterRadius = function (feature) {
var count = feature.features.length;
var result = clusterRadii[count];
if (!result) {
result = Math.round(Math.sqrt(count) * 15);
clusterRadii[count] = result;
}
return result;
};
var clusterFillColors = {};
var getClusterFillColor = function (feature) {
var count = feature.features.length;
var result = clusterFillColors[count];
if (!result) {
var r = Math.round(100 + 155 * Math.min(6, count) / 6);
if (r > 255) r = 255;
var g = Math.round(255 - 155 * Math.max(0, count - 4) / 6);
if (g < 100) g = 100;
var b = 100;
result = '#' + r.toString(16) + g.toString(16) + b.toString(16);
clusterFillColors[count] = result;
}
return result;
};
return {
imageRatio: 1.05,
proxy: '',
crs: 'EPSG:25830',
utmCrs: 'EPSG:25830',
geoCrs: 'EPSG:4326',
initialExtent: [541084.221, 4640788.225, 685574.4632, 4796618.764],
maxExtent: [480408, 4599748, 742552, 4861892],
baselayerExtent: [480408, 4599748, 742552, 4861892],
resolutions: [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, .5, .25],
pointBoundsRadius: 30,
extentMargin: 0.2,
mouseWheelZoom: true,
attribution: '<a href="http://sitna.navarra.es/" target="_blank">SITNA</a>',
oldBrowserAlert: true,
notifyApplicationErrors: false,
maxErrorCount: 10,
locale: 'es_ES',
screenSize: 20,
pixelTolerance: 10,
toastDuration: 5000,
avgTileSize: 31000,
availableBaseLayers: [
{
id: TC.Consts.layer.IDENA_BASEMAP,
title: 'Mapa base',
type: TC.Consts.layerType.WMTS,
url: '//idena.navarra.es/ogc/wmts/',
matrixSet: 'epsg25830extended',
layerNames: 'mapabase',
encoding: TC.Consts.WMTSEncoding.RESTFUL,
format: 'image/png',
isDefault: true,
hideTree: true,
thumbnail: TC.apiLocation + 'TC/css/img/thumb-basemap.png'
},
{
id: TC.Consts.layer.IDENA_ORTHOPHOTO,
title: 'Ortofoto 2014',
type: TC.Consts.layerType.WMTS,
url: '//idena.navarra.es/ogc/wmts/',
matrixSet: 'epsg25830reduced',
layerNames: 'ortofoto2014',
encoding: TC.Consts.WMTSEncoding.RESTFUL,