From 135b7d254c37387c55d8cdc2a633f0f08497cedf Mon Sep 17 00:00:00 2001 From: bastianonm Date: Tue, 3 Jan 2012 09:53:36 +0000 Subject: [PATCH] --- readme.txt | 10 +++++- wp-gpx-maps.php | 32 +++++++++++++++---- wp-gpx-maps_Utils.php | 37 ++++++++++++---------- wp-gpx-maps_admin.php | 74 ++++++++++++++++++++++--------------------- 4 files changed, 94 insertions(+), 59 deletions(-) diff --git a/readme.txt b/readme.txt index 25cfcce..63f8a52 100644 --- a/readme.txt +++ b/readme.txt @@ -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 = diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index 03dbe80..e79052b 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -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,22 +75,36 @@ 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 == '') { $showW = get_option("wpgpxmaps_show_waypoint"); } - + $r = rand(1,5000000); $sitePath = substr (__FILE__, 0, strrpos(__FILE__,'wp-content')).DIRECTORY_SEPARATOR; @@ -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'); } ?> diff --git a/wp-gpx-maps_Utils.php b/wp-gpx-maps_Utils.php index a5f990f..165d1a0 100644 --- a/wp-gpx-maps_Utils.php +++ b/wp-gpx-maps_Utils.php @@ -1,6 +1,7 @@ 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 ; } diff --git a/wp-gpx-maps_admin.php b/wp-gpx-maps_admin.php index c6c70e8..da699b5 100644 --- a/wp-gpx-maps_admin.php +++ b/wp-gpx-maps_admin.php @@ -42,7 +42,11 @@ function WP_GPX_Maps_html_page() { } } - $showW = get_option("wpgpxmaps_show_waypoint"); + $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() { The fastest way to use this plugin: upload the file using the uploader below, than put this shotcode: [sgpx gpx="/wp-content/uploads/gpx/< gpx file name >"] in the pages/posts.

- Full set of attributes: [sgpx gpx="/wp-content/uploads/gpx/< gpx file name >" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true] + Full set of attributes: [sgpx gpx="/wp-content/uploads/gpx/< gpx file name >" width=100% mheight=450px gheight=200px mtype=SATELLITE waypoints=true donotreducegpx=false pointsoffset=10]

@@ -66,27 +70,31 @@ function WP_GPX_Maps_html_page() { Maps Height: , Graph Height: , onchange="this.value = (this.checked)" />Show Waypoints - - Default Map Type: + Default Map Type: - +
> HYBRID: transparent layer of major streets on satellite images.
> ROADMAP: normal street map.
> SATELLITE: satellite images.
> TERRAIN: maps with physical features such as terrain and vegetation.
+ + 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. + + - +

@@ -138,12 +146,6 @@ function WP_GPX_Maps_html_page() { } -?> - - - - @@ -173,26 +175,26 @@ function WP_GPX_Maps_html_page() { { $file = $realGpxPath . "/" . $entry; ?> - - - -

- Delete - | - Download -
- - -
-

-
- - -
-

-
- - + + + + + + + + + + + + + + Delete + | + Download + | + Shortcode: [sgpx gpx="/wp-content/uploads/gpx/"] + +