From f49fa634a2522566003222fc998222e4f1d7640b Mon Sep 17 00:00:00 2001 From: bastianonm Date: Mon, 25 Jun 2012 10:22:56 +0000 Subject: [PATCH] --- WP-GPX-Maps.js | 29 ++++--- languages/wp-gpx-maps-it_IT.mo | Bin 857 -> 1177 bytes languages/wp-gpx-maps-it_IT.po | 136 +++++++++++++++++++------------- languages/wp-gpx-maps.pot | 52 +++++++++---- readme.txt | 4 +- wp-gpx-maps.php | 138 +++++++++++++++++++++++++++++---- wp-gpx-maps_admin.php | 3 +- wp-gpx-maps_admin_settings.php | 28 ++++--- wp-gpx-maps_utils.php | 28 +++++++ 9 files changed, 311 insertions(+), 107 deletions(-) diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js index b975632..ffc4440 100644 --- a/WP-GPX-Maps.js +++ b/WP-GPX-Maps.js @@ -459,6 +459,9 @@ function _wpgpxmaps(params) l_y = { suf : "m", dec : 0 }; } + var nn = 1111.1; + var decPoint = nn.toLocaleString().substring(5, 6); + var thousandsSep = nn.toLocaleString().substring(1, 2); // define the options var hoptions = { @@ -490,7 +493,6 @@ function _wpgpxmaps(params) shared: true, crosshairs: true, formatter: function() { - if (marker) { var hchart_xserie = hchart.xAxis[0].series[0].data; @@ -505,11 +507,10 @@ function _wpgpxmaps(params) } } } - - var tooltip = "" + Highcharts.numberFormat(this.x, l_x.dec) + l_x.suf + "
"; + var tooltip = "" + Highcharts.numberFormat(this.x, l_x.dec,decPoint,thousandsSep) + l_x.suf + "
"; for (i=0; i < this.points.length; i++) { - tooltip += this.points[i].series.name + ": " + Highcharts.numberFormat(this.points[i].y, l_y_arr[i].dec) + l_y_arr[i].suf + "
"; + tooltip += this.points[i].series.name + ": " + Highcharts.numberFormat(this.points[i].y, l_y_arr[i].dec,decPoint,thousandsSep) + l_y_arr[i].suf + "
"; } return tooltip; } @@ -533,7 +534,7 @@ function _wpgpxmaps(params) xAxis: { labels: { formatter: function() { - return Highcharts.numberFormat(this.value, l_x.dec) + l_x.suf; + return Highcharts.numberFormat(this.value, l_x.dec,decPoint,thousandsSep) + l_x.suf; } } }, @@ -559,7 +560,7 @@ function _wpgpxmaps(params) labels: { align: 'left', formatter: function() { - return Highcharts.numberFormat(this.value, l_y.dec) + l_y.suf; + return Highcharts.numberFormat(this.value, l_y.dec,decPoint,thousandsSep) + l_y.suf; } } } @@ -594,7 +595,15 @@ function _wpgpxmaps(params) var l_s; - if (unitspeed == '2') // miles/h + if (unitspeed == '4') // min/miles + { + l_s = { suf : "min/mi", dec : 3 }; + } + else if (unitspeed == '3') // min/km + { + l_s = { suf : "min/km", dec : 3 }; + } + else if (unitspeed == '2') // miles/h { l_s = { suf : "mi/h", dec : 0 }; } @@ -619,7 +628,7 @@ function _wpgpxmaps(params) labels: { //align: 'right', formatter: function() { - return Highcharts.numberFormat(this.value, l_s.dec) + l_s.suf; + return Highcharts.numberFormat(this.value, l_s.dec,decPoint,thousandsSep) + l_s.suf; } }, opposite: true @@ -670,7 +679,7 @@ function _wpgpxmaps(params) labels: { //align: 'right', formatter: function() { - return Highcharts.numberFormat(this.value, l_hr.dec) + l_hr.suf; + return Highcharts.numberFormat(this.value, l_hr.dec,decPoint,thousandsSep) + l_hr.suf; } }, opposite: true @@ -709,7 +718,7 @@ function _wpgpxmaps(params) labels: { //align: 'right', formatter: function() { - return Highcharts.numberFormat(this.value, l_cad.dec) + l_cad.suf; + return Highcharts.numberFormat(this.value, l_cad.dec,decPoint,thousandsSep) + l_cad.suf; } }, opposite: true diff --git a/languages/wp-gpx-maps-it_IT.mo b/languages/wp-gpx-maps-it_IT.mo index b000d39dbc6f86a318a69883ca13b3f38a205965..535be90780652bf2f78910271e8677a4980be2b4 100644 GIT binary patch delta 649 zcmYk2JxBvV5QXPrOpGQ*)1=ViYy`^`QLzhJ39(5K6q`wIi3^vDcx#Ah0$SNAK~S); zwN*>I6!tbE_|pn@cCqqJawjg#efxH2cHZ1e>@v}L&qU7&YYH)oxI$!QZ{dU00>{8Z zFa;igaqtwBnv3B6CeXLwB+h%_IQRrg-CMvfFbUlUM~ONViwp~rpd`)&dI3B}(lRIy zJ&X{g!ADRGJcAkVBhcTV4DbVrfoybWa2}MrC2$&C2ho^zzy$hJ1siGXf>PK9rO^q9 z{)0Qwkc78s0wF7bkbLHjhXz6`G-mDKM@Svq{0`m3 ztskPeba%6BC;#vA;K%Ro-SL0#qxMssZ+!1vpz5FvQqTn7fa?z&fGyYuJJ15IQ}&Nw zzPI5+Si+oj1vlVpcn==KZ{QyA`^L3-bMcFVkH)ra2(MBu(ttVe80G<&Fb56c8a#rL zWzUd(^I%?iPB2dZ$|Q#@?@4wCvspi>IR|Gp;YHGwExcZ^2=>H#k%s)icFdtaYyO&G09e+ F;vdV+G7$g( diff --git a/languages/wp-gpx-maps-it_IT.po b/languages/wp-gpx-maps-it_IT.po index 23775bf..9798ca5 100644 --- a/languages/wp-gpx-maps-it_IT.po +++ b/languages/wp-gpx-maps-it_IT.po @@ -1,56 +1,80 @@ -msgid "" -msgstr "" -"Project-Id-Version: wp-gpx-maps\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-06-21 14:24+0100\n" -"PO-Revision-Date: 2012-06-21 14:31+0100\n" -"Last-Translator: \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-KeywordsList: __;_e\n" -"X-Poedit-Basepath: .\n" -"X-Poedit-Language: Italian\n" -"X-Poedit-Country: ITALY\n" -"X-Poedit-SearchPath-0: ..\n" - -#: ../wp-gpx-maps.php:348 -msgid "Altitude" -msgstr "Altitudine" - -#: ../wp-gpx-maps.php:349 -msgid "Current Position" -msgstr "Posizione Corrente" - -#: ../wp-gpx-maps.php:350 -msgid "Speed" -msgstr "Velocità" - -#: ../wp-gpx-maps.php:351 -msgid "Heart rate" -msgstr "Battito Cardiaco" - -#: ../wp-gpx-maps.php:352 -msgid "Cadence" -msgstr "Cadenza" - -#: ../wp-gpx-maps.php:353 -msgid "Go Full Screen" -msgstr "Schermo intero" - -#: ../wp-gpx-maps.php:354 -msgid "Exit Full Screen" -msgstr "Torna a dimensioni originali" - -#: ../wp-gpx-maps.php:370 -msgid "Download" -msgstr "Scarica" - -#: ../wp-gpx-maps_admin_settings.php:67 -#: ../wp-gpx-maps_admin_settings.php:143 -#: ../wp-gpx-maps_admin_settings.php:245 -#: ../wp-gpx-maps_admin_settings.php:276 -msgid "Save Changes" -msgstr "Salva" - +msgid "" +msgstr "" +"Project-Id-Version: wp-gpx-maps\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-06-25 11:55+0100\n" +"PO-Revision-Date: 2012-06-25 11:56+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-KeywordsList: __;_e\n" +"X-Poedit-Basepath: .\n" +"X-Poedit-Language: Italian\n" +"X-Poedit-Country: ITALY\n" +"X-Poedit-SearchPath-0: ..\n" + +#: ../wp-gpx-maps.php:420 +msgid "Altitude" +msgstr "Altitudine" + +#: ../wp-gpx-maps.php:421 +msgid "Current Position" +msgstr "Posizione Corrente" + +#: ../wp-gpx-maps.php:422 +msgid "Speed" +msgstr "Velocità" + +#: ../wp-gpx-maps.php:423 +msgid "Heart rate" +msgstr "Battito Cardiaco" + +#: ../wp-gpx-maps.php:424 +msgid "Cadence" +msgstr "Cadenza" + +#: ../wp-gpx-maps.php:425 +msgid "Go Full Screen" +msgstr "Schermo intero" + +#: ../wp-gpx-maps.php:426 +msgid "Exit Full Screen" +msgstr "Torna a dimensioni originali" + +#: ../wp-gpx-maps.php:439 +msgid "Total distance" +msgstr "Distanza totale" + +#: ../wp-gpx-maps.php:443 +msgid "Max elevation" +msgstr "Altitudine massima" + +#: ../wp-gpx-maps.php:444 +msgid "Min elevation" +msgstr "Altitudine minima" + +#: ../wp-gpx-maps.php:445 +msgid "Total climbing" +msgstr "Totale salita" + +#: ../wp-gpx-maps.php:446 +msgid "Total descent" +msgstr "Totale discesa" + +#: ../wp-gpx-maps.php:450 +msgid "Average speed" +msgstr "Velocità media" + +#: ../wp-gpx-maps.php:466 +msgid "Download" +msgstr "Scarica" + +#: ../wp-gpx-maps_admin_settings.php:75 +#: ../wp-gpx-maps_admin_settings.php:151 +#: ../wp-gpx-maps_admin_settings.php:255 +#: ../wp-gpx-maps_admin_settings.php:286 +msgid "Save Changes" +msgstr "Salva" + diff --git a/languages/wp-gpx-maps.pot b/languages/wp-gpx-maps.pot index 897fb4a..ab06ccc 100644 --- a/languages/wp-gpx-maps.pot +++ b/languages/wp-gpx-maps.pot @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: wp-gpx-maps\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-06-20 19:00+0100\n" -"PO-Revision-Date: 2012-06-20 19:00+0100\n" +"POT-Creation-Date: 2012-06-25 11:54+0100\n" +"PO-Revision-Date: 2012-06-25 11:55+0100\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,42 +13,66 @@ msgstr "" "X-Poedit-Basepath: .\n" "X-Poedit-SearchPath-0: ..\n" -#: ../wp-gpx-maps.php:348 +#: ../wp-gpx-maps.php:420 msgid "Altitude" msgstr "" -#: ../wp-gpx-maps.php:349 +#: ../wp-gpx-maps.php:421 msgid "Current Position" msgstr "" -#: ../wp-gpx-maps.php:350 +#: ../wp-gpx-maps.php:422 msgid "Speed" msgstr "" -#: ../wp-gpx-maps.php:351 +#: ../wp-gpx-maps.php:423 msgid "Heart rate" msgstr "" -#: ../wp-gpx-maps.php:352 +#: ../wp-gpx-maps.php:424 msgid "Cadence" msgstr "" -#: ../wp-gpx-maps.php:353 +#: ../wp-gpx-maps.php:425 msgid "Go Full Screen" msgstr "" -#: ../wp-gpx-maps.php:354 +#: ../wp-gpx-maps.php:426 msgid "Exit Full Screen" msgstr "" -#: ../wp-gpx-maps.php:370 +#: ../wp-gpx-maps.php:439 +msgid "Total distance" +msgstr "" + +#: ../wp-gpx-maps.php:443 +msgid "Max elevation" +msgstr "" + +#: ../wp-gpx-maps.php:444 +msgid "Min elevation" +msgstr "" + +#: ../wp-gpx-maps.php:445 +msgid "Total climbing" +msgstr "" + +#: ../wp-gpx-maps.php:446 +msgid "Total descent" +msgstr "" + +#: ../wp-gpx-maps.php:450 +msgid "Average speed" +msgstr "" + +#: ../wp-gpx-maps.php:466 msgid "Download" msgstr "" -#: ../wp-gpx-maps_admin_settings.php:67 -#: ../wp-gpx-maps_admin_settings.php:143 -#: ../wp-gpx-maps_admin_settings.php:245 -#: ../wp-gpx-maps_admin_settings.php:276 +#: ../wp-gpx-maps_admin_settings.php:75 +#: ../wp-gpx-maps_admin_settings.php:151 +#: ../wp-gpx-maps_admin_settings.php:255 +#: ../wp-gpx-maps_admin_settings.php:286 msgid "Save Changes" msgstr "" diff --git a/readme.txt b/readme.txt index 3c71090..3824867 100644 --- a/readme.txt +++ b/readme.txt @@ -89,7 +89,7 @@ The attributes are: 1. glinecolorcad: cadence line color (default is #beecff) -1. uomspeed: the unit of measure of speed are: 0, 1, 2 (0 = m/s, 1 = km/h, 2 = miles/h) +1. uomspeed: the unit of measure of speed are: 0, 1, 2, 3, 4 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles) 1. chartFrom1: minimun value for altitude chart @@ -115,6 +115,8 @@ The attributes are: 1. download: Allow users to download your GPX file +1. summary: Print symmary details of your GPX (default is FALSE) + = What happening if I've a very large gpx? = This plugin will print a small amout of points to speedup javascript and pageload. diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index af9fac8..be3356a 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -70,6 +70,8 @@ function print_WP_GPX_Maps_scripts() .wpgpxmaps img { max-width: none; width: none; padding:0; background:none; } .wpgpxmaps .ngimages { display:none; } .wpgpxmaps .myngimages { border:1px solid #fff;position:absolute;cursor:pointer;margin:0;z-index:1; } + .wpgpxmaps_summary .summarylabel { } + .wpgpxmaps_summary .summaryvalue { font-weight: bold; } maxEle; + $min_ele = $points->minEle; + $total_ele_up = $points->totalEleUp; + $total_ele_down = $points->totalEleDown; + $avg_speed = $points->avgSpeed; + $tot_len = $points->totalLength; foreach(array_keys($points->lat) as $i) { @@ -229,18 +253,9 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') if ($showSpeed == true) { - $_speed = (float)$points->speed[$i]; // dafault m/s + $_speed = (float)$points->speed[$i]; - if ($uomspeed == '2') // miles/h - { - $_speed *= 2.2369362920544025; - } - else if ($uomspeed == '1') // km/h - { - $_speed *= 3.6; - } - - $points_graph_speed .= $_speed.','; + $points_graph_speed .= convertSpeed($_speed,$uomspeed).','; } if ($showHr == true) @@ -253,7 +268,36 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') $points_graph_cad .= $points->cad[$i].','; } + } + + if ($uom == '1') + { + // Miles and feet + $tot_len = round($tot_len * 0.000621371192,2)." mi"; + $max_ele = ($max_ele * 3.2808399)." ft"; + $min_ele = ($min_ele * 3.2808399)." ft"; + $total_ele_up = ($total_ele_up * 3.2808399)." ft"; + $total_ele_down = ($total_ele_down * 3.2808399)." ft"; + } else if ($uom == '2') + { + // meters / kilometers + $tot_len = round($tot_len / 1000,2)." km"; + $max_ele = $max_ele ." m"; + $min_ele = $min_ele ." m"; + $total_ele_up = $total_ele_up ." m"; + $total_ele_down = $total_ele_down ." m"; } + else + { + // meters / kilometers + $tot_len = $tot_len ." m"; + $max_ele = $max_ele ." m"; + $min_ele = $min_ele ." m"; + $total_ele_up = $total_ele_up ." m"; + $total_ele_down = $total_ele_down ." m"; + } + + $avg_speed = convertSpeed($avg_speed,$uomspeed,true); if ($showW == true) { @@ -310,10 +354,17 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') "points_graph_speed" => $points_graph_speed, "points_graph_hr" => $points_graph_hr, "points_graph_cad" => $points_graph_cad, - "waypoints" => $waypoints) + "waypoints" => $waypoints, + "max_ele" => $max_ele, + "min_ele" => $min_ele, + "total_ele_up" => $total_ele_up, + "total_ele_down" => $total_ele_down, + "avg_speed" => $avg_speed, + "tot_len" => $tot_len + ) ), LOCK_EX); - + @chmod($gpxcache,0755); $output = ' @@ -363,6 +414,30 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') }); '; + // print summary + if ($summary=='true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') ) + { + + $output .= "
"; + if ($points_graph_dist != '') + { + $output .= "".__("Total distance", "wp-gpx-maps").": $tot_len
"; + } + if ($points_graph_ele != '') + { + $output .= "".__("Max elevation", "wp-gpx-maps").": $max_ele
"; + $output .= "".__("Min elevation", "wp-gpx-maps").": $min_ele
"; + $output .= "".__("Total climbing", "wp-gpx-maps").": $total_ele_up
"; + $output .= "".__("Total descent", "wp-gpx-maps").": $total_ele_down
"; + } + if ($points_graph_speed != '') + { + $output .= "".__("Average speed", "wp-gpx-maps").": $avg_speed
"; + } + $output .= "
"; + } + + // print download link if ($download=='true' && $gpxurl != '') { if ($isGpxUrl == true) @@ -379,6 +454,35 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') return $output; } +function convertSpeed($speed,$uomspeed, $addUom = false) +{ + if ($uomspeed == '4') // min/mi + { + $speed *= 0.037282272; + if ($addUom == true) $speed = round($speed,2) . " min/mi"; + } + else if ($uomspeed == '3') // min/km + { + $speed *= 0.06; + if ($addUom == true) $speed = round($speed,2) . " min/km"; + } + else if ($uomspeed == '2') // miles/h + { + $speed *= 2.2369362920544025; + if ($addUom == true) $speed = round($speed,2) . " mi/h"; + } + else if ($uomspeed == '1') // km/h + { + $speed *= 3.6; + if ($addUom == true) $speed = round($speed,2) . " km/h"; + } + else // dafault m/s + { + if ($addUom == true) $speed = round($speed,2) . " m/s"; + } + return $speed; +} + function downloadRemoteFile($remoteFile) { try @@ -438,6 +542,7 @@ function WP_GPX_Maps_install() { add_option('wpgpxmaps_show_cadence','','','yes'); add_option('wpgpxmaps_zoomonscrollwheel','','','yes'); add_option('wpgpxmaps_download','','','yes'); + add_option('wpgpxmaps_summary','','','yes'); } function WP_GPX_Maps_remove() { @@ -469,6 +574,7 @@ function WP_GPX_Maps_remove() { delete_option('wpgpxmaps_graph_line_color_cad'); delete_option('wpgpxmaps_zoomonscrollwheel'); delete_option('wpgpxmaps_download'); + delete_option('wpgpxmaps_summary'); } ?> diff --git a/wp-gpx-maps_admin.php b/wp-gpx-maps_admin.php index b631479..d0313d3 100644 --- a/wp-gpx-maps_admin.php +++ b/wp-gpx-maps_admin.php @@ -105,7 +105,7 @@ function WP_GPX_Maps_html_page() {
  • showspeed: show speed inside the chart (default is FALSE)
  • showhr: show heart rate inside the chart (default is FALSE)
  • showcad: show cadence inside the chart (default is FALSE)
  • -
  • uomspeed: the unit of measure of speed are: 0, 1, 2 (0 = m/s, 1 = km/h, 2 = miles/h)
  • +
  • uomspeed: the unit of measure of speed are: 0, 1, 2 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles)
  • chartFrom1: minimun value for altitude chart
  • chartTo1: maxumin value for altitude chart
  • chartFrom2: minimun value for speed chart
  • @@ -118,6 +118,7 @@ function WP_GPX_Maps_html_page() {
  • ngimages: NextGen Image id or a list of Images id separated by a comma
  • zoomonscrollwheel: zoom on map when mouse scroll wheel (default is FALSE)
  • download: Allow users to download your GPX file (default is FALSE)
  • +
  • summary: Print symmary details of your GPX (default is FALSE)
  • diff --git a/wp-gpx-maps_admin_settings.php b/wp-gpx-maps_admin_settings.php index b1d030b..e0a2fcc 100644 --- a/wp-gpx-maps_admin_settings.php +++ b/wp-gpx-maps_admin_settings.php @@ -19,7 +19,8 @@ $showHr = get_option('wpgpxmaps_show_hr'); $showCad = get_option('wpgpxmaps_show_cadence'); $zoomonscrollwheel = get_option("wpgpxmaps_zoomonscrollwheel"); - $download = get_option("wpgpxmaps_download"); + $download = get_option("wpgpxmaps_download"); + $summary = get_option("wpgpxmaps_summary"); if (!($t)) $t = 'HYBRID'; @@ -56,14 +57,21 @@ GPX Download: - onchange="this.value = (this.checked)" />Allow users to download your GPX file + onchange="this.value = (this.checked)" /> Allow users to download your GPX file + + Summary table: + + onchange="this.value = (this.checked)" /> Print summary table + + +

    - + " />

    @@ -79,13 +87,13 @@ On mouse scroll wheel: - onchange="this.value = (this.checked)" />Enable zoom + onchange="this.value = (this.checked)" /> Enable zoom Waypoints Support: - onchange="this.value = (this.checked)" />Show Waypoints + onchange="this.value = (this.checked)" /> Show Waypoints @@ -197,6 +205,8 @@ + + @@ -213,7 +223,7 @@ Show Heart Rate (where aviable): - onchange="this.value = (this.checked)" />Show heart rate + onchange="this.value = (this.checked)" /> Show heart rate @@ -227,7 +237,7 @@ Show Cadence (where aviable): - onchange="this.value = (this.checked)" />Show Cadence + onchange="this.value = (this.checked)" /> Show Cadence @@ -258,13 +268,13 @@ - Skip points closer than meters. + Skip points closer than meters. - onchange="this.value = (this.checked)" />Do not reduce gpx. + onchange="this.value = (this.checked)" /> Do not reduce gpx. diff --git a/wp-gpx-maps_utils.php b/wp-gpx-maps_utils.php index 7b5fa15..93c887c 100644 --- a/wp-gpx-maps_utils.php +++ b/wp-gpx-maps_utils.php @@ -125,6 +125,12 @@ $points->speed = array(); $points->hr = array(); $points->cad = array(); + $points->maxEle = 0; + $points->minEle = 0; + $points->totalEleUp = 0; + $points->totalEleDown = 0; + $points->avgSpeed = 0; + $points->totalLength = 0; $gpx = simplexml_load_file($filePath); @@ -202,6 +208,8 @@ $offset = calculateDistance((float)$lat, (float)$lon, (float)$ele, (float)$lastLat, (float)$lastLon, (float)$lastEle); $dist = $dist + $offset; + $points->totalLength = $dist; + if ($speed == 0) { $datediff = (float)my_date_diff($lastTime,$time); @@ -211,6 +219,18 @@ } } + if ($ele != 0 && $lastEle != 0) + { + if ((float)$ele > (float)$lastEle) + { + $points->totalEleUp += (float)($ele - $lastEle); + } + else + { + $points->totalEleDown += (float)($lastEle - $ele); + } + } + array_push($speedBuffer, $speed); if (((float) $offset + (float) $lastOffset) > $gpxOffset) @@ -249,6 +269,13 @@ $lastTime=$time; } unset($nodes); + + try { + $points->maxEle = max($points->ele); + $points->minEle = min($points->ele); + $points->totalLength = max($points->dist); + $points->avgSpeed = array_sum($points->speed) / count($points->speed); + } catch (Exception $e) { } } else @@ -311,6 +338,7 @@ $lastLon=$lon; } unset($nodes); + } else {