diff --git a/readme.txt b/readme.txt
index 218f9b9..da31bd1 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.04
+Stable tag: 1.6.05
Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map.
@@ -153,6 +153,9 @@ Yes!
1. Altitude & Speed & Hearth rate
== Changelog ==
+= 1.6.05 =
+* Added avg cadence (thanks to cyclinggeorgian)
+* fix cadence in old gpx devices
= 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 73fae19..0efcc0c 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.04
+ * Version: 1.6.05
* Author: Bastianon Massimo
* Author URI: http://www.devfarm.it/
* Text Domain: wp-gpx-maps
@@ -280,6 +280,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$p_total_ele_up = wpgpxmaps_findValue($attr, "summaryeleup", "wpgpxmaps_summary_total_ele_up", false);
$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);
$usegpsposition = wpgpxmaps_findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false);
@@ -296,7 +297,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,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9";
+ $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 = md5($cacheFileName);
@@ -332,6 +333,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = $cache_obj["total_ele_up"];
$total_ele_down = $cache_obj["total_ele_down"];
$avg_speed = $cache_obj["avg_speed"];
+ $avg_cad = $cache_obj["avg_cad"];
$tot_len = $cache_obj["tot_len"];
} catch (Exception $e) {
@@ -354,6 +356,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = 0;
$total_ele_down = 0;
$avg_speed = 0;
+ $avg_cad = 0;
$tot_len = 0;
}
}
@@ -402,6 +405,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$total_ele_up = $points->totalEleUp;
$total_ele_down = $points->totalEleDown;
$avg_speed = $points->avgSpeed;
+ $avg_cad = $points->avgCad;
$tot_len = $points->totalLength;
if (is_array ($points_x_lat))
@@ -637,6 +641,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
"total_ele_up" => $total_ele_up,
"total_ele_down" => $total_ele_down,
"avg_speed" => $avg_speed,
+ "avg_cad" => $avg_cad,
"tot_len" => $tot_len,
"max_time" => $max_time,
"min_time" => $min_time
@@ -744,6 +749,10 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
{
$output .= "".__("Average speed", "wp-gpx-maps").": $avg_speed
";
}
+ if ($points_graph_cad != '' && $p_avg_cad == 'true')
+ {
+ $output .= "".__("Average cadence", "wp-gpx-maps").": $avg_cad
";
+ }
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 4b5e65b..2254486 100644
--- a/wp-gpx-maps_admin.php
+++ b/wp-gpx-maps_admin.php
@@ -1,159 +1,159 @@
- '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)
-
- summarytotaltime: Print Total time in summary table (default is FALSE)
-
-
-
- Bugs, problems, thanks and anything else here!
-
-
-
-
-
- '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)
+
- 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 44ebe19..a430567 100644
--- a/wp-gpx-maps_admin_settings.php
+++ b/wp-gpx-maps_admin_settings.php
@@ -1,459 +1,459 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wp-gpx-maps_admin_tracks.php b/wp-gpx-maps_admin_tracks.php
index 5a95bab..0fe5302 100644
--- a/wp-gpx-maps_admin_tracks.php
+++ b/wp-gpx-maps_admin_tracks.php
@@ -1,206 +1,206 @@
-
-
-
-
-
-
-
-
-
-
-
-
- please make folder writable.
-
-
-
- $entry has been deleted.";
- }
- else {
- echo "
Can't delete $entry.";
-
- }
- }
- else
- {
- $myFile = $realGpxPath . "/" . $entry;
- $myGpxFileNames[] = array(
- 'name' => $entry,
- 'size' => filesize( $myFile ),
- 'lastedit' => filemtime( $myFile ),
- 'nonce' => wp_create_nonce( 'wpgpx_deletefile_nonce_' . $entry ),
- );
-
- }
-
- }
- }
- closedir($handle);
- }
-
- if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
- while (false !== ($entry = readdir($handle))) {
- if (preg_match($gpxRegEx,$entry ))
- {
- $filenames[] = $realGpxPath . "/" . $entry;
- }
- }
- closedir($handle);
- }
-
- $wpgpxmaps_gpxRelativePath = get_site_url(null, '/wp-content/uploads/gpx/');
-
-?>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/wp-gpx-maps_utils.php b/wp-gpx-maps_utils.php
index 4d9b009..bc51acf 100644
--- a/wp-gpx-maps_utils.php
+++ b/wp-gpx-maps_utils.php
@@ -211,6 +211,7 @@
$points->totalEleUp = 0;
$points->totalEleDown = 0;
$points->avgSpeed = 0;
+ $points->avgCad = 0;
$points->totalLength = 0;
$gpx = simplexml_load_file($filePath);
@@ -235,7 +236,6 @@
$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,6 +272,13 @@
$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'];
@@ -361,10 +368,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) );
}
@@ -415,13 +420,18 @@
$_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);
$points->avgSpeed = array_sum($_speed) / count($_speed);
+
+
} catch (Exception $e) { }
}