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 '
';
+
foreach( $tabs as $tab => $name ){
+
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
+
echo "$name";
+
}
+
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 <<
+
]
+
+
+
- gpx: relative path to gpx
+
- width: width in pixels
+
- mheight: map height
+
- gheight: graph height
+
- mtype: map available types are: HYBRID, ROADMAP, SATELLITE, TERRAIN, OSM1 (Open Street Map), OSM2 (Open Cycle Map), OSM3 (Hike & Bike), OSM4 (Open Cycle Map - Transport), OSM5 (Open Cycle Map - Landscape), OSM6 (MapToolKit - Terrain)
+
- waypoints: print the gpx waypoints inside the map (default is FALSE)
+
- donotreducegpx: print all the point without reduce it (default is FALSE)
+
- pointsoffset: skip points closer than XX meters(default is 10)
+
- uom: distance/altitude possible unit of measure are: 0, 1, 2, 3, 4, 5 (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles)
+
- mlinecolor: map line color (default is #3366cc)
+
- glinecolor: altitude line color (default is #3366cc)
+
- showspeed: show speed inside the chart (default is FALSE)
+
- showhr: show heart rate inside the chart (default is FALSE)
+
- showele: show elevation data inside the chart (default is TRUE)
+
- showcad: show cadence inside the chart (default is FALSE)
+
- showgrade: show grade inside the chart (default is FALSE)
+
- glinecolorspeed: speed line color (default is #ff0000)
+
- glinecolorhr: heart rate line color (default is #ff77bd)
+
- glinecolorcad: cadence line color (default is #beecff)
+
- glinecolorgrade: grade line color (default is #beecff)
+
- uomspeed: unit of measure for speed are: 0, 1, 2, 3, 4, 5 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters)
+
- chartFrom1: minimun value for altitude chart
+
- chartTo1: maxumin value for altitude chart
+
- chartFrom2: minimun value for speed chart
+
- chartTo2: maxumin value for speed chart
+
- startIcon: Start track icon
+
- endIcon: End track icon
+
- currentIcon: Current position icon (when mouse hover)
+
- waypointicon: waypoint custom icon
+
- nggalleries: NextGen Gallery id or a list of Galleries id separated by a comma
+
- ngimages: NextGen Image id or a list of Images id separated by a comma
+
- dtoffset: the difference (in seconds) between your gpx tool date and your camera date
+
- zoomonscrollwheel: zoom on map when mouse scroll wheel
+
- download: Allow users to download your GPX file
+
- skipcache: Do not use cache. If TRUE might be very slow (default is FALSE)
+
- summary: Print summary details of your GPX (default is FALSE)
+
- summarytotlen: Print Total distance in summary table (default is FALSE)
+
- summarymaxele: Print Max Elevation in summary table (default is FALSE)
+
- summaryminele: Print Min Elevation in summary table (default is FALSE)
+
- summaryeleup: Print Total climbing in summary table (default is FALSE)
+
- summaryeledown: Print Total descent in summary table (default is FALSE)
-
- summaryavgspeed: Print Average Speed in summary table (default is FALSE)
- summaryavgcad: Print Average Cadence in summary table (default is FALSE)
+
+
- summaryavgspeed: Print Average Speed in summary table (default is FALSE)
+
+
- summaryavgcad: Print Average Cadence in summary table (default is FALSE)
+
+
- summaryavghr: Print Average Heart Rate in summary table (default is FALSE)
+
+
- summaryavgtemp: Print Average Temperature in summary table (default is FALSE)
+
- summarytotaltime: Print Total time in summary table (default is FALSE)
+
+
+
+
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 @@
-
-
-
-
-
-
-
\ 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;
}