PageSourceSearch

https://hitza.eus/site/edukia/themes/hitza/src/js/min/libs/leaflet/leaflet.gpx.js?ver=1.4.0

js hitza.eus collected 2026-10-01 11:24:57 UTC 12,219 bytes, 1 lines download raw bytes

1var L=L||require("leaflet"),_MAX_POINT_INTERVAL_MS=15e3,_SECOND_IN_MILLIS=1e3,_MINUTE_IN_MILLIS=60*_SECOND_IN_MILLIS,_HOUR_IN_MILLIS=60*_MINUTE_IN_MILLIS,_DAY_IN_MILLIS=24*_HOUR_IN_MILLIS,_GPX_STYLE_NS="http://www.topografix.com/GPX/gpx_style/0/2",_DEFAULT_MARKER_OPTS={startIconUrl:"pin-icon-start.png",endIconUrl:"pin-icon-end.png",shadowUrl:"pin-shadow.png",wptIcons:[],wptIconUrls:{"":"pin-icon-wpt.png"},pointMatchers:[],iconSize:[33,50],shadowSize:[50,50],iconAnchor:[16,45],shadowAnchor:[16,47],clickable:!1},_DEFAULT_POLYLINE_OPTS={color:"blue"},_DEFAULT_GPX_OPTS={parseElements:["track","route","waypoint"]};L.GPX=L.FeatureGroup.extend({initialize:function(t,e){e.max_point_interval=e.max_point_interval||_MAX_POINT_INTERVAL_MS,e.marker_options=this._merge_objs(_DEFAULT_MARKER_OPTS,e.marker_options||{}),e.polyline_options=e.polyline_options||{},e.gpx_options=this._merge_objs(_DEFAULT_GPX_OPTS,e.gpx_options||{}),L.Util.setOptions(this,e),L.GPXTrackIcon=L.Icon.extend({options:e.marker_options}),this._gpx=t,this._layers={},this._init_info(),t&&this._parse(t,e,this.options.async)},get_duration_string:function(t,e){var n="";_DAY_IN_MILLIS<=t&&(n+=Math.floor(t/_DAY_IN_MILLIS)+"d ",t%=_DAY_IN_MILLIS),_HOUR_IN_MILLIS<=t&&(n+=Math.floor(t/_HOUR_IN_MILLIS)+":",t%=_HOUR_IN_MILLIS);var i=Math.floor(t/_MINUTE_IN_MILLIS);t%=_MINUTE_IN_MILLIS,i<10&&(n+="0"),n+=i+"'";var o=Math.floor(t/_SECOND_IN_MILLIS);return t%=_SECOND_IN_MILLIS,o<10&&(n+="0"),n+=o,n+=!e&&0<t?"."+Math.round(1e3*Math.floor(t))/1e3:'"'},get_duration_string_iso:function(t,e){return this.get_duration_string(t,e).replace("'",":").replace('"',"")},to_miles:function(t){return t/1.60934},to_ft:function(t){return 3.28084*t},m_to_km:function(t){return t/1e3},m_to_mi:function(t){return t/1609.34},get_name:function(){return this._info.name},get_desc:function(){return this._info.desc},get_author:function(){return this._info.author},get_copyright:function(){return this._info.copyright},get_distance:function(){return this._info.length},get_distance_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))},get_start_time:function(){return this._info.duration.start},get_end_time:function(){return this._info.duration.end},get_moving_time:function(){return this._info.duration.moving},get_total_time:function(){return this._info.duration.total},get_moving_pace:function(){return this.get_moving_time()/this.m_to_km(this.get_distance())},get_moving_pace_imp:function(){return this.get_moving_time()/this.get_distance_imp()},get_moving_speed:function(){return this.m_to_km(this.get_distance())/(this.get_moving_time()/36e5)},get_moving_speed_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))/(this.get_moving_time()/36e5)},get_total_speed:function(){return this.m_to_km(this.get_distance())/(this.get_total_time()/36e5)},get_total_speed_imp:function(){return this.to_miles(this.m_to_km(this.get_distance()))/(this.get_total_time()/36e5)},get_elevation_gain:function(){return this._info.elevation.gain},get_elevation_loss:function(){return this._info.elevation.loss},get_elevation_gain_imp:function(){return this.to_ft(this.get_elevation_gain())},get_elevation_loss_imp:function(){return this.to_ft(this.get_elevation_loss())},get_elevation_data:function(){var t=this;return this._info.elevation._points.map(function(e){return t._prepare_data_point(e,t.m_to_km,null,function(t,e){return t.toFixed(2)+" km, "+e.toFixed(0)+" m"})})},get_elevation_data_imp:function(){var t=this;return this._info.elevation._points.map(function(e){return t._prepare_data_point(e,t.m_to_mi,t.to_ft,function(t,e){return t.toFixed(2)+" mi, "+e.toFixed(0)+" ft"})})},get_elevation_max:function(){return this._info.elevation.max},get_elevation_min:function(){return this._info.elevation.min},get_elevation_max_imp:function(){return this.to_ft(this.get_elevation_max())},get_elevation_min_imp:function(){return this.to_ft(this.get_elevation_min())},get_average_hr:function(){return this._info.hr.avg},get_average_temp:function(){return this._info.atemp.avg},get_average_cadence:function(){return this._info.cad.avg},get_heartrate_data:function(){var t=this;return this._info.hr._points.map(function(e){return t._prepare_data_point(e,t.m_to_km,null,function(t,e){return t.toFixed(2)+" km, "+e.toFixed(0)+" bpm"})})},get_heartrate_data_imp:function(){var t=this;return this._info.hr._points.map(function(e){return t._prepare_data_point(e,t.m_to_mi,null,function(t,e){return t.toFixed(2)+" mi, "+e.toFixed(0)+" bpm"})})},get_cadence_data:function(){var t=this;return this._info.cad._points.map(function(e){return t._prepare_data_point(e,t.m_to_km,null,function(t,e){return t.toFixed(2)+" km, "+e.toFixed(0)+" rpm"})})},get_temp_data:function(){var t=this;return this._info.atemp._points.map(function(e){return t._prepare_data_point(e,t.m_to_km,null,function(t,e){return t.toFixed(2)+" km, "+e.toFixed(0)+" degrees"})})},get_cadence_data_imp:function(){var t=this;return this._info.cad._points.map(function(e){return t._prepare_data_point(e,t.m_to_mi,null,function(t,e){return t.toFixed(2)+" mi, "+e.toFixed(0)+" rpm"})})},get_temp_data_imp:function(){var t=this;return this._info.atemp._points.map(function(e){return t._prepare_data_point(e,t.m_to_mi,null,function(t,e){return t.toFixed(2)+" mi, "+e.toFixed(0)+" degrees"})})},reload:function(){this._init_info(),this.clearLayers(),this._parse(this._gpx,this.options,this.options.async)},_merge_objs:function(t,e){var n={};for(var i in t)n[i]=t[i];for(var i in e)n[i]=e[i];return n},_prepare_data_point:function(t,e,n,i){var o=[e&&e(t[0])||t[0],n&&n(t[1])||t[1]];return o.push(i&&i(o[0],o[1])||o[0]+": "+o[1]),o},_init_info:function(){this._info={name:null,length:0,elevation:{gain:0,loss:0,max:0,min:1/0,_points:[]},hr:{avg:0,_total:0,_points:[]},duration:{start:null,end:null,moving:0,total:0},atemp:{avg:0,_total:0,_points:[]},cad:{avg:0,_total:0,_points:[]}}},_load_xml:function(t,e,n,i){null==i&&(i=this.options.async),null==n&&(n=this.options);var o=new window.XMLHttpRequest;o.open("GET",t,i);try{o.overrideMimeType("text/xml")}catch(t){}o.onreadystatechange=function(){4==o.readyState&&200==o.status&&e(o.responseXML,n)},o.send(null)},_parse:function(t,e,n){var i=this,o=function(t,e){var n=i._parse_gpx_data(t,e);n&&(i.addLayer(n),i.fire("loaded",{layers:n,element:t}))};if("<"===t.substr(0,1)){var a=new DOMParser;n?setTimeout(function(){o(a.parseFromString(t,"text/xml"),e)}):o(a.parseFromString(t,"text/xml"),e)}else this._load_xml(t,o,e,n)},_parse_gpx_data:function(t,e){var n,i,o,a,_=[],r=[],s=e.gpx_options.parseElements;-1<s.indexOf("route")&&r.push(["rte","rtept"]),-1<s.indexOf("track")&&r.push(["trkseg","trkpt"]),0<(u=t.getElementsByTagName("name")).length&&(this._info.name=u[0].textContent),0<(f=t.getElementsByTagName("desc")).length&&(this._info.desc=f[0].textContent);var l=t.getElementsByTagName("author");0<l.length&&(this._info.author=l[0].textContent);var m=t.getElementsByTagName("copyright");for(0<m.length&&(this._info.copyright=m[0].textContent),i=0;i<r.length;i++)for(a=t.getElementsByTagName(r[i][0]),n=0;n<a.length;n++){var h=this._parse_trkseg(a[n],e,r[i][1]);for(o=0;o<h.length;
1o++)_.push(h[o])}if(this._info.hr.avg=Math.round(this._info.hr._total/this._info.hr._points.length),this._info.cad.avg=Math.round(this._info.cad._total/this._info.cad._points.length),this._info.atemp.avg=Math.round(this._info.atemp._total/this._info.atemp._points.length),-1<s.indexOf("waypoint"))for(a=t.getElementsByTagName("wpt"),n=0;n<a.length;n++){var p=new L.LatLng(a[n].getAttribute("lat"),a[n].getAttribute("lon")),g=a[n].getElementsByTagName("name"),u="";0<g.length&&(u=g[0].textContent);var c=a[n].getElementsByTagName("desc"),f="";0<c.length&&(f=c[0].textContent);var d=a[n].getElementsByTagName("sym"),v="";0<d.length&&(v=d[0].textContent);var I,x=e.marker_options.wptIcons,M=e.marker_options.wptIconUrls;if(x&&x[v])I=x[v];else if(M&&M[v])I=new L.GPXTrackIcon({iconUrl:M[v]});else if(x&&x[""])I=x[""];else{if(!M||!M[""]){console.log('No icon or icon URL configured for symbol type "'+v+'", and no fallback configured; ignoring waypoint.');continue}I=new L.GPXTrackIcon({iconUrl:M[""]})}var k=new L.Marker(p,{clickable:e.marker_options.clickable,title:u,icon:I});k.bindPopup("<b>"+u+"</b>"+(0<f.length?"<br>"+f:"")).openPopup(),this.fire("addpoint",{point:k,point_type:"waypoint",element:a[n]}),_.push(k)}return 1<_.length?new L.FeatureGroup(_):1==_.length?_[0]:void 0},_parse_trkseg:function(t,e,n){var i=t.getElementsByTagName(n);if(!i.length)return[];for(var o=[],a=[],_=[],r=null,s=0;s<i.length;s++){var l=new L.LatLng(i[s].getAttribute("lat"),i[s].getAttribute("lon"));if(l.meta={time:null,ele:null,hr:null,cad:null,atemp:null},0<(u=i[s].getElementsByTagName("time")).length?l.meta.time=new Date(Date.parse(u[0].textContent)):l.meta.time=new Date("1970-01-01T00:00:00"),0<(u=i[s].getElementsByTagName("ele")).length&&(l.meta.ele=parseFloat(u[0].textContent)),0<(u=i[s].getElementsByTagName("name")).length)for(var m=u[0].textContent,h=e.marker_options.pointMatchers||[],p=0;p<h.length;p++)if(h[p].regex.test(m)){a.push({label:m,coords:l,icon:h[p].icon,element:i[s]});break}if(0<(u=i[s].getElementsByTagNameNS("*","hr")).length&&(l.meta.hr=parseInt(u[0].textContent),this._info.hr._points.push([this._info.length,l.meta.hr]),this._info.hr._total+=l.meta.hr),0<(u=i[s].getElementsByTagNameNS("*","cad")).length&&(l.meta.cad=parseInt(u[0].textContent),this._info.cad._points.push([this._info.length,l.meta.cad]),this._info.cad._total+=l.meta.cad),0<(u=i[s].getElementsByTagNameNS("*","atemp")).length&&(l.meta.atemp=parseInt(u[0].textContent),this._info.atemp._points.push([this._info.length,l.meta.atemp]),this._info.atemp._total+=l.meta.atemp),l.meta.ele>this._info.elevation.max&&(this._info.elevation.max=l.meta.ele),l.meta.ele<this._info.elevation.min&&(this._info.elevation.min=l.meta.ele),this._info.elevation._points.push([this._info.length,l.meta.ele]),this._info.duration.end=l.meta.time,null!=r){this._info.length+=this._dist3d(r,l);var g=l.meta.ele-r.meta.ele;0<g?this._info.elevation.gain+=g:this._info.elevation.loss+=Math.abs(g),g=Math.abs(l.meta.time-r.meta.time),this._info.duration.total+=g,g<e.max_point_interval&&(this._info.duration.moving+=g)}else null==this._info.duration.start&&(this._info.duration.start=l.meta.time);r=l,o.push(l)}var u,c=this._merge_objs(_DEFAULT_POLYLINE_OPTS,{}),f=t.getElementsByTagNameNS(_GPX_STYLE_NS,"line");0<f.length&&(0<(u=f[0].getElementsByTagName("color")).length&&(c.color="#"+u[0].textContent),0<(u=f[0].getElementsByTagName("opacity")).length&&(c.opacity=u[0].textContent),0<(u=f[0].getElementsByTagName("weight")).length&&(c.weight=u[0].textContent),0<(u=f[0].getElementsByTagName("linecap")).length&&(c.lineCap=u[0].textContent));var d=new L.Polyline(o,this._merge_objs(c,e.polyline_options));if(this.fire("addline",{line:d,element:t}),_.push(d),e.marker_options.startIcon||e.marker_options.startIconUrl){var v=new L.Marker(o[0],{clickable:e.marker_options.clickable,icon:e.marker_options.startIcon||new L.GPXTrackIcon({iconUrl:e.marker_options.startIconUrl})});this.fire("addpoint",{point:v,point_type:"start",element:i[0]}),_.push(v)}for((e.marker_options.endIcon||e.marker_options.endIconUrl)&&(v=new L.Marker(o[o.length-1],{clickable:e.marker_options.clickable,icon:e.marker_options.endIcon||new L.GPXTrackIcon({iconUrl:e.marker_options.endIconUrl})}),this.fire("addpoint",{point:v,point_type:"end",element:i[i.length-1]}),_.push(v)),s=0;s<a.length;s++)v=new L.Marker(a[s].coords,{clickable:e.marker_options.clickable,title:a[s].label,icon:a[s].icon}),this.fire("addpoint",{point:v,point_type:"label",element:a[s].element}),_.push(v);return _},_dist2d:function(t,e){var n=this._deg2rad(e.lat-t.lat),i=this._deg2rad(e.lng-t.lng),o=Math.sin(n/2)*Math.sin(n/2)+Math.cos(this._deg2rad(t.lat))*Math.cos(this._deg2rad(e.lat))*Math.sin(i/2)*Math.sin(i/2);
1return 2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))*6371e3},_dist3d:function(t,e){var n=this._dist2d(t,e),i=Math.abs(e.meta.ele-t.meta.ele);return Math.sqrt(Math.pow(n,2)+Math.pow(i,2))},_deg2rad:function(t){return t*Math.PI/180}}),"object"==typeof module&&"object"==typeof module.exports?module.exports=L:"function"==typeof define&&define.amd&&define(L);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.