version 1.6.06

* Added average values under the graph
This commit is contained in:
bastianonm 2019-01-03 11:11:14 +00:00
parent 27964e6587
commit 6d27b35231
5 changed files with 310 additions and 90 deletions

View File

@ -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)

View File

@ -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 .= "<span class='avgcad'><span class='summarylabel'>".__("Average cadence", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_cad</span></span><br />";
}
if ($points_graph_hr != '' && $p_avg_hr == 'true')
{
$output .= "<span class='avghr'><span class='summarylabel'>".__("Average Heartrate", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_hr</span></span><br />";
}
if ($points_graph_atemp != '' && $p_avg_temp == 'true')
{
$output .= "<span class='avgtemp'><span class='summarylabel'>".__("Average Temperature", "wp-gpx-maps").":</span><span class='summaryvalue'> $avg_temp</span></span><br />";
}
if ($p_total_time == 'true' && $max_time > 0)
{
$time_diff = date("H:i:s", ($max_time - $min_time));

View File

@ -1,159 +1,323 @@
<?php
if ( is_admin() ){
add_action('admin_menu', 'wpgpxmaps_admin_menu');
}
function wpgpxmaps_admin_menu() {
if ( current_user_can('manage_options') ){
add_options_page('WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page');
}
else if ( current_user_can('publish_posts') ) {
add_menu_page('WP GPX Maps', 'WP GPX Maps', 'publish_posts', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page');
}
}
function wpgpxmaps_ilc_admin_tabs( $current ) {
if (current_user_can('manage_options'))
{
$tabs = array( 'tracks' => 'Tracks', 'settings' => 'Settings', 'help' => "help" );
}
else if ( current_user_can('publish_posts') ) {
$tabs = array( 'tracks' => 'Tracks', 'help' => "help" );
}
echo '<h2 class="nav-tab-wrapper">';
foreach( $tabs as $tab => $name ){
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>";
}
echo '</h2>';
}
function WP_GPX_Maps_html_page() {
$realGpxPath = gpxFolderPath();
$cacheGpxPath = gpxCacheFolderPath();
$relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace("\\","/", $relativeGpxPath);
$tab = $_GET['tab'];
if ($tab == '')
$tab = 'tracks';
?>
<div id="icon-themes" class="icon32"><br></div>
<h2>WP GPX Settings</h2>
<?php
if(file_exists($realGpxPath) && is_dir($realGpxPath))
{
//dir exsist!
}
else
{
if (!@mkdir($realGpxPath,0755,true)) {
echo '<div class="error" style="padding:10px">
Can\'t create <b>'.$realGpxPath.'</b> folder. Please create it and make it writable!<br />
If not, you will must update the file manually!
</div>';
}
}
if(file_exists($cacheGpxPath) && is_dir($cacheGpxPath))
{
//dir exsist!
}
else
{
if (!@mkdir($cacheGpxPath,0755,true)) {
echo '<div class="error" style="padding:10px">
Can\'t create <b>'.$cacheGpxPath.'</b> folder. Please create it and make it writable!<br />
If not, cache will not created and your site could be slower!
</div>';
}
}
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")
{
?>
<div style="padding:10px;">
<b>The fastest way to use this plugin:</b><br /> upload the file using the uploader in the first tab, than copy the shortcode from the list and paste it in the pages/posts.
<p>You can manually set the relative path to your gpx: <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt"]</b>.</p>
<p>You can also use gpx from other sites: <b>[sgpx gpx="http://www.someone.com/somewhere/somefile.gpx"]</b></p>
<hr />
<p>
<i>Full set of attributes:</i> <b>[sgpx gpx="<?php echo $relativeGpxPath; ?>&lt gpx file name &gt" </b>
&nbsp;&nbsp;&nbsp;<em>&gt&gt read below all the optional attributes &lt&lt</em>&nbsp;&nbsp;&nbsp;
<b>]</b>
<ul>
<li><b>gpx</b>: relative path to gpx
</li><li><b>width</b>: width in pixels
</li><li><b>mheight</b>: map height
</li><li><b>gheight</b>: graph height
</li><li><b>mtype</b>: 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)
</li><li><b>waypoints</b>: print the gpx waypoints inside the map (default is FALSE)
</li><li><b>donotreducegpx</b>: print all the point without reduce it (default is FALSE)
</li><li><b>pointsoffset</b>: skip points closer than XX meters(default is 10)
</li><li><b>uom</b>: 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)
</li><li><b>mlinecolor</b>: map line color (default is #3366cc)
</li><li><b>glinecolor</b>: altitude line color (default is #3366cc)
</li><li><b>showspeed</b>: show speed inside the chart (default is FALSE)
</li><li><b>showhr</b>: show heart rate inside the chart (default is FALSE)
</li><li><b>showele</b>: show elevation data inside the chart (default is TRUE)
</li><li><b>showcad</b>: show cadence inside the chart (default is FALSE)
</li><li><b>showgrade</b>: show grade inside the chart (default is FALSE)
</li><li><b>glinecolorspeed</b>: speed line color (default is #ff0000)
</li><li><b>glinecolorhr</b>: heart rate line color (default is #ff77bd)
</li><li><b>glinecolorcad</b>: cadence line color (default is #beecff)
</li><li><b>glinecolorgrade</b>: grade line color (default is #beecff)
</li><li><b>uomspeed</b>: 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)
</li><li><b>chartFrom1</b>: minimun value for altitude chart
</li><li><b>chartTo1</b>: maxumin value for altitude chart
</li><li><b>chartFrom2</b>: minimun value for speed chart
</li><li><b>chartTo2</b>: maxumin value for speed chart
</li><li><b>startIcon</b>: Start track icon
</li><li><b>endIcon</b>: End track icon
</li><li><b>currentIcon</b>: Current position icon (when mouse hover)
</li><li><b>waypointicon</b>: waypoint custom icon
</li><li><b>nggalleries</b>: NextGen Gallery id or a list of Galleries id separated by a comma
</li><li><b>ngimages</b>: NextGen Image id or a list of Images id separated by a comma
</li><li><b>dtoffset</b>: the difference (in seconds) between your gpx tool date and your camera date
</li><li><b>zoomonscrollwheel</b>: zoom on map when mouse scroll wheel
</li><li><b>download</b>: Allow users to download your GPX file
</li><li><b>skipcache</b>: Do not use cache. If TRUE might be very slow (default is FALSE)
</li><li><b>summary</b>: Print summary details of your GPX (default is FALSE)
</li><li><b>summarytotlen</b>: Print Total distance in summary table (default is FALSE)
</li><li><b>summarymaxele</b>: Print Max Elevation in summary table (default is FALSE)
</li><li><b>summaryminele</b>: Print Min Elevation in summary table (default is FALSE)
</li><li><b>summaryeleup</b>: Print Total climbing in summary table (default is FALSE)
</li><li><b>summaryeledown</b>: Print Total descent in summary table (default is FALSE)
</li><li><b>summaryavgspeed</b>: Print Average Speed in summary table (default is FALSE)</li><li><b>summaryavgcad</b>: Print Average Cadence in summary table (default is FALSE)
</li><li><b>summaryavgspeed</b>: Print Average Speed in summary table (default is FALSE)
</li><li><b>summaryavgcad</b>: Print Average Cadence in summary table (default is FALSE)
</li><li><b>summaryavghr</b>: Print Average Heart Rate in summary table (default is FALSE)
</li><li><b>summaryavgtemp</b>: Print Average Temperature in summary table (default is FALSE)
</li><li><b>summarytotaltime</b>: Print Total time in summary table (default is FALSE) </li>
</ul>
<p>
<a href="http://devfarm.it/forums/forum/wp-gpx-maps/">Bugs, problems, thanks and anything else here!</a>
</p>
</p>
</div>
<?php
}
}
?>
?>

View File

@ -1,8 +1,8 @@
<?php
if ( !current_user_can('manage_options') )
return;
return;
$po = get_option('wpgpxmaps_pointsoffset');
$showW = get_option("wpgpxmaps_show_waypoint");
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
@ -13,41 +13,43 @@
$showSpeed = get_option('wpgpxmaps_show_speed');
$showHr = get_option('wpgpxmaps_show_hr');
$showAtemp = get_option('wpgpxmaps_show_atemp');
$showCad = get_option('wpgpxmaps_show_cadence');
$showGrade = get_option('wpgpxmaps_show_grade');
$zoomonscrollwheel = get_option("wpgpxmaps_zoomonscrollwheel");
$download = get_option("wpgpxmaps_download");
$skipcache = get_option("wpgpxmaps_skipcache");
$summary = get_option("wpgpxmaps_summary");
$tot_len = get_option("wpgpxmaps_summary_tot_len");
$min_ele = get_option("wpgpxmaps_summary_min_ele");
$max_ele = get_option("wpgpxmaps_summary_max_ele");
$total_ele_up = get_option("wpgpxmaps_summary_total_ele_up");
$total_ele_down = get_option("wpgpxmaps_summary_total_ele_down");
$avg_speed = get_option("wpgpxmaps_summary_avg_speed"); $avg_cad = get_option("wpgpxmaps_summary_avg_cad");
$avg_speed = get_option("wpgpxmaps_summary_avg_speed");
$avg_cad = get_option("wpgpxmaps_summary_avg_cad");
$$avg_hr = get_option("wpgpxmaps_summary_avg_hr");
$avg_temp = get_option("wpgpxmaps_summary_avg_temp");
$total_time = get_option("wpgpxmaps_summary_total_time");
$usegpsposition = get_option("wpgpxmaps_usegpsposition");
$distanceType = get_option("wpgpxmaps_distance_type");
if (empty($showEle))
$showEle = "true";
if (!($t))
$t = 'HYBRID';
if (!($po))
$po = 10;
?>
<form method="post" action="options.php">
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<h3 class="title">General</h3>
<table class="form-table">
<tr>
<th scope="row">Width:</th>
@ -55,18 +57,21 @@
<input name="wpgpxmaps_width" type="text" id="wpgpxmaps_width" value="<?php echo get_option('wpgpxmaps_width'); ?>" style="width:50px;" />
</td>
</tr>
<tr>
<th scope="row">Map Height:</th>
<td>
<input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />
</td>
</tr>
<tr>
<th scope="row">Graph Height:</th>
<td>
<input name="wpgpxmaps_graph_height" type="text" id="wpgpxmaps_graph_height" value="<?php echo get_option('wpgpxmaps_graph_height'); ?>" style="width:50px;" />
</td>
</tr>
<tr>
<th scope="row">Distance type:</th>
<td>
@ -77,42 +82,40 @@
</select>
</td>
</tr>
<tr>
<th scope="row">Cache:</th>
<td>
<input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if($skipcache == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Do not use cache</i>
</td>
</tr>
<tr>
<th scope="row">GPX Download:</th>
<td>
<input name="wpgpxmaps_download" type="checkbox" value="true" <?php if($download == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to download your GPX file</i>
</td>
</tr>
<tr>
<th scope="row">Use browser GPS position:</th>
<td>
<input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if($usegpsposition == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Allow users to use browser GPS in order to display their current position on map</i>
</td>
</tr>
<tr>
<th scope="row">Google maps api key:</th>
<td>
<input name="wpgpxmaps_googlemapsv3_apikey" type="text" id="wpgpxmaps_googlemapsv3_apikey" value="<?php echo get_option('wpgpxmaps_googlemapsv3_apikey'); ?>" style="width:400px" /> <em> Go to the <a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">Google API Console</a> and click &#8216;Get A Key&#8217; </em>
</td>
</tr>
<tr>
<th scope="row">Thunderforest api key (Open Cycle Map):</th>
<td>
<input name="wpgpxmaps_openstreetmap_apikey" type="text" id="wpgpxmaps_openstreetmap_apikey" value="<?php echo get_option('wpgpxmaps_openstreetmap_apikey'); ?>" style="width:400px" /> <em> Go to <a href="http://www.thunderforest.com/docs/apikeys/" target="_blank">Thunderforest API Keys</a> and click &#8216;signing in to your Thunderforest account&#8217; </em>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition,wpgpxmaps_googlemapsv3_apikey,wpgpxmaps_openstreetmap_apikey" />
<input name="page_options" type="hidden" value="wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_download,wpgpxmaps_skipcache,wpgpxmaps_distance_type,wpgpxmaps_usegpsposition,wpgpxmaps_openstreetmap_apikey" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p>
@ -120,108 +123,131 @@
<hr />
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<h3 class="title">Summary table</h3>
<table class="form-table">
<tr>
<th scope="row">Summary table:</th>
<td>
<input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if($summary == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print summary table</i>
</td>
</tr>
<tr>
<th scope="row">Total distance:</th>
<td>
<input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if($tot_len == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total distance</i>
</td>
</tr>
<tr>
<th scope="row">Max Elevation:</th>
<td>
<input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if($max_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Max Elevation</i>
</td>
</tr>
<tr>
<th scope="row">Min Elevation:</th>
<td>
<input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if($min_ele == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Min Elevation</i>
</td>
</tr>
<tr>
<th scope="row">Total climbing:</th>
<td>
<input name="wpgpxmaps_summary_total_ele_up" type="checkbox" value="true" <?php if($total_ele_up == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total climbing</i>
</td>
</tr>
<tr>
<th scope="row">Total descent:</th>
<th scope="row">Total Descent:</th>
<td>
<input name="wpgpxmaps_summary_total_ele_down" type="checkbox" value="true" <?php if($total_ele_down == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total descent</i>
</td>
</tr>
<tr>
<th scope="row">Average Speed:</th>
<td>
<input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if($avg_speed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Speed</i>
</td>
</tr> <tr> <th scope="row">Average Cadence:</th> <td> <input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if($avg_cad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Cadence</i> </td> </tr>
</tr>
<tr>
<th scope="row">Average Cadence:</th>
<td>
<input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if($avg_cad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Cadence</i>
</td>
</tr>
<tr>
<th scope="row">Average Heart Rate:</th>
<td>
<input name="wpgpxmaps_summary_avg_hr" type="checkbox" value="true" <?php if($avg_hr == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Heart Rate</i>
</td>
</tr>
<tr>
<th scope="row">Average Temperature:</th>
<td>
<input name="wpgpxmaps_summary_avg_temp" type="checkbox" value="true" <?php if($avg_temp == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Average Temperature</i>
</td>
</tr>
<tr>
<th scope="row">Total time:</th>
<td>
<input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if($total_time == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Print Total time</i>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_summary,wpgpxmaps_summary_tot_len,wpgpxmaps_summary_max_ele,wpgpxmaps_summary_min_ele,wpgpxmaps_summary_total_ele_up,wpgpxmaps_summary_total_ele_down,wpgpxmaps_summary_avg_speed,wpgpxmaps_summary_avg_cad,wpgpxmaps_summary_total_time" />
<input name="page_options" type="hidden" value="wpgpxmaps_summary,wpgpxmaps_summary_tot_len,wpgpxmaps_summary_max_ele,wpgpxmaps_summary_min_ele,wpgpxmaps_summary_total_ele_up,wpgpxmaps_summary_total_ele_down,wpgpxmaps_summary_avg_speed,wpgpxmaps_summary_avg_cad,wpgpxmaps_summary_avg_hr,wpgpxmaps_summary_avg_temp,wpgpxmaps_summary_total_time" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
</p>
</form>
<hr />
<form method="post" action="options.php">
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<h3 class="title">Map</h3>
<table class="form-table">
<tr>
<th scope="row">On mouse scroll wheel:</th>
<td>
<input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if($zoomonscrollwheel == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Enable zoom</i>
</td>
</tr>
<tr>
<th scope="row">Waypoints Support:</th>
<td>
<input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if($showW == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Waypoints</i>
</td>
</tr>
<tr>
<th scope="row">Map line color:</th>
<td>
<input name="wpgpxmaps_map_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_map_line_color'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Default Map Type:</th>
<td>
<!--
<input type="radio" name="wpgpxmaps_map_type" value="HYBRID" <?php if ($t == 'HYBRID') echo 'checked'; ?> > HYBRID: transparent layer of major streets on satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="ROADMAP" <?php if ($t == 'ROADMAP') echo 'checked'; ?>> ROADMAP: normal street map.<br />
<input type="radio" name="wpgpxmaps_map_type" value="SATELLITE" <?php if ($t == 'SATELLITE') echo 'checked'; ?>> SATELLITE: satellite images.<br />
<input type="radio" name="wpgpxmaps_map_type" value="TERRAIN" <?php if ($t == 'TERRAIN') echo 'checked'; ?>> TERRAIN: maps with physical features such as terrain and vegetation.<br />
-->
<input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ($t == 'OSM1') echo 'checked'; ?>> Open Street Map<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ($t == 'OSM2') echo 'checked'; ?>> Open Cycle Map<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ($t == 'OSM4') echo 'checked'; ?>> Open Cycle Map - Transport<br />
@ -229,50 +255,47 @@
<input type="radio" name="wpgpxmaps_map_type" value="OSM3" <?php if ($t == 'OSM3') echo 'checked'; ?>> Hike & Bike<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ($t == 'OSM6') echo 'checked'; ?>> MapToolKit - Terrain<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ($t == 'OSM7') echo 'checked'; ?>> Open Street Map - Humanitarian map style<br />
<!--
<input type="radio" name="wpgpxmaps_map_type" value="OSM8" <?php if ($t == 'OSM8') echo 'checked'; ?>> Open Ski Map<br />
-->
<input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ($t == 'OSM9') echo 'checked'; ?>> Hike & Bike<br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ($t == 'OSM10') echo 'checked'; ?>> Open Sea Map<br />
</td>
</tr>
<tr>
<th scope="row">Start Icon:</th>
<td>
<input name="wpgpxmaps_map_start_icon" value="<?php echo get_option('wpgpxmaps_map_start_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em>
</td>
</tr>
<tr>
<th scope="row">End Icon:</th>
<td>
<input name="wpgpxmaps_map_end_icon" value="<?php echo get_option('wpgpxmaps_map_end_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty to hide</em>
</td>
</tr>
<tr>
<th scope="row">Current Position Icon:</th>
<td>
<input name="wpgpxmaps_map_current_icon" value="<?php echo get_option('wpgpxmaps_map_current_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td>
</tr>
<tr>
<th scope="row">Current GPS Position Icon:</th>
<td>
<input name="wpgpxmaps_currentpositioncon" value="<?php echo get_option('wpgpxmaps_currentpositioncon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td>
</tr>
<tr>
<th scope="row">Custom Waypoint Icon:</th>
<td>
<input name="wpgpxmaps_map_waypoint_icon" value="<?php echo get_option('wpgpxmaps_map_waypoint_icon'); ?>" style="width:400px" /> <em>(Url to image) Leave empty for default</em>
</td>
</tr>
</table>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
@ -282,13 +305,13 @@
</form>
<hr />
<form method="post" action="options.php">
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<h3 class="title">Chart</h3>
<table class="form-table">
<tr>
<th scope="row">Show altitude:</th>
<td>
@ -296,6 +319,7 @@
<input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>">
</td>
</tr>
<tr>
<tr>
<th scope="row">Altitude line color:</th>
@ -303,7 +327,9 @@
<input name="wpgpxmaps_graph_line_color" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color'); ?>" />
</td>
</tr>
<th scope="row">Unit of measure:</th>
<td>
<select name='wpgpxmaps_unit_of_measure'>
<option value="0" <?php if ($uom == '0') echo 'selected'; ?>>meters/meters</option>
@ -315,6 +341,7 @@
</select>
</td>
</tr>
<tr>
<th scope="row">Altitude display offset:</th>
<td>
@ -325,18 +352,21 @@
<em>(leave empty for auto scale)</em>
</td>
</tr>
<tr>
<th scope="row">Show speed:</th>
<td>
<input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if($showSpeed == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Speed</i>
</td>
</tr>
<tr>
<th scope="row">Speed line color:</th>
<td>
<input name="wpgpxmaps_graph_line_color_speed" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_speed'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Speed unit of measure:</th>
<td>
@ -349,7 +379,8 @@
<option value="5" <?php if ($uomSpeed == '5') echo 'selected'; ?>>Nautical Miles/Hour (Knots)</option> <option value="6" <?php if ($uomSpeed == '6') echo 'selected'; ?>>min/100 meters</option>
</select>
</td>
</tr>
</tr>
<tr>
<th scope="row">Speed display offset:</th>
<td>
@ -360,47 +391,51 @@
<em>(leave empty for auto scale)</em>
</td>
</tr>
<tr>
<th scope="row">Show Heart Rate (where aviable):</th>
<td>
<input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if($showHr == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show heart rate</i>
</td>
</tr>
<tr>
<th scope="row">Heart rate line color:</th>
<td>
<input name="wpgpxmaps_graph_line_color_hr" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_hr'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Show Temperature (where aviable):</th>
<td>
<input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if($showAtemp == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Temperature</i>
</td>
</tr>
</tr>
<tr>
<th scope="row">Temperature line color:</th>
<td>
<input name="wpgpxmaps_graph_line_color_atemp" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_atemp'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Show Cadence (where aviable):</th>
<td>
<input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if($showCad == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Show Cadence</i>
</td>
</tr>
<tr>
<th scope="row">Cadence line color:</th>
<td>
<input name="wpgpxmaps_graph_line_color_cad" type="color" data-hex="true" value="<?php echo get_option('wpgpxmaps_graph_line_color_cad'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Show Grade:</th>
<td>
@ -409,6 +444,7 @@
<i>(Grade values depends on your gps accuracy. If you have a poor gps accuracy they might be totally wrong!)</i>
</td>
</tr>
<tr>
<th scope="row">Grade line color:</th>
<td>
@ -419,6 +455,7 @@
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
<input name="page_options" type="hidden" value="wpgpxmaps_unit_of_measure,wpgpxmaps_graph_line_color,wpgpxmaps_show_elevation,wpgpxmaps_show_speed,wpgpxmaps_graph_line_color_speed,wpgpxmaps_show_hr,wpgpxmaps_graph_line_color_hr,wpgpxmaps_unit_of_measure_speed,wpgpxmaps_graph_offset_from1,wpgpxmaps_graph_offset_to1,wpgpxmaps_graph_offset_from2,wpgpxmaps_graph_offset_to2,wpgpxmaps_graph_line_color_cad,wpgpxmaps_show_cadence,wpgpxmaps_show_grade,wpgpxmaps_graph_line_color_grade,wpgpxmaps_show_atemp,wpgpxmaps_graph_line_color_atemp" />
<input type="submit" class="button-primary" value="<?php _e('Save Changes', "wp_gpx_maps") ?>" />
@ -426,26 +463,27 @@
</form>
<hr />
<form method="post" action="options.php">
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<h3 class="title">Advanced options <small>(Do not edit if you don't know what you are doing!)</small></h3>
<table class="form-table">
<tr>
<th scope="row"></th>
<td>
<i>Skip points closer than </i> <input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" /> <i>meters</i>.
</td>
</tr>
<tr>
<th scope="row"></th>
<td>
<input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if($donotreducegpx == true){echo('checked');} ?> onchange="this.value = (this.checked)" /> <i>Do not reduce gpx</i>.
</td>
</tr>
</table>
<input type="hidden" name="action" value="update" />
@ -456,4 +494,5 @@
</p>
</form>
<hr />
<hr />

View File

@ -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)." <br />";
return $offset;
}