diff --git a/readme.txt b/readme.txt index da31bd1..89f6ee8 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Requires at least: 2.0.0 Tested up to: 4.9.8 -Stable tag: 1.6.05 +Stable tag: 1.6.06 Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. @@ -153,9 +153,8 @@ Yes! 1. Altitude & Speed & Hearth rate == Changelog == -= 1.6.05 = -* Added avg cadence (thanks to cyclinggeorgian) -* fix cadence in old gpx devices += 1.6.06 = +* Added average values under the graph (thanks to cyclinggeorgian) = 1.6.04 = * NGG gallery is working * Getting HR, Cad and Temp working again (thanks to cyclinggeorgian) diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index 0efcc0c..c0e2301 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -3,7 +3,7 @@ * Plugin Name: WP-GPX-Maps * Plugin URI: http://www.devfarm.it/ * Description: Draws a GPX track with altitude chart - * Version: 1.6.05 + * Version: 1.6.06 * Author: Bastianon Massimo * Author URI: http://www.devfarm.it/ * Text Domain: wp-gpx-maps @@ -281,7 +281,9 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') $p_total_ele_down = wpgpxmaps_findValue($attr, "summaryeledown", "wpgpxmaps_summary_total_ele_down", false); $p_avg_speed = wpgpxmaps_findValue($attr, "summaryavgspeed", "wpgpxmaps_summary_avg_speed", false); $p_avg_cad = wpgpxmaps_findValue($attr, "summaryavgcad", "wpgpxmaps_summary_avg_cad", false); - $p_total_time = wpgpxmaps_findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false); + $p_avg_hr = wpgpxmaps_findValue($attr, "summaryavghr", "wpgpxmaps_summary_avg_hr", false); + $p_avg_temp = wpgpxmaps_findValue($attr, "summaryavgtemp", "wpgpxmaps_summary_avg_temp", false); + $p_total_time = wpgpxmaps_findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false); $usegpsposition = wpgpxmaps_findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false); $currentpositioncon = wpgpxmaps_findValue($attr, "currentpositioncon", "wpgpxmaps_currentpositioncon", ""); @@ -297,7 +299,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') } else { $mtime = 0; } - $cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$avg_cad,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9"; + $cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9"; $cacheFileName = md5($cacheFileName); @@ -334,6 +336,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') $total_ele_down = $cache_obj["total_ele_down"]; $avg_speed = $cache_obj["avg_speed"]; $avg_cad = $cache_obj["avg_cad"]; + $avg_hr = $cache_obj["avg_hr"]; + $avg_temp = $cache_obj["avg_temp"]; $tot_len = $cache_obj["tot_len"]; } catch (Exception $e) { @@ -357,6 +361,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') $total_ele_down = 0; $avg_speed = 0; $avg_cad = 0; + $avgv_hr = 0; + $avg_temp = 0; $tot_len = 0; } } @@ -406,6 +412,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') $total_ele_down = $points->totalEleDown; $avg_speed = $points->avgSpeed; $avg_cad = $points->avgCad; + $avg_hr = $points->avgHr; + $avg_temp = $points->avgTemp; $tot_len = $points->totalLength; if (is_array ($points_x_lat)) @@ -549,11 +557,6 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') if ($showW == true) { $wpoints = wpgpxmaps_getWayPoints($gpx); - /* - foreach ($wpoints as $p) { - $waypoints .= '['.number_format ( (float)$p[0] , 7 , '.' , '' ).','.number_format ( (float)$p[1] , 7 , '.' , '' ).',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],'; - } - */ $waypoints = json_encode($wpoints); } @@ -642,6 +645,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') "total_ele_down" => $total_ele_down, "avg_speed" => $avg_speed, "avg_cad" => $avg_cad, + "avg_hr" => $avg_hr, + "avg_temp" => $avg_temp, "tot_len" => $tot_len, "max_time" => $max_time, "min_time" => $min_time @@ -753,6 +758,16 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='') { $output .= "".__("Average cadence", "wp-gpx-maps").": $avg_cad
"; } + if ($points_graph_hr != '' && $p_avg_hr == 'true') + { + $output .= "".__("Average Heartrate", "wp-gpx-maps").": $avg_hr
"; + } + + if ($points_graph_atemp != '' && $p_avg_temp == 'true') + { + $output .= "".__("Average Temperature", "wp-gpx-maps").": $avg_temp
"; + } + if ($p_total_time == 'true' && $max_time > 0) { $time_diff = date("H:i:s", ($max_time - $min_time)); diff --git a/wp-gpx-maps_admin.php b/wp-gpx-maps_admin.php index 2254486..3432774 100644 --- a/wp-gpx-maps_admin.php +++ b/wp-gpx-maps_admin.php @@ -1,159 +1,323 @@ 'Tracks', 'settings' => 'Settings', 'help' => "help" ); + } + else if ( current_user_can('publish_posts') ) { + $tabs = array( 'tracks' => 'Tracks', 'help' => "help" ); + } + + echo ''; + } + + function WP_GPX_Maps_html_page() { + $realGpxPath = gpxFolderPath(); + $cacheGpxPath = gpxCacheFolderPath(); + $relativeGpxPath = relativeGpxFolderPath(); + $relativeGpxPath = str_replace("\\","/", $relativeGpxPath); + + $tab = $_GET['tab']; + + if ($tab == '') + $tab = 'tracks'; + + ?> +

