This commit is contained in:
bastianonm 2012-01-03 09:53:36 +00:00
parent 1d58f76ab6
commit 135b7d254c
4 changed files with 94 additions and 59 deletions

View File

@ -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
Requires at least: 2.0.0
Tested up to: 3.3
Stable tag: 1.0.9
Stable tag: 1.1.0
License: GPLv2 or later
Draws a gpx track with altitude graph
@ -54,6 +54,10 @@ The attributes are:
1. waypoints: print the gpx waypoints inside the map (default is FALSE)
1. donotreducegpx: Print all the point without reduce it (default is FALSE)
1. pointsoffset: Skip points closer than XX meters(default is 10)
shortcode with all the attributes : [sgpx gpx=">relative path to your gpx<" width=100% mheight=300px gheight=200px mtype=SATELLITE waypoints=true]
= What happening if I've a very large gpx? =
@ -68,6 +72,9 @@ Yes!
2. Admin area
== Changelog ==
= 1.1.0 =
* Added Advanced Setting in the Admin Area
* Added the shortcode for every entry in the admin area (easy to copy and paste in your posts)
= 1.0.9 =
* minor bug fixes
* Windows/IIS compatibility
@ -95,6 +102,7 @@ Yes!
* Initial release.
== Upgrade Notice ==
= 1.1.0 =
= 1.0.9 =
= 1.0.8 =
= 1.0.7 =

View File

