Added nautical miles as distance (Many thanks to Anders)

This commit is contained in:
bastianonm 2013-07-05 12:43:58 +00:00
parent 03aae4463a
commit ae5a93669d
4 changed files with 58 additions and 72 deletions

View File

@ -621,6 +621,11 @@ function _wpgpxmaps(params)
l_x = { suf : "km", dec : 1 };
l_y = { suf : "m", dec : 0 };
}
else if (unit=="3")
{
l_x = { suf : "NM", dec : 1 };
l_y = { suf : "m", dec : 0 };
}
else
{
l_x = { suf : "m", dec : 0 };
@ -684,11 +689,7 @@ function _wpgpxmaps(params)
{
el_report.innerHTML += serie.name + ' avg: ' + dataX.value / dataX.count + "<br />";
}
}
el_report.innerHTML += "<br />"
@ -836,11 +837,9 @@ function _wpgpxmaps(params)
if (graphSpeed != '')
{
if (unitspeed == '5') // knos
if (unitspeed == '5') // knots
{
l_s = { suf : "knos", dec : 2 };
l_s = { suf : "knots", dec : 2 };
}
else if (unitspeed == '4') // min/miles
{

View File

@ -5,18 +5,12 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: maps, gpx, gps, graph, chart, google maps, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence
Requires at least: 2.0.0
Tested up to: 3.5
Stable tag: 1.1.44
Stable tag: 1.1.45
Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map.
== Description ==
IMPORTANT NOTICE
wp-gpx-maps will no longer be available on wordpress.org, because highcharts is not GPL licensed.
If you want to keep wp-gpx-maps updated, follow this link: http://www.devfarm.it/forums/forum/wp-gpx-maps/
This plugin has, as input, the GPX file with the track you've made and as output it shows the map of the track and an interactive altitude graph (where available).
Fully configurable:
@ -98,7 +92,7 @@ The attributes are:
1. pointsoffset: skip points closer than XX meters(default is 10)
1. uom: the unit of measure of distance/altitude are values are: 0, 1, 2 (0 = meters, 1 = feet/miles, 2 = meters/kilometers)
1. uom: the unit of measure of distance/altitude are values are: 0, 1, 2 (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles)
1. mlinecolor: map line color (default is #3366cc)
@ -120,7 +114,7 @@ The attributes are:
1. glinecolorgrade: grade line color (default is #beecff)
1. uomspeed: the unit of measure of speed are: 0, 1, 2, 3, 4 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles)
1. uomspeed: the unit of measure of speed are: 0, 1, 2, 3, 4 (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots))
1. chartFrom1: minimun value for altitude chart
@ -181,6 +175,8 @@ Yes!
1. Altitude & Speed & Hearth rate
== Changelog ==
= 1.1.45 =
* Added nautical miles as distance (Many thanks to Anders)
= 1.1.44 =
* Added Chart zoom feature
* Some small bug fixes

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps
Plugin URI: http://www.devfarm.it/
Description: Draws a gpx track with altitude graph
Version: 1.1.44
Version: 1.1.45
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
*/
@ -59,7 +59,7 @@ function enqueue_WP_GPX_Maps_scripts()
wp_enqueue_script( 'highcharts' );
wp_deregister_script( 'WP-GPX-Maps' );
wp_register_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.1.44");
wp_register_script( 'WP-GPX-Maps', plugins_url('/WP-GPX-Maps.js', __FILE__), array('jquery','googlemaps','highcharts'), "1.1.45");
wp_enqueue_script( 'WP-GPX-Maps' );
}
@ -84,20 +84,16 @@ function print_WP_GPX_Maps_scripts()
function findValue($attr, $attributeName, $optionName, $defaultValue)
{
$val = '';
if ( isset($attr[$attributeName]) )
{
if ( isset($attr[$attributeName]) ) {
$val = $attr[$attributeName];
}
if ($val == '')
{
if ($val == '') {
$val = get_option($optionName);
}
if ($val == '' && isset($_GET[$attributeName]) && $attributeName != "download")
{
if ($val == '' && isset($_GET[$attributeName]) && $attributeName != "download") {
$val = $_GET[$attributeName];
}
if ($val == '')
{
if ($val == '') {
$val = $defaultValue;
}
return $val;
@ -154,7 +150,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$p_total_time = findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false);
$colors_map = "\"".implode("\",\"",(explode(" ",$color_map)))."\"";
$gpxurl = $gpx;
$cacheFileName = "$gpx,$w,$mh,$mt,$gh,$showW,$showHr,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,v1.1.38";
@ -169,8 +165,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$gpxcache.= DIRECTORY_SEPARATOR.$cacheFileName.".tmp";
// Try to load cache
if (file_exists($gpxcache) && !($skipcache == true))
{
if (file_exists($gpxcache) && !($skipcache == true)) {
try {
$cache_str = file_get_contents($gpxcache);
@ -220,25 +215,21 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$isGpxUrl = (preg_match('/^(http(s)?\:\/\/)/', trim($gpx)) == 1);
if ((!isset($points_maps) || $points_maps == '') && $gpx != '')
{
if ((!isset($points_maps) || $points_maps == '') && $gpx != '') {
$sitePath = sitePath();
$gpx = trim($gpx);
if ($isGpxUrl == true)
{
if ($isGpxUrl == true) {
$gpx = downloadRemoteFile($gpx);
}
else
{
else {
$gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx);
$gpx = $sitePath . $gpx;
}
if ($gpx == '')
{
if ($gpx == '') {
return "No gpx found";
}
@ -267,8 +258,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$tot_len = $points->totalLength;
if (is_array ($points_x_lat))
foreach(array_keys($points_x_lat) as $i)
{
foreach(array_keys($points_x_lat) as $i) {
$_lat = (float)$points_x_lat[$i];
$_lon = (float)$points_x_lon[$i];
@ -292,8 +282,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$points_graph_grade .= 'null,';
}
else
{
else {
$points_maps .= '['.number_format((float)$points_x_lat[$i], 7 , '.' , '' ).','.number_format((float)$points_x_lon[$i], 7 , '.' , '' ).'],';
$_ele = (float)$points->ele[$i];
@ -308,7 +297,11 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
{
// meters / kilometers
$_dist = (float)($_dist / 1000);
}
} else if ($uom == '3')
{
// meters / kilometers / nautical miles
$_dist = (float)($_dist / 1000 / 1.852);
}
$points_graph_dist .= number_format ( $_dist , 2 , '.' , '' ).',';
$points_graph_ele .= number_format ( $_ele , 2 , '.' , '' ).',';
@ -320,43 +313,46 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$points_graph_speed .= convertSpeed($_speed,$uomspeed).',';
}
if ($showHr == true)
{
if ($showHr == true) {
$points_graph_hr .= number_format ( $points->hr[$i] , 2 , '.' , '' ).',';
}
if ($showCad == true)
{
if ($showCad == true) {
$points_graph_cad .= number_format ( $points->cad[$i] , 2 , '.' , '' ).',';
}
if ($showGrade == true)
{
if ($showGrade == true) {
$points_graph_grade .= number_format ( $points->grade[$i] , 2 , '.' , '' ).',';
}
}
}
if ($uom == '1')
{
if ($uom == '1') {
// Miles and feet
$tot_len = round($tot_len * 0.000621371192, 2)." mi";
$max_ele = round($max_ele * 3.2808399, 0)." ft";
$min_ele = round($min_ele * 3.2808399, 0)." ft";
$total_ele_up = round($total_ele_up * 3.2808399, 0)." ft";
$total_ele_down = round($total_ele_down * 3.2808399, 0)." ft";
} else if ($uom == '2')
{
}
else if ($uom == '2') {
// meters / kilometers
$tot_len = round($tot_len / 1000, 2)." km";
$max_ele = round($max_ele, 0) ." m";
$min_ele = round($min_ele, 0) ." m";
$total_ele_up = round($total_ele_up, 0) ." m";
$total_ele_down = round($total_ele_down, 0) ." m";
}
else if ($uom == '3') {
// meters / kilometers / nautical miles
$tot_len = round($tot_len / 1000/1.852, 2)." NM";
$max_ele = round($max_ele, 0) ." m";
$min_ele = round($min_ele, 0) ." m";
$total_ele_up = round($total_ele_up, 0) ." m";
$total_ele_down = round($total_ele_down, 0) ." m";
}
else
{
else {
// meters / meters
$tot_len = round($tot_len, 0) ." m";
$max_ele = round($max_ele, 0) ." m";
@ -367,8 +363,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$avg_speed = convertSpeed($avg_speed,$uomspeed,true);
if ($showW == true)
{
if ($showW == true) {
$wpoints = 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]).'\'],';
@ -410,8 +405,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
}
$ngimgs_data = '';
if ( $ngGalleries != '' || $ngImages != '' )
{
if ( $ngGalleries != '' || $ngImages != '' ) {
//print_r($points);
@ -424,8 +418,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
}
}
if (!($skipcache == true))
{
if (!($skipcache == true)) {
@file_put_contents($gpxcache,
serialize(array( "points_maps" => $points_maps,
"points_x_time" => $points_x_time,
@ -512,8 +506,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
</script>';
// print summary
if ($summary=='true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') )
{
if ($summary=='true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') ) {
$output .= "<div id='wpgpxmaps_summary_".$r."' class='wpgpxmaps_summary'>";
if ($points_graph_dist != '' && $p_tot_len == 'true')
@ -544,14 +537,11 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
}
// print download link
if ($download=='true' && $gpxurl != '')
{
if ($isGpxUrl == true)
{
if ($download=='true' && $gpxurl != '') {
if ($isGpxUrl == true) {
}
else
{
else {
$gpxurl = get_bloginfo('url').$gpxurl;
}
$output.="<a href='$gpxurl' target='_new'>".__("Download", "wp-gpx-maps")."</a>";
@ -576,10 +566,10 @@ function convertSpeed($speed,$uomspeed, $addUom = false)
$uom = '';
if ($uomspeed == '5') // knos
if ($uomspeed == '5') // knots
{
$speed *= 1.94384449;
$uom = " knos";
$uom = " knots";
}
else if ($uomspeed == '4') // min/mi
{

View File

@ -254,6 +254,7 @@
<option value="0" <?php if ($uom == '0') echo 'selected'; ?>>meters/meters</option>
<option value="1" <?php if ($uom == '1') echo 'selected'; ?>>feet/miles</option>
<option value="2" <?php if ($uom == '2') echo 'selected'; ?>>meters/kilometers</option>
<option value="3" <?php if ($uom == '3') echo 'selected'; ?>>meters/nautical miles</option>
</select>
</td>
</tr>