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 ''; -} - -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! -

- -

-
- - '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 44ebe19..a430567 100644 --- a/wp-gpx-maps_admin_settings.php +++ b/wp-gpx-maps_admin_settings.php @@ -1,459 +1,459 @@ - - -
- - - -

General

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Width: - -
Map Height: - -
Graph Height: - -
Distance type: - -
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’ -
- -

- - - " /> -

- -
- -
- -
- - - -

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 -
Min Elevation: - onchange="this.value = (this.checked)" /> Print Total climbing -
Min Elevation: - onchange="this.value = (this.checked)" /> Print Total descent -
Min Elevation: - onchange="this.value = (this.checked)" /> Print Average Speed -
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
- > Open Cycle Map - Landscape
- > 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 -
- -

- - - " /> -

- -
-
-
- - - -

Chart

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Show altitude: - onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" /> Show Altitude - -
Altitude line color: - -
Unit of measure: - -
Altitude display offset: - From - - To - - (leave empty for auto scale) -
Show speed: - onchange="this.value = (this.checked)" /> Show Speed -
Speed line color: - -
Speed unit of measure: - -
Speed display offset: - From - - To - - (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: - onchange="this.value = (this.checked)" /> Show Grade - BETA -
- (Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!) -
Grade line color: - -
- -

- - - " /> -

- -
-
-
- - - -

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. -
- - - - -

- " /> -

- -
+ + +
+ + + +

General

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Width: + +
Map Height: + +
Graph Height: + +
Distance type: + +
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’ +
+ +

+ + + " /> +

+ +
+ +
+ +
+ + + +

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: + 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
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
+ > Open Cycle Map - Landscape
+ > 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 +
+ +

+ + + " /> +

+ +
+
+
+ + + +

Chart

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Show altitude: + onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" /> Show Altitude + +
Altitude line color: + +
Unit of measure: + +
Altitude display offset: + From + + To + + (leave empty for auto scale) +
Show speed: + onchange="this.value = (this.checked)" /> Show Speed +
Speed line color: + +
Speed unit of measure: + +
Speed display offset: + From + + To + + (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: + onchange="this.value = (this.checked)" /> Show Grade - BETA +
+ (Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!) +
Grade line color: + +
+ +

+ + + " /> +

+ +
+
+
+ + + +

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. +
+ + + + +

+ " /> +

+ +

\ 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 @@ - - -
-
- Choose a file to upload: - File ". $uploadingFileName . " has been uploaded"; - } else{ - echo "
There was an error uploading the file, please try again!"; - } - } - else - { - echo "file not supported!"; - } - } - } - ?> -
- -
- -
- -
- - -
-
-

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) { } }