@ -3,7 +3,7 @@
Plugin Name: WP-GPX-Maps
Plugin URI: http://www.darwinner.it/
Description: Draws a gpx track with altitude graph
Version: 1.0.9
Version: 1.1.0
Author: Bastianon Massimo
Author URI: http://www.pedemontanadelgrappa.it/
License: GPL
@ -58,6 +58,8 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$mt = $attr["mtype"];
$gh = $attr["gheight"];
$showW = $attr['waypoints'];
$donotreducegpx = $attr['donotreducegpx'];
$pointsoffset = $attr['pointsoffset'];
if ($w == '')
{
@ -73,15 +75,29 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
{
$gh = get_option("wpgpxmaps_graph_height");
}
if ($gh == '')
{
$gh = "200px";
}
if ($pointsoffset == '')
{
$pointsoffset = get_option("wpgpxmaps_pointsoffset");
}
if ($pointsoffset == '')
{
$pointsoffset = 10;
}
if ($mt == '')
{
$mt = get_option("wpgpxmaps_map_type");
}
if ($gh == '')
if ($donotreducegpx == '')
{
$gh = "200px";
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
}
if ($showW == '')
@ -99,7 +115,7 @@ function handle_WP_GPX_Maps_Shortcodes($attr, $content='')
$gpx = $sitePath . $gpx;
$points = getPoints( $gpx );
$points = getPoints( $gpx, $pointsoffset, $donotreducegpx);
$points_maps = '';
$points_graph = '';
$waypoints = '';
@ -155,6 +171,8 @@ function WP_GPX_Maps_install() {
add_option("wpgpxmaps_height", '450px', '', 'yes');
add_option('wpgpxmaps_map_type','HYBRID','','yes');
add_option('wpgpxmaps_show_waypoint','','','yes');
add_option('wpgpxmaps_pointsoffset','10','','yes');
add_option('wpgpxmaps_donotreducegpx','true','','yes');
}
function WP_GPX_Maps_remove() {
@ -163,6 +181,8 @@ function WP_GPX_Maps_remove() {
delete_option('wpgpxmaps_height');
delete_option('wpgpxmaps_map_type');
delete_option('wpgpxmaps_show_waypoint');
delete_option('wpgpxmaps_pointsoffset');
delete_option('wpgpxmaps_donotreducegpx');
}
?>

View File

@ -1,6 +1,7 @@
<?php
function getPoints($gpxPath,$gpxOffset = 10)
function getPoints($gpxPath,$gpxOffset = 10, $donotreducegpx)
{
$points = array();
$dist=0;
@ -9,12 +10,6 @@
$lastEle=0;
$lastOffset=0;
//Default Offset = 10 mt
if (!($gpxOffset > 0))
{
$gpxOffset = 10;
}
if (file_exists($gpxPath))
{
$points = parseXml($gpxPath, $gpxOffset);
@ -24,16 +19,24 @@
array_push($points, array((float)0,(float)0,(float)0,(float)0));
echo "File $gpxPath not found!";
}
// riduco l'array a circa 200 punti per non appensantire la pagina(mappa e grafico)!
$count=sizeof($points);
if ($count>200)
// reduce the points to around 200 to speedup
if ( $donotreducegpx != true)
{
$f = round($count/200);
if ($f>1)
for($i=$count;$i>0;$i--)
if ($i % $f != 0)
unset($points[$i]);
$count=sizeof($points);
if ($count>200)
{
$f = round($count/200);
if ($f>1)
for($i=$count;$i>0;$i--)
if ($i % $f != 0)
unset($points[$i]);
}
}
return $points;
}
@ -77,6 +80,8 @@
}
else
{
echo "j";
//Smoller Offset -> continue..
$lastOffset= (float) $lastOffset + (float) $offset ;
}

View File

@ -43,6 +43,10 @@ function WP_GPX_Maps_html_page() {
}
$showW = get_option("wpgpxmaps_show_waypoint");
$donotreducegpx = get_option("wpgpxmaps_donotreducegpx");
$t = get_option('wpgpxmaps_map_type');
if (!($t))
$t = 'HYBRID';
?>
@ -50,7 +54,7 @@ function WP_GPX_Maps_html_page() {
<b>The fastest way to use this plugin:</b> upload the file using the uploader below, than put this
shotcode: <b>[sgpx gpx="/wp-content/uploads/gpx/&lt gpx file name &gt"]</b> in the pages/posts.
<p>
<i>Full set of attributes:</i> <b>[sgpx gpx="/wp-content/uploads/gpx/&lt gpx file name &gt" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true]</b>
<i>Full set of attributes:</i> <b>[sgpx gpx="/wp-content/uploads/gpx/&lt gpx file name &gt" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true donotreducegpx=false pointsoffset=10]</b>
</p>
</div>
@ -66,27 +70,31 @@ function WP_GPX_Maps_html_page() {
<i>Maps Height:</i> <input name="wpgpxmaps_height" type="text" id="wpgpxmaps_height" value="<?php echo get_option('wpgpxmaps_height'); ?>" style="width:50px;" />,
<i>Graph Height:</i> <input name="wpgpxmaps_graph_height" type="text" id="wpgpxmaps_graph_height" value="<?php echo get_option('wpgpxmaps_graph_height'); ?>" style="width:50px;" />,
<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 width="150" scope="row">Default Map Type:</th>
<th scope="row">Default Map Type:</th>
<td>
<?php
$t = get_option('wpgpxmaps_map_type');
if (!($t))
$t = 'HYBRID';
?>
<br />
<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 />
</td>
</tr>
<tr>
<th scope="row">Advanced options:</th>
<td>
<br />
<b>Do not edit if you don't know what you are doing!</b><br />
<i>Skip points closer than </i> <input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo get_option('wpgpxmaps_pointsoffset'); ?>" style="width:50px;" /><i>meters</i>.
<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" />
<input name="page_options" type="hidden" value="wpgpxmaps_map_type,wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_show_waypoint" />
<input name="page_options" type="hidden" value="wpgpxmaps_map_type,wpgpxmaps_height,wpgpxmaps_graph_height,wpgpxmaps_width,wpgpxmaps_show_waypoint,wpgpxmaps_pointsoffset,wpgpxmaps_donotreducegpx" />
<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
@ -138,12 +146,6 @@ function WP_GPX_Maps_html_page() {
}
?>
<?php
if ( is_readable ( $realGpxPath ) && $handle = opendir($realGpxPath)) {
?>
@ -173,26 +175,26 @@ function WP_GPX_Maps_html_page() {
{
$file = $realGpxPath . "/" . $entry;
?>
<tr class="active" id="akismet">
<td class="plugin-title">
<strong><?php echo $entry; ?></strong>
<div class="row-actions-visible">
<a href="#" onclick="delgpx('<?php echo $entry ?>'); return false;">Delete</a>
|
<a href="../wp-content/uploads/gpx/<?php echo $entry?>">Download</a>
</div>
</td>
<td class="column-description desc">
<div class="plugin-description">
<p><?php echo date ("F d Y H:i:s.", filemtime( $file ) ) ?></p>
</div>
</td>
<td class="column-description desc">
<div class="plugin-description">
<p><?php echo number_format ( filesize( $file ) , 0, '.', ',' ) ?></p>
</div>
</td>
</tr>
<tr>
<td style="border:none; padding-bottom:0;">
<strong><?php echo $entry; ?></strong>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo date ("F d Y H:i:s.", filemtime( $file ) ) ?>
</td>
<td style="border:none; padding-bottom:0;">
<?php echo number_format ( filesize( $file ) , 0, '.', ',' ) ?>
</td>
</tr>
<tr>
<td colspan=3 style="padding: 0px 7px 7px 7px;">
<a href="#" onclick="delgpx('<?php echo $entry ?>'); return false;">Delete</a>
|
<a href="../wp-content/uploads/gpx/<?php echo $entry?>">Download</a>
|
Shortcode: [sgpx gpx="/wp-content/uploads/gpx/<?php echo $entry?>"]
</td>
</tr>
<?php
}
}