+

WP GPX Settings

+ + Can\'t create '.$realGpxPath.' folder. Please create it and make it writable!
+ If not, you will must update the file manually! + '; + } + } + + if(file_exists($cacheGpxPath) && is_dir($cacheGpxPath)) + { + //dir exsist! + } + else + { + if (!@mkdir($cacheGpxPath,0755,true)) { + echo '
+ Can\'t create '.$cacheGpxPath.' folder. Please create it and make it writable!
+ If not, cache will not created and your site could be slower! +
'; + } + } + + wpgpxmaps_ilc_admin_tabs($tab); + + if ($tab == "tracks") + { + include 'wp-gpx-maps_admin_tracks.php'; + } + else if ($tab == "settings") + { + include 'wp-gpx-maps_admin_settings.php'; + } + else if ($tab == "help") + { + ?> + +
+ The fastest way to use this plugin:
upload the file using the uploader in the first tab, than copy the shortcode from the list and paste it in the pages/posts. +

You can manually set the relative path to your gpx: [sgpx gpx="< gpx file name >"].

+

You can also use gpx from other sites: [sgpx gpx="http://www.someone.com/somewhere/somefile.gpx"]

+
+

+ Full set of attributes: [sgpx gpx="< gpx file name >" +    >> read below all the optional attributes <<    + ] + +

+ +

+ Bugs, problems, thanks and anything else here! +

+ +

+
+ + \ No newline at end of file + +?> diff --git a/wp-gpx-maps_admin_settings.php b/wp-gpx-maps_admin_settings.php index a430567..db8d3e1 100644 --- a/wp-gpx-maps_admin_settings.php +++ b/wp-gpx-maps_admin_settings.php @@ -1,8 +1,8 @@ -
+ + - +

General

- + @@ -55,18 +57,21 @@ + + + - + + + - - - - + +
Width:
Map Height:
Graph Height:
Distance type: @@ -77,42 +82,40 @@
Cache: onchange="this.value = (this.checked)" /> Do not use cache
GPX Download: onchange="this.value = (this.checked)" /> Allow users to download your GPX file
Use browser GPS position: onchange="this.value = (this.checked)" /> Allow users to use browser GPS in order to display their current position on map
Google maps api key: - Go to the Google API Console and click ‘Get A Key’ -
Thunderforest api key (Open Cycle Map): Go to Thunderforest API Keys and click ‘signing in to your Thunderforest account’
- +

- + " />

@@ -120,108 +123,131 @@
+ -

Summary table

- + + + + + + - + + - + + + + + + + + + + + + + + + + + - +
Summary table: onchange="this.value = (this.checked)" /> Print summary table
Total distance: onchange="this.value = (this.checked)" /> Print Total distance
Max Elevation: onchange="this.value = (this.checked)" /> Print Max Elevation
Min Elevation: onchange="this.value = (this.checked)" /> Print Min Elevation
Total climbing: onchange="this.value = (this.checked)" /> Print Total climbing
Total descent:Total Descent: onchange="this.value = (this.checked)" /> Print Total descent
Average Speed: onchange="this.value = (this.checked)" /> Print Average Speed
Average Cadence: onchange="this.value = (this.checked)" /> Print Average Cadence
Average Cadence: + onchange="this.value = (this.checked)" /> Print Average Cadence +
Average Heart Rate: + onchange="this.value = (this.checked)" /> Print Average Heart Rate +
Average Temperature: + onchange="this.value = (this.checked)" /> Print Average Temperature +
Total time: onchange="this.value = (this.checked)" /> Print Total time
- +

- + " />

-
- -
+ -

Map

+ + + + - + - + - + - + - + - -
On mouse scroll wheel: onchange="this.value = (this.checked)" /> Enable zoom
Waypoints Support: onchange="this.value = (this.checked)" /> Show Waypoints
Map line color:
Default Map Type: - > Open Street Map
> Open Cycle Map
> Open Cycle Map - Transport
@@ -229,50 +255,47 @@ > Hike & Bike
> MapToolKit - Terrain
> Open Street Map - Humanitarian map style
- > Hike & Bike
> Open Sea Map
Start Icon: (Url to image) Leave empty to hide
End Icon: (Url to image) Leave empty to hide
Current Position Icon: (Url to image) Leave empty for default
Current GPS Position Icon: (Url to image) Leave empty for default
Custom Waypoint Icon: (Url to image) Leave empty for default
+ +

@@ -282,13 +305,13 @@


-
+ -

Chart

- + + + @@ -303,7 +327,9 @@ + + + + + + - + + + + + + - + + - - + + - - + +
Show altitude: @@ -296,6 +319,7 @@
Altitude line color:
Unit of measure:
Altitude display offset: @@ -325,18 +352,21 @@ (leave empty for auto scale)
Show speed: onchange="this.value = (this.checked)" /> Show Speed
Speed line color:
Speed unit of measure: @@ -349,7 +379,8 @@
Speed display offset: @@ -360,47 +391,51 @@ (leave empty for auto scale)
Show Heart Rate (where aviable): onchange="this.value = (this.checked)" /> Show heart rate
Heart rate line color:
Show Temperature (where aviable): onchange="this.value = (this.checked)" /> Show Temperature
Temperature line color:
Show Cadence (where aviable): onchange="this.value = (this.checked)" /> Show Cadence
Cadence line color:
Show Grade: @@ -409,6 +444,7 @@ (Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!)
Grade line color: @@ -419,6 +455,7 @@

+ " /> @@ -426,26 +463,27 @@


-
+ -

Advanced options (Do not edit if you don't know what you are doing!)

- + + +
Skip points closer than meters.
onchange="this.value = (this.checked)" /> Do not reduce gpx.
@@ -456,4 +494,5 @@

-
\ No newline at end of file + +
diff --git a/wp-gpx-maps_utils.php b/wp-gpx-maps_utils.php index bc51acf..7d902e2 100644 --- a/wp-gpx-maps_utils.php +++ b/wp-gpx-maps_utils.php @@ -212,6 +212,8 @@ $points->totalEleDown = 0; $points->avgSpeed = 0; $points->avgCad = 0; + $points->avgHr = 0; + $points->avgTemp = 0; $points->totalLength = 0; $gpx = simplexml_load_file($filePath); @@ -236,6 +238,7 @@ $trk->registerXPathNamespace('a', 'http://www.topografix.com/GPX/1/0'); $trk->registerXPathNamespace('b', 'http://www.topografix.com/GPX/1/1'); + $trk->registerXPathNamespace('ns3', 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1'); $trkpts = $trk->xpath('//trkpt | //a:trkpt | //b:trkpt'); @@ -272,13 +275,6 @@ $atemp = @$tpe["ns3:atemp"]; $cad = @$tpe["ns3:cad"]; } - else if (isset($arr['gpxtpx:TrackPointExtension'])) - { - $tpe = $arr['gpxtpx:TrackPointExtension']; - $hr = @$tpe["gpxtpx:hr"]; - $atemp = @$tpe["gpxtpx:atemp"]; - $cad = @$tpe["gpxtpx:cad"]; - } else if (isset($arr['TrackPointExtension'])) { $tpe = $arr['TrackPointExtension']; @@ -368,8 +364,8 @@ array_push($points->dist, (float)round($dist, 2) ); array_push($points->speed, (float)round($avgSpeed, 1) ); array_push($points->hr, $hr); - array_push($points->atemp, $atemp); - array_push($points->cad, $cad); + array_push($points->atemp, $atemp); + array_push($points->cad, $cad); array_push($points->grade, (float)round($grade, 2) ); } @@ -419,18 +415,27 @@ $_time = array_filter($points->dt); $_ele = array_filter($points->ele); $_dist = array_filter($points->dist); - $_speed = array_filter($points->speed); - $_cad = array_filter($points->cad); - $points->maxEle = max($_ele); $points->minEle = min($_ele); $points->totalLength = max($_dist); $points->maxTime = max($_time); $points->minTime = min($_time); - - $points->avgCad = (float)round(array_sum($_cad) / count($_cad), 0); + + // Calculating Average Speed + $_speed = array_filter($points->speed); $points->avgSpeed = array_sum($_speed) / count($_speed); + // Calculating Average Cadence + $_cad = array_filter($points->cad); + $points->avgCad = (float)round(array_sum($_cad) / count($_cad), 0); + + // Calculating Average Heart Rate + $_hr = array_filter($points->hr); + $points->avgHr = (float)round(array_sum($_hr) / count($_hr), 0); + + // Calculating Average Temperature + $_temp = array_filter($points->atemp); + $points->avgTemp = (float)round(array_sum($_temp) / count($_temp), 1); } catch (Exception $e) { } @@ -683,9 +688,7 @@ $t2 += date_getDecimals($old_date); $offset = (float)($t1 - $t2); - - //echo "$offset = $new_date - $old_date; ".strtotime($new_date)." ".strtotime($old_date)."
"; - + return $offset; }