function IFactorLayer(A){this.layerName=null;this.type=null;this.bounds=null;this.fileSufix="";this.forceReload=false;this.forceClean=false;this.layerDefinition=null;this.layerEvents=new Object();this.useMultiplePhysicalLayers=false;this.physicalLayers=new Object();this.zoomLevelIndices=new Object();this.layerEmpty=true;this.initIFactorLayer(A)}IFactorLayer.defaultZoomLevelIncrement=-1;IFactorLayer.boundsOverlaps=function(B,A){if(B==null||B==[]||A==null||A==[]){return true}if(B instanceof VELatLongRectangle){B=[B]}if(A instanceof VELatLongRectangle){A=[A]}var D;for(D=0;D<B.length;D++){boundsI=B[D];var C;for(C=0;C<A.length;C++){boundsJ=A[C];var E=!(boundsI.BottomRightLatLong.Longitude<boundsJ.TopLeftLatLong.Longitude||boundsI.BottomRightLatLong.Latitude>boundsJ.TopLeftLatLong.Latitude||boundsI.TopLeftLatLong.Longitude>boundsJ.BottomRightLatLong.Longitude||boundsI.TopLeftLatLong.Latitude<boundsJ.BottomRightLatLong.Latitude);if(E){return true}}}return false};IFactorLayer.getBoundsFromBoundsDefinitionArray=function(B){var A=null;if(B!=null&&B!=""&&B!=[]){var G;var L=0;var D=new Array();for(G=0;G<B.length;G++){var I=B[G].split(",");if(I.length==4){var C=parseFloat(I[0]);var J=parseFloat(I[1]);var H=parseFloat(I[2]);var E=parseFloat(I[3]);var K=new VELatLong(E,C);var F=new VELatLong(J,H);D[L]=new VELatLongRectangle(K,F);L=L+1}}if(D.length!=0){A=D}}return A};IFactorLayer.prototype.getProperty=function(A){return this[A]};IFactorLayer.prototype.setProperty=function(A,B){if(A in this){this[A]=B;return B}else{return undefined}};IFactorLayer.prototype.getLayerDefinitionProperty=function(A){return this.layerDefinition[A]};IFactorLayer.prototype.isShapeLayer=function(){if(this.type=="indexvectorlayer"||this.type=="simplevectorlayer"){return true}else{return false}};IFactorLayer.prototype.isTileLayer=function(){if(this.type=="tilelayer"){return true}else{return false}};IFactorLayer.prototype.initIFactorLayer=function(A){if(A!=null){this.layerDefinition=A;this.layerName=A.layer_name;this.type=A.type;this.bounds=IFactorLayer.getBoundsFromBoundsDefinitionArray(A.bounds);A.bounds=this.bounds;this.normalizeBoundsForDataSourcesInBoundsDefinition(A);this.fileSufix=A.datafile_suffix;if(this.fileSufix==null){this.fileSufix=""}this.useMultiplePhysicalLayers=A.use_multiple_physical_layers;if(this.useMultiplePhysicalLayers!=true){this.useMultiplePhysicalLayers=false}this.configureLayerEventsFromLayerDefinition(A);if(A.type="indexvectorlayer"){this.zoomLevelRangeConfiguration(A)}if(this.layerRespondsToEvent("OnMapLoad")){this.forceReload=true}}};IFactorLayer.prototype.zoomLevelRangeConfiguration=function(D){var K=1;var B=19;if(D.range_of_indices==null){return }var F;for(F=0;F<D.range_of_indices.length;F++){var C=D.range_of_indices[F];if(C==null){continue}var G=C.zoom_level_range;var J=C.zoom_level_indices;var I=C.zoom_level_increment;if(G==null&&J==null&&I==null){continue}var A=null;var H=null;if(G==null){A=K;H=B}else{A=G[0];if(A==null){A=K}H=G[1];if(H==null){H=B}}if(I==null){I=IFactorLayer.defaultZoomLevelIncrement}var E;for(E=A;E<=H;E++){if(J!=null){this.zoomLevelIndices[E]=J}else{this.zoomLevelIndices[E]=E+I}}}};IFactorLayer.prototype.normalizeBoundsForDataSourcesInBoundsDefinition=function(C){if(C.source!=null&&C.source!=""&&C.source!=[]){var A;for(A=0;A<C.source.length;A++){var B=C.source[A];if(B.bounds!=null){B.bounds=IFactorLayer.getBoundsFromBoundsDefinitionArray(B.bounds)}}}};IFactorLayer.prototype.configureLayerEventsFromLayerDefinition=function(B){layerEventsDefinition=B.map_reload_event;if(layerEventsDefinition!=null&&layerEventsDefinition!=""){var A;for(A=0;A<layerEventsDefinition.length;A++){eventName=layerEventsDefinition[A];this.layerEvents[eventName]=true}}else{B.map_reload_event=new Array()}};IFactorLayer.prototype.layerEventNames=function(){eventList=new Array();for(var A in this.layerEvents){eventList[eventList.length]=A}return eventList};IFactorLayer.prototype.layerRespondsToEvent=function(B){var A=this.layerEvents[B];if(A==true){return true}else{return false}};IFactorLayer.prototype.layerOnlyRespondsToEvent=function(A){var B=this.layerDefinition.map_reload_event;if(B==null||B==""||B.length!=1){return false}else{return this.layerRespondsToEvent(A)}};IFactorLayer.prototype.layerBoundsOverlaps=function(A){return IFactorLayer.boundsOverlaps(this.bounds,A)};IFactorLayer.prototype.getIndicesLevelForZoomLevel=function(B){var A=this.zoomLevelIndices[B];if(A==null){A=B+IFactorLayer.defaultZoomLevelIncrement}return A};IFactorLayer.prototype.isLayerVisibleAtZoomLevel=function(C){var B=this.getLayerDefinitionProperty("min_zoom");var A=this.getLayerDefinitionProperty("max_zoom");if(B!=null&&B!=""&&C<B||A!=null&&A!=""&&C>A){return false}else{return true}};IFactorLayer.prototype.addPhysicalLayer=function(F,B,E,D){var A=new Object();if(D!=null){var C;for(C=0;C<D.length;C++){dataSourceName=D[C];A[dataSourceName]=true}}this.physicalLayers[F]={physicalLayerName:F,physicalVELayer:B,bounds:E,physicalDataSources:A};this.layerEmpty=false;return this.physicalLayers[F]};IFactorLayer.prototype.createAndAddNewPhysicalLayer=function(D,B){var A=new VEShapeLayer();A.SetTitle(this.layerName);var C=null;aPhysicalLayer=this.addPhysicalLayer(D,A,C,B);return aPhysicalLayer};IFactorLayer.prototype.allPhysicalLayerNames=function(){var A=new Array();for(var B in this.physicalLayers){A[A.length]=B}return A};IFactorLayer.prototype.deleteAllPhysicalLayers=function(C){var A=true;for(var B in this.physicalLayers){A=false;aPhysicalLayer=this.physicalLayers[B];aShape=aPhysicalLayer.physicalVELayer;if(aShape!=null){C.DeleteShapeLayer(aShape)}}if(!A){this.physicalLayers=new Object()}this.layerEmpty=true};