this.packet.position_timestamp){dateString=moment(positionDate).format(trackdirect.settings.dateFormatNoTimeZone)+
" - "+
moment(date).format(trackdirect.settings.dateFormatNoTimeZone);}
if(this.packet.getOgnRegistration()!=null){var name=escapeHtml(this.packet.station_name);name+=", ";name+=escapeHtml(this.packet.getOgnRegistration());if(this.packet.getOgnCN()!==null){name+=" ["+escapeHtml(this.packet.getOgnCN())+"]";}
return(''+
'
'+
name+
" "+
''+
dateString+
"
");}else if(this.packet.station_name==this.packet.sender_name){return(''+
'
'+
escapeHtml(this.packet.station_name)+
" "+
''+
dateString+
"
");}else{return(''+
'
'+
escapeHtml(this.packet.station_name)+
" "+
'Sent by '+
escapeHtml(this.packet.sender_name)+
"
"+
''+
dateString+
"
");}};trackdirect.models.Marker.prototype._getGoogleMarkerOptions=function(){var anchorPoint=null;if(this._isDotMarker){var colorId=trackdirect.services.stationColorCalculator.getColorId(this.packet);var iconUrl=trackdirect.settings.baseUrl+
trackdirect.settings.imagesBaseDir+
"dotColor"+
colorId+
".png";var scaledImageSize=new google.maps.Size(12,12);var imageSize=new google.maps.Size(12,12);var imageAnchor=new google.maps.Point(6,6);var opacity=1.0;}else{var scalePx=24;var sizePx=24;if(this._shouldMarkerSymbolBeScaled()){scalePx=48;}
if(this.packet.course!==null){sizePx=sizePx+7;if(scalePx0){var dotMarkers=markerCollection.getDotMarkers(me.markerIdKey);dotMarkers[0]._addMarkerToOldTimeout(0);me._addMarkerToOldTimeout(100);}}}else{me._addMarkerToOldTimeout(1000);}}},delay);}),(trackdirect.models.Marker.prototype._emitTdEventListeners=function(event,arg){if(event in this._tdEventListeners){for(var i=0;i0){this._supportedMapTypes=this._tdMapOptions.supportedMapTypes;}else if(typeof google==="object"&&typeof google.maps==="object"){this._supportedMapTypes["roadmap"]=google.maps.MapTypeId.ROADMAP;this._supportedMapTypes["terrain"]=google.maps.MapTypeId.TERRAIN;this._supportedMapTypes["satellite"]=google.maps.MapTypeId.SATELLITE;this._supportedMapTypes["hybrid"]=google.maps.MapTypeId.HYBRID;}else if(typeof L==="object"){this._supportedMapTypes["roadmap"]="OpenStreetMap.Mapnik";this._supportedMapTypes["terrain"]="OpenTopoMap";}
if(typeof this._tdMapOptions.maptype!=="undefined"&&this._tdMapOptions.maptype!==null&&this._tdMapOptions.maptype in this._supportedMapTypes){this._mapType=this._tdMapOptions.maptype;}else{this._mapType=Object.keys(this._supportedMapTypes)[0];}};trackdirect.models.Map.prototype._initMap=function(){this._heatMap=new trackdirect.models.HeatMap(this);this._setMapInitialLocation();this._initOms();this._initInfoWindowEvent();this._updateMapContent();this._initMapEvents();if(typeof google==="object"&&typeof google.maps==="object"){if(typeof this._tdMapOptions.mid!=="undefined"){var kmlUrl="https://www.google.com/maps/d/u/0/kml?mid="+this._tdMapOptions.mid;var kmlLayer=new google.maps.KmlLayer(kmlUrl,{map:this});}}};trackdirect.models.Map.prototype.triggerResize=function(){if(typeof google==="object"&&typeof google.maps==="object"){google.maps.event.trigger(this,"resize");}else if(typeof L==="object"){L.Map.prototype._onResize.call(this);}};trackdirect.models.Map.prototype.setCenter=function(pos,zoom){if(typeof google==="object"&&typeof google.maps==="object"){google.maps.Map.prototype.setCenter.call(this,pos);if(typeof zoom!=="undefined"){google.maps.Map.prototype.setZoom.call(this,zoom);}}else if(typeof L==="object"){zoom=typeof zoom!=="undefined"?zoom:this.getZoom();L.Map.prototype.setView.call(this,pos,zoom);}
this._renderCordinatesContainer(pos);};trackdirect.models.Map.prototype.getCenterLiteral=function(){if(typeof google==="object"&&typeof google.maps==="object"){var latLng=google.maps.Map.prototype.getCenter.call(this);if(typeof latLng!=="undefined"&&typeof latLng.lat==="function"){return{lat:latLng.lat(),lng:latLng.lng()};}else{return latLng;}}else if(typeof L==="object"){var latLng=L.Map.prototype.getCenter.call(this);if(typeof latLng!=="undefined"){return{lat:latLng.lat,lng:latLng.lng};}else{return latLng;}}
return null;};trackdirect.models.Map.prototype.fitBounds=function(bounds){if(typeof google==="object"&&typeof google.maps==="object"){var latLngBounds=new google.maps.LatLngBounds();for(var i=0;i=0||this.state.isFilterMode){return true;}
return false;};trackdirect.models.Map.prototype.getNumberOfNewMarkersToShow=function(){return this._newMarkersToShow;};trackdirect.models.Map.prototype.showNewMarkersInQueue=function(track){track=typeof track!=="undefined"?track:true;var oldestAllowedTrackingTimestamp=0;if(this.state.onlyTrackRecentPackets){oldestAllowedTrackingTimestamp=Math.floor(Date.now()/1000)-60;}
while((markerIdKey=this._newMarkersToShow.pop())!=null){if(!this.markerCollection.isExistingMarker(markerIdKey)){continue;}
var marker=this.markerCollection.getMarker(markerIdKey);trackdirect.services.callbackExecutor.addWithPriority(marker,marker.showCompleteMarker,[]);if(track&&marker.packet.packet_order_id==1){if(marker.shouldMarkerBeVisible()&&marker.showAsMarker&&this.state.trackStationId!==null&&this.state.trackStationId==marker.packet.station_id&&this.state.getClientTimestamp(marker.packet.timestamp)>oldestAllowedTrackingTimestamp){trackdirect.services.callbackExecutor.addWithPriority(this,this.setCenterByStationId,[marker.packet.station_id]);}}
if(this.state.openInfoWindowForMarkerIdKey!==null&&this.state.openInfoWindowForMarkerIdKey==markerIdKey&&marker.packet.packet_order_id==1&&marker.shouldMarkerBeVisible()&&marker.showAsMarker){trackdirect.services.callbackExecutor.addWithPriority(this,this.openLatestStationInfoWindow,[marker.packet.station_id]);}}
this.state.openInfoWindowForMarkerIdKey=null;};trackdirect.models.Map.prototype.activateFilteredMode=function(){this.state.isFilterMode=true;this._deactivateHeatMap();this._updateMapContent();};trackdirect.models.Map.prototype.deactivateFilteredMode=function(){if(this.state.isFilterMode){this._activateHeatMap();this.state.isFilterMode=false;this.state.filterStationIds=[];this._updateMapContent();}};trackdirect.models.Map.prototype.getNorthEastLat=function(){if(this.getBounds()!=null){if(typeof google==="object"&&typeof google.maps==="object"){return this.getBounds().getNorthEast().lat();}else if(typeof L==="object"){return this.getBounds().getNorthEast().lat;}}
return 0;};trackdirect.models.Map.prototype.getNorthEastLng=function(){if(this.getBounds()!=null){if(typeof google==="object"&&typeof google.maps==="object"){return this.getBounds().getNorthEast().lng();}else if(typeof L==="object"){return this.getBounds().getNorthEast().lng;}}
return 0;};trackdirect.models.Map.prototype.getSouthWestLat=function(){if(this.getBounds()!=null){if(typeof google==="object"&&typeof google.maps==="object"){return this.getBounds().getSouthWest().lat();}else if(typeof L==="object"){return this.getBounds().getSouthWest().lat;}}
return 0;};trackdirect.models.Map.prototype.getSouthWestLng=function(){if(this.getBounds()!=null){if(typeof google==="object"&&typeof google.maps==="object"){return this.getBounds().getSouthWest().lng();}else if(typeof L==="object"){return this.getBounds().getSouthWest().lng;}}
return 0;};trackdirect.models.Map.prototype.isMapReady=function(){if(this.getBounds()!=null){return true;}
return false;};trackdirect.models.Map.prototype.setMapType=function(mapType){if(mapType in this._supportedMapTypes){this._mapType=mapType;if(typeof google==="object"&&typeof google.maps==="object"){this._updateGoogleMapTileLayer();}else if(typeof L==="object"){this._updateLeafletTileLayer();}
this._emitTdEventListeners("change");}};trackdirect.models.Map.prototype.getMapType=function(){return this._mapType;};trackdirect.models.Map.prototype.getLeafletTileLayer=function(){return this._leafletTileLayer;};trackdirect.models.Map.prototype.getMid=function(){if(typeof this._tdMapOptions.mid!=="undefined"){return this._tdMapOptions.mid;}
return null;};trackdirect.models.Map.prototype.resetAllMarkers=function(){while(this.markerCollection.getNumberOfMarkers()>0){var i=this.markerCollection.getNumberOfMarkers();while(i--){var marker=this.markerCollection.getMarker(i);if(marker!==null){marker.stopToOldTimeout();marker.stopDirectionPolyline();marker.hide();marker.hideMarkerPrevPosition();marker.hideMarkerTail();var stationCoverage=this.markerCollection.getStationCoverage(marker.packet.station_id);if(stationCoverage){stationCoverage.hide();}}
this.markerCollection.removeMarker(i);}}
if(this.state.openInfoWindow!==null){this.state.openInfoWindow.hide();}
if(this.oms){this.oms.clearMarkers();}
this.markerCollection.resetAllMarkers();};trackdirect.models.Map.prototype.openMarkerInfoWindow=function(marker,disableAutoPan){disableAutoPan=typeof disableAutoPan!=="undefined"?disableAutoPan:true;if(marker.getMap()!==null){if(this.state.openInfoWindow!==null&&this.state.openInfoWindow.getMarker().packet.id!=marker.packet.id){this.state.openInfoWindow.hide();}
if(this.state.openInfoWindow!==null&&this.state.openInfoWindow.getMarker().packet.id==marker.packet.id){this.state.openInfoWindow.setMarker(marker);}else{this.state.openInfoWindow=new trackdirect.models.InfoWindow(marker,this,disableAutoPan);}
this._addInfoWindowListeners(this.state.openInfoWindow);this.state.openInfoWindow.show();}};trackdirect.models.Map.prototype.openLatestStationInfoWindow=function(stationId){var latestVisibleMarker=this.markerCollection.getStationLatestVisibleMarker(stationId);if(latestVisibleMarker!==null){this.openMarkerInfoWindow(latestVisibleMarker);}};trackdirect.models.Map.prototype.openPolylineInfoWindow=function(marker,position){if(this.state.openInfoWindow!==null){this.state.openInfoWindow.hide();}
this.state.openInfoWindow=new trackdirect.models.InfoWindow(marker,this);this._addInfoWindowListeners(this.state.openInfoWindow);this.state.openInfoWindow.show(true,position);};trackdirect.models.Map.prototype._addInfoWindowListeners=function(infoWindow){var me=this;infoWindow.addTdListener("station-tail-needed",function(stationId){me._emitTdEventListeners("station-tail-needed",stationId);});};(trackdirect.models.Map.prototype.addTdListener=function(event,handler){if(!(event in this._tdEventListeners)){this._tdEventListeners[event]=[];}
this._tdEventListeners[event].push(handler);}),(trackdirect.models.Map.prototype._emitTdEventListeners=function(event,arg){if(event in this._tdEventListeners){for(var i=0;i0){this.overlayMapTypes.clear();}}else if(typeof L==="object"){if(this._heatMap!==null){this.removeLayer(this._heatMap);}}});trackdirect.models.Map.prototype._activateHeatMap=function(){if(typeof google==="object"&&typeof google.maps==="object"){if(typeof this.overlayMapTypes!=="undefined"&&this.overlayMapTypes.length==0){this.overlayMapTypes.setAt(0,this._heatMap);}}else if(typeof L==="object"){if(this._heatMap!==null){this._heatMap.addTo(this);this._heatMap.bringToFront();this._heatMap.setZIndex(1000);}}};trackdirect.models.Map.prototype._updateGoogleMapTileLayer=function(){this.setMapTypeId(this._supportedMapTypes[this._mapType]);};trackdirect.models.Map.prototype._updateLeafletTileLayer=function(){if(typeof windyInit!=="function"){if(this._leafletTileLayer!==null){this._leafletTileLayer.remove();}
if(typeof L.mapboxGL==="function"){var attribution="";var accessToken="no-token";var style="";if("mapboxGLStyle"in this._tdMapOptions){style=this._tdMapOptions["mapboxGLStyle"];}
if("mapboxGLAccessToken"in this._tdMapOptions){accessToken=this._tdMapOptions["mapboxGLAccessToken"];}
if("mapboxGLAttribution"in this._tdMapOptions){attribution=this._tdMapOptions["mapboxGLAttribution"];}
this._leafletTileLayer=L.mapboxGL({accessToken:accessToken,style:style,});this.addLayer(this._leafletTileLayer);this.attributionControl.addAttribution(attribution);}else{var options={};if(isHighDensity()){options["ppi"]="320";options["size"]="512";}else if(trackdirect.isMobile){options["ppi"]="250";}
this._leafletTileLayer=L.tileLayer.provider(this._supportedMapTypes[this._mapType],options);this.addLayer(this._leafletTileLayer);this._leafletTileLayer.bringToBack();}}};trackdirect.models.Map.prototype._updateMapContent=function(){if(this.getBounds()!=null){var previousVisibleMapSectors=[];for(var i=0;i=trackdirect.settings.minZoomForMarkerPrevPosition&&this._currentContentZoom=trackdirect.settings.minZoomForMarkerTail&&this._currentContentZoom=trackdirect.settings.minZoomForMarkerLabel&&this._currentContentZoom=trackdirect.settings.minZoomForMarkerPrevPosition;var hideMarkerTail=this.getZoom()=trackdirect.settings.minZoomForMarkerTail;var hideMarkerLabel=this.getZoom()=trackdirect.settings.minZoomForMarkerLabel;if(hidePrevPosition||hideMarkerTail||hideMarkerLabel){return true;}
return false;};trackdirect.models.Map.prototype._showVisibleMarkerDetails=function(){for(var i=0;i=trackdirect.settings.minZoomForMarkers){if(this.state.isFilterMode){for(var markerIdKey in this.markerCollection.getAllMarkers()){if(this.markerCollection.isExistingMarker(markerIdKey)){var marker=this.markerCollection.getMarker(markerIdKey);if(marker.showAsMarker&&marker.packet.phg!=null&&marker.getMap()!==null&&marker.shouldMarkerBeVisible()){if(this.state.showPHGCircles==0){marker.hidePHGCircle();}else if(this.state.showPHGCircles==1){marker.showPHGCircle(true);}else if(this.state.showPHGCircles==2){marker.showPHGCircle(false);}}}}}else{for(var i=0;i=trackdirect.settings.minZoomForMarkers){if(this.state.isFilterMode){for(var markerIdKey in this.markerCollection.getAllMarkers()){if(this.markerCollection.isExistingMarker(markerIdKey)){var marker=this.markerCollection.getMarker(markerIdKey);if(marker.showAsMarker&&marker.packet.rng!=null&&marker.getMap()!==null&&marker.shouldMarkerBeVisible()){if(this.state.showRNGCircles==0){marker.hideRNGCircle();}else if(this.state.showRNGCircles==1){marker.showRNGCircle(true);}else if(this.state.showRNGCircles==2){marker.showRNGCircle(false);}}}}}else{for(var i=0;i1){for(var markerIdKey in this.markerCollection.getPositionMarkerIdKeys(latitude,longitude)){var marker=this.markerCollection.getMarker(markerIdKey);if(marker!==null&&marker.shouldMarkerBeVisible()){if(marker.getZIndex()>topMarkerZindex){topMarkerZindex=marker.getZIndex();topMarkerIdKey=markerIdKey;}
marker.hideLabel();marker.hasLabel=false;}}
if(topMarkerIdKey!=-1){var topMarker=this.markerCollection.getMarker(topMarkerIdKey);topMarker.hasLabel=true;var topMarkerMapSector=trackdirect.services.MapSectorCalculator.getMapSector(topMarker.getPositionLiteral().lat,topMarker.getPositionLiteral().lng);if(this.state.isFilterMode){topMarker.showLabel();}else if(this.isMapSectorVisible(topMarkerMapSector)&&this.getZoom()>=trackdirect.settings.minZoomForMarkerLabel){topMarker.showLabel();}}}};trackdirect.models.Map.prototype._hideMarkersInPreviousVisibleMapSectors=function(previousVisibleMapSectors){if(this._currentContentZoom>=trackdirect.settings.minZoomForMarkers){var markerIdKeyListToMaybeHide={};var markerIdKeyListNotToHide={};for(var i=0;i=trackdirect.settings.minZoomForMarkers){var mapSectorMarkerKeys=this.markerCollection.getMapSectorMarkerKeys(mapSector);for(var j=0;j=trackdirect.settings.minZoomForMarkers){for(var i=0;i=-90&&lng<=180&&lng>=-180){var content="";content+=this._getGpsDegreeFromGpsDecimal(lat.toFixed(5),"lat");content+=" "+this._getGpsDegreeFromGpsDecimal(lng.toFixed(5),"lon");content+="
"+lat.toFixed(5)+", "+lng.toFixed(5);content+="
"+this._getMaidenheadLocatorFromGpsDecimal(lat,lng);$("#"+options.cordinatesContainer).html(content);}};trackdirect.models.Map.prototype._getGpsDegreeFromGpsDecimal=function(dms,type){var sign=1,Abs=0;var days,minutes,secounds,direction;if(dms<0){sign=-1;}
Abs=Math.abs(Math.round(dms*1000000));if(type=="lat"&&Abs>90*1000000){return false;}else if(type=="lon"&&Abs>180*1000000){return false;}
days=Math.floor(Abs/1000000);minutes=Math.floor((Abs/1000000-days)*60);secounds=((Math.floor(((Abs/1000000-days)*60-minutes)*100000)*60)/
100000).toFixed();days=days*sign;if(type=="lat")direction=days<0?"S":"N";if(type=="lon")direction=days<0?"W":"E";return days*sign+"º "+minutes+"' "+secounds+"'' "+direction;};trackdirect.models.Map.prototype._getMaidenheadLocatorFromGpsDecimal=function(lat,lng,){const chars='ABCDEFGHIJKLMNOPQRSTUVX';var result='';lng=lng+180;lat=lat+90;result=chars.charAt(parseInt(lng/20));result+=chars.charAt(parseInt(lat/10));result+=parseInt(lng/2%10);result+=parseInt(lat%10);lng_r=(lng-parseInt(lng/2)*2)*60;lat_r=(lat-parseInt(lat))*60;result+=chars.charAt(parseInt(lng_r/5));result+=chars.charAt(parseInt(lat_r/2.5));return result;};
if(typeof google==="object"&&typeof google.maps==="object"){trackdirect.models.Label=function(options,map){this._defaultMap=map;options.map=null;this.setValues(options);this.div_=null;};trackdirect.models.Label.prototype=new google.maps.OverlayView();trackdirect.models.Label.prototype.show=function(){if(typeof this.getMap()==="undefined"||this.getMap()===null){this.setMap(this._defaultMap);}};trackdirect.models.Label.prototype.hide=function(){if(this.getMap()!==null){this.setMap(null);}};trackdirect.models.Label.prototype.onAdd=function(){if(this.div_===null){var jqSpan=$(document.createElement("span"));jqSpan.css("color","#101010");jqSpan.css("text-shadow","1px 1px 1px #FFF, -1px -1px 1px #FFF, 1px -1px 1px #FFF, -1px 1px 1px #FFF, 1px 1px 1px #FFF");jqSpan.css("position","relative");jqSpan.css("top","10px");jqSpan.css("white-space","nowrap");jqSpan.css("font-family","Helvetica");jqSpan.css("font-weight","bold");jqSpan.css("font-size","10px");jqSpan.css("padding","0px");jqSpan.css("z-index","1000");jqSpan.css("margin","0");jqSpan.css("line-height","10px");var span=(this.span_=jqSpan[0]);span.innerHTML=this.get("text").toString();var div=(this.div_=document.createElement("div"));div.appendChild(span);div.style.cssText="position: absolute; display: none";}
var pane=this.getPanes().overlayLayer;pane.appendChild(this.div_);var me=this;this.listeners_=[google.maps.event.addListener(this,"position_changed",function(){me.draw();}),google.maps.event.addListener(this,"text_changed",function(){me.draw();}),];};trackdirect.models.Label.prototype.onRemove=function(){if(this.div_!==null&&this.div_.parentNode!==null){this.div_.parentNode.removeChild(this.div_);for(var i=0,I=this.listeners_.length;i0){if($(window).height()>=300){packetDiv.append(this._getPacketPathDiv());}
var phgRange=this._marker.packet.getPHGRange();var rngRange=this._marker.packet.getRNGRange();if(phgRange!==null||rngRange!==null){packetDiv.append(this._getSpaceDiv());packetDiv.append(this._getPhgDiv(phgRange));packetDiv.append(this._getRngDiv(rngRange));}
if($(window).height()>=300){var transmitDistance=this._getTransmitDistance(this._marker.packet);var tailDistance=this._getTailDistance(this._defaultMap.markerCollection.getMarkerMasterMarkerKeyId(this._marker.markerIdKey));if((transmitDistance!==null&&Math.round(transmitDistance/100)!=0)||(tailDistance!==null&&Math.round(tailDistance)>0)){packetDiv.append(this._getSpaceDiv());packetDiv.append(this._getTransmitDistanceDiv(transmitDistance));packetDiv.append(this._getTailDistanceDiv(tailDistance));}}
if(this._marker.packet.speed!==null||this._marker.packet.course!==null||this._marker.packet.altitude!==null){packetDiv.append(this._getSpaceDiv());packetDiv.append(this._getPacketSpeedAltitudeCourseDiv());}
if(typeof this._marker.packet.weather!=="undefined"&&this._marker.packet.weather!==null){packetDiv.append(this._getSpaceDiv());packetDiv.append(this._getWeatherDiv());}
if(typeof this._marker.packet.latest_telemetry_packet_timestamp!=="undefined"&&this._marker.packet.latest_telemetry_packet_timestamp!==null){packetDiv.append(this._getSpaceDiv());packetDiv.append(this._getTelemetryDiv());}
var commentDiv=this._getPacketCommentDiv();if(commentDiv!=null){packetDiv.append(this._getSpaceDiv());packetDiv.append(commentDiv);}}
return packetDiv;};trackdirect.models.InfoWindow.prototype._getPacketTimeDiv=function(){if(this._marker.packet.timestamp==0){dateString='No known packet for specified limits.';}else{var date=new Date(this._marker.packet.timestamp*1000);var dateString=moment(date).format(trackdirect.settings.dateFormatNoTimeZone);if(this._marker.packet.timestamp>this._marker.packet.position_timestamp&&!trackdirect.isMobile){var positionDate=new Date(this._marker.packet.position_timestamp*1000);dateString=moment(positionDate).format(trackdirect.settings.dateFormatNoTimeZone)+
" - "+
moment(date).format(trackdirect.settings.dateFormatNoTimeZone);}
if(this._defaultMap.state.endTimeTravelTimestamp!==null&&this._marker.packet.map_id==12){dateString+='
(exact time for this is not known)';}}
var timeDiv=$(document.createElement("div"));timeDiv.css("clear","both");timeDiv.html(dateString);return timeDiv;};trackdirect.models.InfoWindow.prototype._getPacketPathDiv=function(){var rawPath=this._marker.packet.getLinkifiedRawPath();if(rawPath!==null){var rawPathDiv=$(document.createElement("div"));rawPathDiv.css("clear","both");rawPathDiv.html("["+rawPath+"]");return rawPathDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getSpaceDiv=function(){var spaceDiv=$(document.createElement("div"));spaceDiv.css("clear","both");spaceDiv.css("line-height","4px");spaceDiv.html(" ");return spaceDiv;};trackdirect.models.InfoWindow.prototype._getPhgDiv=function(phgRange){if(phgRange!==null){if(this._defaultMap.state.useImperialUnit){var phgRange=Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(phgRange/1000)*10)/10;var phgRangeUnit="miles";}else{var phgRange=Math.round(phgRange/10)/100;var phgRangeUnit="km";}
var phgDiv=$(document.createElement("div"));phgDiv.attr("id","phglinks-"+
this._marker.packet.station_id+
"-"+
this._marker.packet.id);var halfPhgLink=$("Half");var fullPhgLink=$("Full");var nonePhgLink=$("None");phgDiv.css("clear","both");phgDiv.css("display","none");phgDiv.css("color","#440B2A");phgDiv.append("PHG calculated range: "+phgRange+" "+phgRangeUnit);if(typeof L==="object"&&L.version<="0.7.7"){return phgDiv;}
if(phgRange>0){phgDiv.append("
");phgDiv.append("PHG circle: ");phgDiv.append(fullPhgLink);phgDiv.append(' - ');phgDiv.append(halfPhgLink);phgDiv.append(' - ');phgDiv.append(nonePhgLink);}
return phgDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getRngDiv=function(rngRange){if(rngRange!==null){if(this._defaultMap.state.useImperialUnit){var rngRange=Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(rngRange/1000)*10)/10;var rngRangeUnit="miles";}else{var rngRange=Math.round(rngRange*100)/100;var rngRangeUnit="km";}
var rngDiv=$(document.createElement("div"));rngDiv.attr("id","rnglinks-"+
this._marker.packet.station_id+
"-"+
this._marker.packet.id);var halfRngLink=$("Half");var fullRngLink=$("Full");var noneRngLink=$("None");rngDiv.css("clear","both");rngDiv.css("display","none");rngDiv.css("color","#440B2A");rngDiv.append("RNG precalculated range: "+rngRange+" "+rngRangeUnit);if(typeof L==="object"&&L.version<="0.7.7"){return rngDiv;}
if(rngRange>0){rngDiv.append("
");rngDiv.append("RNG circle: ");rngDiv.append(fullRngLink);rngDiv.append(' - ');rngDiv.append(halfRngLink);rngDiv.append(' - ');rngDiv.append(noneRngLink);}
return rngDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getTransmitDistanceDiv=function(transmitDistance){if(transmitDistance!==null&&Math.round(transmitDistance/100)!=0){var transmitDistanceDiv=$(document.createElement("div"));transmitDistanceDiv.css("clear","both");transmitDistanceDiv.css("color","#273c20");if(this._defaultMap.state.useImperialUnit){transmitDistance=Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(transmitDistance/1000)*10)/10;transmitDistanceUnit="miles";}else{transmitDistance=Math.round(transmitDistance/100)/10;transmitDistanceUnit="km";}
transmitDistanceDiv.append('Transmit distance: '+
transmitDistance+
" "+
transmitDistanceUnit+
"");return transmitDistanceDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getTailDistanceDiv=function(tailDistance){if(tailDistance!==null&&Math.round(tailDistance)>0){var distanceDiv=$(document.createElement("div"));distanceDiv.css("clear","both");distanceDiv.css("color","#273c20");if(tailDistance<1000){if(this._defaultMap.state.useImperialUnit){tailDistance=Math.round(trackdirect.services.imperialConverter.convertMeterToYard(tailDistance));tailDistanceUnit="yd";}else{tailDistance=Math.round(tailDistance);tailDistanceUnit="m";}}else{if(this._defaultMap.state.useImperialUnit){tailDistance=Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(tailDistance/1000)*10)/10;tailDistanceUnit="miles";}else{tailDistance=Math.round(tailDistance/100)/10;tailDistanceUnit="km";}}
distanceDiv.append('Current tail distance: '+
tailDistance+
" "+
tailDistanceUnit+
"");return distanceDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getPacketSpeedAltitudeCourseDiv=function(){if(Math.round(this._marker.packet.speed)!=0||Math.round(this._marker.packet.course)!=0||Math.round(this._marker.packet.altitude)!=0){var speedDiv=$(document.createElement("div"));speedDiv.css("clear","both");speedDiv.css("font-weight","bold");if(this._marker.packet.speed!==null){if(this._defaultMap.state.useImperialUnit){speedDiv.append(Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(this._marker.packet.speed))+" mph ");}else{speedDiv.append(Math.round(this._marker.packet.speed)+" km/h ");}}
if(this._marker.packet.course!==null){speedDiv.append(Math.round(this._marker.packet.course)+"° ");}
if(this._marker.packet.altitude!==null){if(this._defaultMap.state.useImperialUnit){speedDiv.append(" alt "+
Math.round(trackdirect.services.imperialConverter.convertMeterToFeet(this._marker.packet.altitude))+
" ft ");}else{speedDiv.append(" alt "+Math.round(this._marker.packet.altitude)+" m ");}}
return speedDiv;}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDivRainString=function(){if(isNumeric(this._marker.packet.weather.rain_1h)){if(this._defaultMap.state.useImperialUnit){var rain1h="-";if(isNumeric(this._marker.packet.weather.rain_1h)){rain1h=Math.round(trackdirect.services.imperialConverter.convertMmToInch(this._marker.packet.weather.rain_1h))+"in";}
var rain24h="-";if(isNumeric(this._marker.packet.weather.rain_24h)){rain24h=Math.round(trackdirect.services.imperialConverter.convertMmToInch(this._marker.packet.weather.rain_24h))+"in";}
var rainSinceMidnight="-";if(isNumeric(this._marker.packet.weather.rain_since_midnight)){rainSinceMidnight=Math.round(trackdirect.services.imperialConverter.convertMmToInch(this._marker.packet.weather.rain_since_midnight))+"in";}}else{var rain1h="-";if(isNumeric(this._marker.packet.weather.rain_1h)){rain1h=Math.round(this._marker.packet.weather.rain_1h)+"mm";}
var rain24h="-";if(isNumeric(this._marker.packet.weather.rain_24h)){rain24h=Math.round(this._marker.packet.weather.rain_24h)+"mm";}
var rainSinceMidnight="-";if(isNumeric(this._marker.packet.weather.rain_since_midnight)){rainSinceMidnight=Math.round(this._marker.packet.weather.rain_since_midnight)+"mm";}}
return("Rain "+
rain1h+
"/"+
rain24h+
"/"+
rainSinceMidnight+
" (1h/24h/midnight)
");}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDivTemperatureString=function(){if(isNumeric(this._marker.packet.weather.temperature)){if(this._defaultMap.state.useImperialUnit){return("Temperature "+
Math.round(trackdirect.services.imperialConverter.convertCelciusToFahrenheit(this._marker.packet.weather.temperature))+
"°F"+
"
");}else{return("Temperature "+
Math.round(this._marker.packet.weather.temperature)+
"°C"+
"
");}}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDivHumidityString=function(){if(isNumeric(this._marker.packet.weather.humidity)){return("Humidity "+
Math.round(this._marker.packet.weather.humidity)+
"%
");}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDivPressureString=function(){if(isNumeric(this._marker.packet.weather.pressure)){if(this._defaultMap.state.useImperialUnit){return("Pressure "+
Math.round(trackdirect.services.imperialConverter.convertMbarToMmhg(this._marker.packet.weather.pressure))+
" mmHg
");}else{return("Pressure "+
Math.round(this._marker.packet.weather.pressure)+
" hPa
");}}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDivWindString=function(){if(isNumeric(this._marker.packet.weather.wind_speed)){var windDir="";if(typeof this._marker.packet.weather.wind_direction!=="undefined"&&isNumeric(this._marker.packet.weather.wind_direction)){windDir=this._marker.packet.weather.wind_direction.toString()+"° ";}
if(this._defaultMap.state.useImperialUnit){if(isNumeric(this._marker.packet.weather.wind_gust)){return("Wind "+
windDir+
Math.round(trackdirect.services.imperialConverter.convertMpsToMph(this._marker.packet.weather.wind_speed)*10)/
10+
" mph"+
" ("+
Math.round(trackdirect.services.imperialConverter.convertMpsToMph(this._marker.packet.weather.wind_gust)*10)/
10+
" mph)
");}else{return("Wind "+
windDir+
Math.round(trackdirect.services.imperialConverter.convertMpsToMph(this._marker.packet.weather.wind_speed)*10)/
10+
" mph
");}}else{if(isNumeric(this._marker.packet.weather.wind_gust)){return("Wind "+
windDir+
Math.round(this._marker.packet.weather.wind_speed*10)/10+
" m/s"+
" ("+
Math.round(this._marker.packet.weather.wind_gust*10)/10+
" m/s)
");}else{return("Wind "+
windDir+
Math.round(this._marker.packet.weather.wind_speed*10)/10+
" m/s
");}}}
return null;};trackdirect.models.InfoWindow.prototype._getWeatherDiv=function(){var weatherDiv=$(document.createElement("div"));weatherDiv.css("clear","both");weatherDiv.css("color","#227152");var weatherDate=new Date(this._marker.packet.timestamp*1000);if(typeof this._marker.packet.weather.timestamp!=="undefined"&&this._marker.packet.weather.timestamp!==null){weatherDate=new Date(this._marker.packet.weather.timestamp*1000);}
weatherDateString=moment(weatherDate).format(trackdirect.settings.dateFormatNoTimeZone);weatherDiv.append("Latest Weather "+weatherDateString+"
");if(!trackdirect.isMobile&&$(window).height()>=300){weatherDiv.append(this._getWeatherDivTemperatureString());weatherDiv.append(this._getWeatherDivHumidityString());weatherDiv.append(this._getWeatherDivPressureString());weatherDiv.append(this._getWeatherDivRainString());weatherDiv.append(this._getWeatherDivWindString());}
return weatherDiv;};trackdirect.models.InfoWindow.prototype._getTelemetryDiv=function(){var telemetryDiv=$(document.createElement("div"));telemetryDiv.css("clear","both");telemetryDiv.css("color","#823030");var telemetryDate=new Date(this._marker.packet.latest_telemetry_packet_timestamp*1000);telemetryDateString=moment(telemetryDate).format(trackdirect.settings.dateFormatNoTimeZone);telemetryDiv.append("Latest Telemetry "+telemetryDateString+"
");return telemetryDiv;};trackdirect.models.InfoWindow.prototype._getPacketCommentDiv=function(){var comment="";var ognSummary=escapeHtml(this._marker.packet.getOgnSummary());if(ognSummary!=""){comment=ognSummary;}else if(typeof this._marker.packet.comment!=="undefined"&&this._marker.packet.comment!==null){comment=Autolinker.link(escapeHtml(this._marker.packet.comment),{newWindow:true,});}
if(comment==""){return null;}
var commentDiv=$(document.createElement("div"));commentDiv.css("clear","both");commentDiv.css("font-weight","bold");if(!trackdirect.isMobile){commentDiv.css("font-size","11px");}else{commentDiv.css("font-size","10px");}
commentDiv.html(comment);return commentDiv;};trackdirect.models.InfoWindow.prototype._addPhgLinkListeners=function(){var marker=this._marker;$("#half-phg-"+marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.showPHGCircle(true);return false;});$("#full-phg-"+marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.showPHGCircle(false);return false;});$("#none-phg-"+this._marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.hidePHGCircle();return false;});if($("#phglinks-"+marker.packet.station_id+"-"+marker.packet.id).length){$("#phglinks-"+marker.packet.station_id+"-"+marker.packet.id).show();}};trackdirect.models.InfoWindow.prototype._addRngLinkListeners=function(){var marker=this._marker;$("#half-rng-"+marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.showRNGCircle(true);return false;});$("#full-rng-"+marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.showRNGCircle(false);return false;});$("#none-rng-"+marker.packet.station_id+"-"+marker.packet.id).click(function(e){marker.hideRNGCircle();return false;});if($("#rnglinks-"+marker.packet.station_id+"-"+marker.packet.id).length){$("#rnglinks-"+marker.packet.station_id+"-"+marker.packet.id).show();}};trackdirect.models.InfoWindow.prototype._getMenuDiv=function(isInfoWindowOpen){var menuWrapperDiv=this._getMenuDivWrapperDiv();var menuDiv=this._getMenuDivMainDiv();menuWrapperDiv.append(menuDiv);var menuUl=this._getMenuDivUlDiv();menuDiv.append(menuUl);menuUl.append(this._getMenuDivTrackLink());menuUl.append(this._getMenuDivFilterLink());if(!trackdirect.isMobile){menuUl.append(this._getMenuDivCenterLink(isInfoWindowOpen));}
menuUl.append(this._getMenuDivZoomLink(isInfoWindowOpen));if(!trackdirect.isEmbedded&&!inIframe()&&!this._marker.isMovingStation()&&this._marker.packet.source_id!=2){menuUl.append(this._getMenuDivCoverageLink());}
return menuWrapperDiv;};trackdirect.models.InfoWindow.prototype._getMenuDivWrapperDiv=function(){var menuWrapperDiv=$(document.createElement("div"));menuWrapperDiv.addClass("infowindow-menu-wrapper");menuWrapperDiv.css("clear","both");menuWrapperDiv.css("width","100%");menuWrapperDiv.css("padding-top","8px");return menuWrapperDiv;};trackdirect.models.InfoWindow.prototype._getMenuDivMainDiv=function(){var menuDiv=$(document.createElement("div"));menuDiv.addClass("infowindow-menu");menuDiv.css("width","100%");menuDiv.css("border-top","1px solid #cecece");return menuDiv;};trackdirect.models.InfoWindow.prototype._getMenuDivUlDiv=function(){var menuUl=$(document.createElement("ul"));menuUl.css("list-style-type","none");menuUl.css("list-style","none");menuUl.css("text-align","center");menuUl.css("margin","0");menuUl.css("padding","0");menuUl.css("display","table");return menuUl;};trackdirect.models.InfoWindow.prototype._getMenuDivLinkCss=function(){var liLinkCss={"list-style":"none",display:"table-cell","text-align":"center","padding-right":"10px",width:"auto",};return liLinkCss;};trackdirect.models.InfoWindow.prototype._getMenuDivTrackLink=function(){var trackLinkElementClass="trackStationLink"+this._marker.packet.station_id;var menuLi=$(document.createElement("li"));menuLi.css(this._getMenuDivLinkCss());var menuLink=$(document.createElement("a"));menuLink.css("color","#337ab7");menuLink.attr("href","#");menuLink.addClass(trackLinkElementClass);menuLink.attr("onclick","trackdirect.handleTrackStationRequest("+
this._marker.packet.station_id+
', "'+
trackLinkElementClass+
'"); return false;');if(this._defaultMap.state.getTrackStationId()!==null&&this._defaultMap.state.getTrackStationId()==this._marker.packet.station_id){menuLink.html("Untrack");}else{menuLink.html("Track");}
menuLi.append(menuLink);return menuLi;};trackdirect.models.InfoWindow.prototype._getMenuDivFilterLink=function(){var filterLinkElementClass="filterStationLink"+this._marker.packet.station_id;var menuLi=$(document.createElement("li"));menuLi.css(this._getMenuDivLinkCss());var menuLink=$(document.createElement("a"));menuLink.css("color","#337ab7");menuLink.addClass(filterLinkElementClass);menuLink.attr("onclick","trackdirect.handleFilterStationRequest("+
this._marker.packet.station_id+
', "'+
filterLinkElementClass+
'"); return false;');if(this._defaultMap.state.filterStationIds.length>0&&this._defaultMap.state.filterStationIds.indexOf(this._marker.packet.station_id)>-1){menuLink.html("Unfilter");var center=this._defaultMap.getCenterLiteral();menuLink.attr("href","/center/"+
Number.parseFloat(center.lat).toFixed(5)+
","+
Number.parseFloat(center.lng).toFixed(5)+
"/zoom/"+
this._defaultMap.getZoom());}else{menuLink.html("Filter");menuLink.attr("href","/sid/"+this._marker.packet.station_id);}
menuLi.append(menuLink);return menuLi;};trackdirect.models.InfoWindow.prototype._getMenuDivCoverageLink=function(){var coverageLinkElementClass="stationCoverageLink"+this._marker.packet.station_id;var menuLi=$(document.createElement("li"));menuLi.css(this._getMenuDivLinkCss());var menuLink=$(document.createElement("a"));menuLink.css("color","#337ab7");menuLink.css("white-space","nowrap");menuLink.attr("href","#");menuLink.addClass(coverageLinkElementClass);menuLink.attr("onclick","trackdirect.toggleStationCoverage("+
this._marker.packet.station_id+
', "'+
coverageLinkElementClass+
'"); return false;');var coveragePolygon=this._defaultMap.markerCollection.getStationCoverage(this._marker.packet.station_id);if(coveragePolygon!==null&&coveragePolygon.isRequestedToBeVisible()){menuLink.html("Hide Coverage");}else{menuLink.html("Coverage");}
menuLi.append(menuLink);return menuLi;};trackdirect.models.InfoWindow.prototype._getMenuDivCenterLink=function(isInfoWindowOpen){var menuLi=$(document.createElement("li"));menuLi.css(this._getMenuDivLinkCss());var menuLink=$(document.createElement("a"));menuLink.css("color","#337ab7");if(isInfoWindowOpen){menuLink.attr("href","/center/"+
this._marker.packet.latitude.toFixed(5)+
","+
this._marker.packet.longitude.toFixed(5)+
"/zoom/"+
this._defaultMap.getZoom());menuLink.attr("onclick","trackdirect.setCenter("+
this._marker.packet.latitude+
","+
this._marker.packet.longitude+
"); return false;");menuLink.html("Center");}else{menuLink.attr("href","/center/"+
this._marker.packet.latitude.toFixed(5)+
","+
this._marker.packet.longitude.toFixed(5)+
"/zoom/"+
this._defaultMap.getZoom());menuLink.attr("onclick","trackdirect.focusOnMarkerId("+
this._marker.packet.marker_id+
"); return false;");menuLink.html("Focus");}
menuLi.append(menuLink);return menuLi;};trackdirect.models.InfoWindow.prototype._getMenuDivZoomLink=function(isInfoWindowOpen){var menuLi=$(document.createElement("li"));menuLi.css(this._getMenuDivLinkCss());var menuLink=$(document.createElement("a"));menuLink.css("color","#337ab7");if(isInfoWindowOpen){menuLink.attr("href","/center/"+
this._marker.packet.latitude.toFixed(5)+
","+
this._marker.packet.longitude.toFixed(5)+
"/zoom/14");menuLink.attr("onclick","trackdirect.setCenter("+
this._marker.packet.latitude+
","+
this._marker.packet.longitude+
", 14); return false;");menuLink.html("Zoom");}else{menuLink.attr("href","/center/"+
this._marker.packet.latitude.toFixed(5)+
","+
this._marker.packet.longitude.toFixed(5)+
"/zoom/14");menuLink.attr("onclick","trackdirect.focusOnMarkerId("+
this._marker.packet.marker_id+
", 14); return false;");menuLink.html("Zoom");}
menuLi.append(menuLink);return menuLi;};trackdirect.models.InfoWindow.prototype._getCompactMainDiv=function(){var packet=this._marker.packet;var mainDiv=$(document.createElement("div"));mainDiv.css("font-family","Verdana,Arial,sans-serif");if(!trackdirect.isMobile){mainDiv.css("font-size","11px");}else{mainDiv.css("font-size","10px");}
mainDiv.css("line-height","1.42857143");mainDiv.css("color","#333");mainDiv.css("text-align","left");var polylineDiv=$(document.createElement("div"));polylineDiv.css("float","left");var nameDiv=$(document.createElement("div"));nameDiv.css("clear","both");nameDiv.css("font-size","12px");nameDiv.css("font-weight","bold");var iconUrl24=trackdirect.services.symbolPathFinder.getFilePath(packet.symbol_table,packet.symbol,null,null,null,24,24);var iconImg=$(document.createElement("img"));iconImg.css("vertical-align","middle");iconImg.css("width","24px");iconImg.css("height","24px");iconImg.attr("src",iconUrl24);iconImg.attr("alt","");iconImg.attr("title","");nameDiv.append(iconImg);nameDiv.append(" ");nameDiv.append(" ");var nameLink=$(document.createElement("a"));nameLink.css("color","#337ab7");if(trackdirect.isMobile){nameLink.css("vertical-align","-2px");}
nameLink.attr("href","");nameLink.attr("onclick","trackdirect.openStationInformationDialog("+
packet.station_id+
"); return false;");nameLink.html(escapeHtml(packet.station_name));nameDiv.append(nameLink);if(packet.sender_name!=packet.station_name){nameDiv.append(" (");var nameLink2=$(document.createElement("span"));if(trackdirect.isMobile){nameLink2.css("vertical-align","-2px");}
nameLink2.html(escapeHtml(packet.sender_name));nameDiv.append(nameLink2);nameDiv.append(")");}
polylineDiv.append(nameDiv);var tailDistance=this._getTailDistance(this._defaultMap.markerCollection.getMarkerMasterMarkerKeyId(this._marker.markerIdKey));if(tailDistance!==null&&Math.round(tailDistance)>0){var distanceDiv=$(document.createElement("div"));distanceDiv.css("clear","both");distanceDiv.css("padding-top","4px");distanceDiv.append("Tail distance: ");if(tailDistance<1000){if(this._defaultMap.state.useImperialUnit){distanceDiv.append(Math.round(trackdirect.services.imperialConverter.convertMeterToYard(tailDistance))+" yd ");}else{distanceDiv.append(Math.round(tailDistance)+" m ");}}else{if(this._defaultMap.state.useImperialUnit){distanceDiv.append(Math.round(trackdirect.services.imperialConverter.convertKilometerToMile(tailDistance/1000)*10)/
10+
" miles ");}else{distanceDiv.append(Math.round(tailDistance/100)/10+" km ");}}
polylineDiv.append(distanceDiv);}
mainDiv.append(polylineDiv);return mainDiv;};trackdirect.models.InfoWindow.prototype._getTailDistance=function(markerIdKey){if(this._defaultMap.markerCollection.isExistingMarker(markerIdKey)){var marker=this._defaultMap.markerCollection.getMarker(markerIdKey);if(marker.packet.hasConfirmedMapId()&&marker.packet.is_moving==1&&marker.overwrite!==true){var distance=0;if(this._defaultMap.markerCollection.hasDotMarkers(markerIdKey)){var prevLatLng=null;var dotMarkers=this._defaultMap.markerCollection.getDotMarkers(markerIdKey);for(var i=0;i=1){var relatedStationLatLng={lat:parseFloat(packet.station_location_path[0][0]),lng:parseFloat(packet.station_location_path[0][1]),};var distance=trackdirect.services.distanceCalculator.getDistance(packet.getLatLngLiteral(),relatedStationLatLng);if(distance!==null){return distance;}}
if(typeof packet.station_id_path!=="undefined"&&packet.station_id_path!==null&&packet.station_id_path.length>=1){for(var i=0;itrackdirect.settings.minZoomForMarkers-1){return trackdirect.settings.baseUrl+"/heatmaps/transparent.png";}
var normalizedCoord=me._getNormalizedCoord(coord,zoom);if(!normalizedCoord){return trackdirect.settings.baseUrl+"/heatmaps/transparent.png";}
var xString=String(normalizedCoord.x);var yString=String(normalizedCoord.y);return me._getUrlTemplate().replace("{z}",zoom).replace("{y}",yString).replace("{x}",xString);},tileSize:new google.maps.Size(256,256),maxZoom:9,minZoom:0,radius:1738000,name:"APRSHEAT",};return options;};trackdirect.models.HeatMap.prototype._getUrlTemplate=function(){return(trackdirect.settings.baseUrl+
"/heatmaps/latest-heatmap.{z}.{y}.{x}.png?version="+
this._getHeatMapVersion());};trackdirect.models.HeatMap.prototype._getHeatMapVersion=function(){var today=new Date();var dd=today.getDate();var mm=today.getMonth()+1;var yyyy=today.getFullYear();var hh=today.getHours();if(dd<10){dd="0"+dd;}
if(mm<10){mm="0"+mm;}
return yyyy+"-"+mm+"-"+dd+"-"+hh;};trackdirect.models.HeatMap.prototype._getNormalizedCoord=function(coord,zoom){var y=coord.y;var x=coord.x;var tileRange=1<=tileRange){return null;}
if(x<0||x>=tileRange){x=((x%tileRange)+tileRange)%tileRange;}
return{x:x,y:y};};
trackdirect.models.DirectionPolyline=function(marker,map){this._marker=marker;this._defaultMap=map;this.startTimestamp=this._marker.packet.timestamp;this.speed=this._marker.packet.speed;this.course=this._marker.packet.course;this.stopped=false;this.timerId=null;if(typeof google==="object"&&typeof google.maps==="object"){google.maps.Polyline.call(this,this._getGooglePolylineOptions());}else if(typeof L==="object"){L.Polyline.call(this,{},this._getLeafletPolylineOptions());this.setLatLngs([this._getFirstCoordinate(),this._getExpectedCoordinate(),]);}};if(typeof google==="object"&&typeof google.maps==="object"){trackdirect.models.DirectionPolyline.prototype=Object.create(google.maps.Polyline.prototype);}else if(typeof L==="object"){trackdirect.models.DirectionPolyline.prototype=Object.create(L.Polyline.prototype);}
trackdirect.models.DirectionPolyline.prototype.constructor=trackdirect.models.DirectionPolyline;trackdirect.models.DirectionPolyline.prototype.setPathItems=function(pathItems){if(typeof google==="object"&&typeof google.maps==="object"){this.setPath(pathItems);}else if(typeof L==="object"){this.setLatLngs(pathItems);}};trackdirect.models.DirectionPolyline.prototype.getMap=function(){if(typeof google==="object"&&typeof google.maps==="object"){var map=google.maps.Polyline.prototype.getMap.call(this);if(typeof map!=="undefined"){return map;}}else if(typeof L==="object"){if(this._defaultMap.hasLayer(this)){return this._defaultMap;}}
return null;};trackdirect.models.DirectionPolyline.prototype.show=function(){var timeInSeconds=this._getAgeInSeconds();if(this.stopped===false&&timeInSeconds<=900&&this._marker.packet.hasConfirmedMapId()&&(this._defaultMap.state.isFilterMode||this._defaultMap.getZoom()>=trackdirect.settings.minZoomForMarkerTail)){if(typeof google==="object"&&typeof google.maps==="object"){if(typeof this.getMap()==="undefined"||this.getMap()===null){this.setMap(this._defaultMap);}}else if(typeof L==="object"){if(!this._defaultMap.hasLayer(this)){this.addTo(this._defaultMap);}}
this.recalculate();}};trackdirect.models.DirectionPolyline.prototype.hide=function(){if(typeof google==="object"&&typeof google.maps==="object"){if(this.getMap()!==null){this.setMap(null);}}else if(typeof L==="object"){if(this._defaultMap.hasLayer(this)){this._defaultMap.removeLayer(this);}}};trackdirect.models.DirectionPolyline.prototype.stop=function(){this.stopped=true;this.hide();};trackdirect.models.DirectionPolyline.prototype._getGooglePolylineOptions=function(){var lineCoordinates=[this._getFirstCoordinate(),this._getExpectedCoordinate(),];var lineSymbol={path:google.maps.SymbolPath.FORWARD_OPEN_ARROW,strokeOpacity:1,scale:0.65,};var options={path:lineCoordinates,strokeOpacity:0,strokeColor:trackdirect.services.stationColorCalculator.getColor(this._marker.packet),map:null,icons:[{icon:lineSymbol,offset:"0px",repeat:"8px",},],};return options;};trackdirect.models.DirectionPolyline.prototype._getLeafletPolylineOptions=function(){return{color:trackdirect.services.stationColorCalculator.getColor(this._marker.packet),weight:4,opacity:0.7,dashArray:"2,8",lineJoin:"round",};};trackdirect.models.DirectionPolyline.prototype._getFirstCoordinate=function(){return this._marker.packet.getLatLngLiteral();};trackdirect.models.DirectionPolyline.prototype._getExpectedCoordinate=function(){var timeInSeconds=this._getAgeInSeconds();var distance=(this.speed/3.6)*timeInSeconds;var startPosition=this._getFirstCoordinate();if(startPosition!=null){return trackdirect.services.distanceCalculator.getPositionByDistance(startPosition,this.course,distance);}
return null;};trackdirect.models.DirectionPolyline.prototype.recalculate=function(){var interval=1000;var me=this;this.timerId=window.setInterval(function(){if(!me._marker.isVisible()||me.stopped||!me._marker.showAsMarker){me.hide();clearInterval(me.timerId);return;}
var timeInSeconds=me._getAgeInSeconds();if(timeInSeconds>900){me.stop();if(me.timerId!==null){clearInterval(me.timerId);}}else{var firstPosition=me._getFirstCoordinate();var newPosition=me._getExpectedCoordinate();if(firstPosition!=null&&newPosition!=null){me.setPathItems([firstPosition,newPosition]);}}},interval);};trackdirect.models.DirectionPolyline.prototype._getAgeInSeconds=function(){var timeInSeconds=0;var startTimestamp=this._defaultMap.state.getClientTimestamp(this.startTimestamp);if(startTimestamp