This commit is contained in:
parent
36fb58126f
commit
3089f5fc16
|
@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=basti
|
||||||
Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
|
Tags: maps, gpx, gps, graph, google maps, google chart, track, garmin
|
||||||
Requires at least: 2.0.0
|
Requires at least: 2.0.0
|
||||||
Tested up to: 3.3
|
Tested up to: 3.3
|
||||||
Stable tag: 1.1.7
|
Stable tag: 1.1.8
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
|
|
||||||
Draws a gpx track with altitude graph
|
Draws a gpx track with altitude graph
|
||||||
|
@ -83,6 +83,9 @@ Yes!
|
||||||
2. Admin area - Settings
|
2. Admin area - Settings
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
= 1.1.8 =
|
||||||
|
* cache issues fixed
|
||||||
|
* added speed when not present in the gpx (derived from datetime)
|
||||||
= 1.1.7 =
|
= 1.1.7 =
|
||||||
* new unit of measure (meters/kilometers)
|
* new unit of measure (meters/kilometers)
|
||||||
* mouse wheel scrolling issue fixed
|
* mouse wheel scrolling issue fixed
|
||||||
|
@ -135,6 +138,8 @@ Yes!
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|
||||||
== Upgrade Notice ==
|
== Upgrade Notice ==
|
||||||
|
= 1.1.8 =
|
||||||
|
= 1.1.7 =
|
||||||
= 1.1.6 =
|
= 1.1.6 =
|
||||||
* Added speed support. To enable this feature please check the plugin settings
|
* Added speed support. To enable this feature please check the plugin settings
|
||||||
= 1.1.5 =
|
= 1.1.5 =
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: WP-GPX-Maps
|
Plugin Name: WP-GPX-Maps
|
||||||
Plugin URI: http://www.darwinner.it/
|
Plugin URI: http://www.darwinner.it/
|
||||||
Description: Draws a gpx track with altitude graph
|
Description: Draws a gpx track with altitude graph
|
||||||
Version: 1.1.7
|
Version: 1.1.8
|
||||||
Author: Bastianon Massimo
|
Author: Bastianon Massimo
|
||||||
Author URI: http://www.pedemontanadelgrappa.it/
|
Author URI: http://www.pedemontanadelgrappa.it/
|
||||||
License: GPL
|
License: GPL
|
||||||
|
@ -88,7 +88,12 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
||||||
|
|
||||||
$r = rand(1,5000000);
|
$r = rand(1,5000000);
|
||||||
|
|
||||||
|
$cacheFileName = "$gpx,$w,$mh,$mt,$gh,$showW,$donotreducegpx,$pointsoffset,$showSpeed,$uom";
|
||||||
|
|
||||||
|
//echo "----------cacheFileName---------$cacheFileName-------------------";
|
||||||
|
|
||||||
$cacheFileName = md5($gpx.$w.$mh.$mt.$gh.$showW.$donotreducegpx.$pointsoffset.$showSpeed.$uom);
|
$cacheFileName = md5($gpx.$w.$mh.$mt.$gh.$showW.$donotreducegpx.$pointsoffset.$showSpeed.$uom);
|
||||||
|
|
||||||
$gpxcache = gpxCacheFolderPath();
|
$gpxcache = gpxCacheFolderPath();
|
||||||
|
|
||||||
if(!(file_exists($gpxcache) && is_dir($gpxcache)))
|
if(!(file_exists($gpxcache) && is_dir($gpxcache)))
|
||||||
|
@ -176,10 +181,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
|
||||||
else {
|
else {
|
||||||
$points_graph .= '['.$_dist.','.$_ele.'],';
|
$points_graph .= '['.$_dist.','.$_ele.'],';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($showW == true)
|
if ($showW == true)
|
||||||
{
|
{
|
||||||
$wpoints = getWayPoints($gpx);
|
$wpoints = getWayPoints($gpx);
|
||||||
|
|
|
@ -126,8 +126,10 @@
|
||||||
$lastLat = 0;
|
$lastLat = 0;
|
||||||
$lastLon = 0;
|
$lastLon = 0;
|
||||||
$lastEle = 0;
|
$lastEle = 0;
|
||||||
|
$lastTime = 0;
|
||||||
$dist = 0;
|
$dist = 0;
|
||||||
$lastOffset = 0;
|
$lastOffset = 0;
|
||||||
|
$speedBuffer = array();
|
||||||
|
|
||||||
// normal case
|
// normal case
|
||||||
foreach($nodes as $trkpt)
|
foreach($nodes as $trkpt)
|
||||||
|
@ -135,26 +137,60 @@
|
||||||
$lat = $trkpt['lat'];
|
$lat = $trkpt['lat'];
|
||||||
$lon = $trkpt['lon'];
|
$lon = $trkpt['lon'];
|
||||||
$ele = $trkpt->ele;
|
$ele = $trkpt->ele;
|
||||||
|
$time = $trkpt->time;
|
||||||
$speed = (float)$trkpt->speed;
|
$speed = (float)$trkpt->speed;
|
||||||
|
|
||||||
if ($lastLat == 0 && $lastLon == 0)
|
if ($lastLat == 0 && $lastLon == 0)
|
||||||
{
|
{
|
||||||
//Base Case
|
//Base Case
|
||||||
array_push($points, array((float)$lat,(float)$lon,(float)round($ele,2),(float)round($dist,2), $speed ));
|
array_push($points, array((float)$lat,(float)$lon,(float)round($ele,2),(float)round($dist,2), 0 ));
|
||||||
$lastLat=$lat;
|
$lastLat=$lat;
|
||||||
$lastLon=$lon;
|
$lastLon=$lon;
|
||||||
$lastEle=$ele;
|
$lastEle=$ele;
|
||||||
|
$lastTime=$time;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Normal Case
|
//Normal Case
|
||||||
$offset = calculateDistance((float)$lat, (float)$lon, (float)$ele, (float)$lastLat, (float)$lastLon, (float)$lastEle);
|
$offset = calculateDistance((float)$lat, (float)$lon, (float)$ele, (float)$lastLat, (float)$lastLon, (float)$lastEle);
|
||||||
$dist = $dist + $offset;
|
$dist = $dist + $offset;
|
||||||
|
|
||||||
|
if ($speed == 0)
|
||||||
|
{
|
||||||
|
$datediff = (float)date_diff($lastTime,$time);
|
||||||
|
//echo "------------$time-------$lastTime-----";
|
||||||
|
//echo "------------$datediff------------";
|
||||||
|
if ($datediff>0)
|
||||||
|
{
|
||||||
|
$speed = $offset / $datediff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($speedBuffer, $speed);
|
||||||
|
|
||||||
if (((float) $offset + (float) $lastOffset) > $gpxOffset)
|
if (((float) $offset + (float) $lastOffset) > $gpxOffset)
|
||||||
{
|
{
|
||||||
//Bigger Offset -> write coordinate
|
//Bigger Offset -> write coordinate
|
||||||
|
|
||||||
|
$avgSpeed = 0;
|
||||||
|
|
||||||
|
foreach($speedBuffer as $s)
|
||||||
|
{
|
||||||
|
$avgSpeed += $s;
|
||||||
|
}
|
||||||
|
|
||||||
|
$avgSpeed = $avgSpeed / count($speedBuffer);
|
||||||
|
$speedBuffer = array();
|
||||||
|
|
||||||
$lastOffset=0;
|
$lastOffset=0;
|
||||||
array_push($points, array((float)$lat,(float)$lon,(float)round($ele,1),(float)round($dist,1), $speed ));
|
array_push($points, array(
|
||||||
|
(float)$lat,
|
||||||
|
(float)$lon,
|
||||||
|
(float)round($ele,1),
|
||||||
|
(float)round($dist,1),
|
||||||
|
(float)round($avgSpeed,1)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -165,6 +201,7 @@
|
||||||
$lastLat=$lat;
|
$lastLat=$lat;
|
||||||
$lastLon=$lon;
|
$lastLon=$lon;
|
||||||
$lastEle=$ele;
|
$lastEle=$ele;
|
||||||
|
$lastTime=$time;
|
||||||
}
|
}
|
||||||
unset($nodes);
|
unset($nodes);
|
||||||
|
|
||||||
|
@ -274,5 +311,34 @@
|
||||||
return sqrt((float)pow((float)$ele1-(float)$ele2,2)+(float)pow((float)$d,2));
|
return sqrt((float)pow((float)$ele1-(float)$ele2,2)+(float)pow((float)$d,2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function date_diff($old_date, $new_date) {
|
||||||
|
|
||||||
|
$t1 = strtotime($new_date);
|
||||||
|
$t2 = strtotime($old_date);
|
||||||
|
|
||||||
|
// milliceconds fix
|
||||||
|
$t1 += date_getDecimals($new_date);
|
||||||
|
$t2 += date_getDecimals($old_date);
|
||||||
|
|
||||||
|
$offset = (float)($t1 - $t2);
|
||||||
|
|
||||||
|
//echo "$offset = $new_date - $old_date; ".strtotime($new_date)." ".strtotime($old_date)." <br />";
|
||||||
|
|
||||||
|
return $offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
function date_getDecimals($date)
|
||||||
|
{
|
||||||
|
if (preg_match('(\.([0-9]{2})Z?)', $date, $matches))
|
||||||
|
{
|
||||||
|
return (float)((float)$matches[1] / 100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
if ( isset($_POST['clearcache']) )
|
if ( isset($_POST['clearcache']) )
|
||||||
{
|
{
|
||||||
echo "pulisco la cahce";
|
echo "Cache is now empty!";
|
||||||
recursive_remove_directory($cacheGpxPath,true);
|
recursive_remove_directory($cacheGpxPath,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue