diff --git a/readme.txt b/readme.txt index 0ec4d94..874cfaa 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: bastianonm Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML 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.4 +Tested up to: 3.5 Stable tag: 1.1.39 Draws a gpx track with altitude graph. You can also display your nextgen gallery images in the map. diff --git a/wp-gpx-maps.php b/wp-gpx-maps.php index f543096..e69de29 100644 --- a/wp-gpx-maps.php +++ b/wp-gpx-maps.php @@ -1,676 +0,0 @@ -Settings'; - // add the link to the list - array_unshift($links, $settings_link); - } - - return $links; -} - -function enqueue_WP_GPX_Maps_scripts() -{ - - wp_enqueue_script( 'jquery' ); - - wp_deregister_script( 'googlemaps' ); - wp_register_script( 'googlemaps', 'https://maps.googleapis.com/maps/api/js?sensor=false&v=3.9', null, null); - wp_enqueue_script( 'googlemaps' ); - - wp_deregister_script( 'highcharts' ); - wp_register_script( 'highcharts', "http://code.highcharts.com/highcharts.js", array('jquery'), "2.3.3", true); - 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.39"); - wp_enqueue_script( 'WP-GPX-Maps' ); - -} - -function print_WP_GPX_Maps_scripts() -{ -?> - -dt; - $points_x_lat = $points->lat; - $points_x_lon = $points->lon; - - $max_ele = $points->maxEle; - $min_ele = $points->minEle; - $max_time = $points->maxTime; - $min_time = $points->minTime; - $total_ele_up = $points->totalEleUp; - $total_ele_down = $points->totalEleDown; - $avg_speed = $points->avgSpeed; - $tot_len = $points->totalLength; - - if (is_array ($points_x_lat)) - foreach(array_keys($points_x_lat) as $i) - { - - $_lat = (float)$points_x_lat[$i]; - $_lon = (float)$points_x_lon[$i]; - - if ( $_lat == 0 && $_lon == 0 ) - { - $points_maps .= 'null,'; - $points_graph_dist .= 'null,'; - $points_graph_ele .= 'null,'; - - if ($showSpeed == true) - $points_graph_speed .= 'null,'; - - if ($showHr == true) - $points_graph_hr .= 'null,'; - - if ($showCad == true) - $points_graph_cad .= 'null,'; - } - else - { - $points_maps .= '['.number_format((float)$points_x_lat[$i], 7 , '.' , '' ).','.number_format((float)$points_x_lon[$i], 7 , '.' , '' ).'],'; - - $_ele = (float)$points->ele[$i]; - $_dist = (float)$points->dist[$i]; - - if ($uom == '1') - { - // Miles and feet - $_dist *= 0.000621371192; - $_ele *= 3.2808399; - } else if ($uom == '2') - { - // meters / kilometers - $_dist = (float)($_dist / 1000); - } - - $points_graph_dist .= number_format ( $_dist , 2 , '.' , '' ).','; - $points_graph_ele .= number_format ( $_ele , 2 , '.' , '' ).','; - - if ($showSpeed == true) { - - $_speed = (float)$points->speed[$i]; - - $points_graph_speed .= convertSpeed($_speed,$uomspeed).','; - } - - if ($showHr == true) - { - $points_graph_hr .= number_format ( $points->hr[$i] , 2 , '.' , '' ).','; - } - - if ($showCad == true) - { - $points_graph_cad .= number_format ( $points->cad[$i] , 2 , '.' , '' ).','; - } - } - } - - 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') - { - // 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 - { - // meters / meters - $tot_len = round($tot_len, 0) ." m"; - $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"; - } - - $avg_speed = convertSpeed($avg_speed,$uomspeed,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]).'\'],'; - } - } - - $p="/(,|,null,)$/"; - - $points_maps = preg_replace($p, "", $points_maps); - - $points_graph_dist = preg_replace($p, "", $points_graph_dist); - $points_graph_ele = preg_replace($p, "", $points_graph_ele); - $points_graph_speed = preg_replace($p, "", $points_graph_speed); - $points_graph_hr = preg_replace($p, "", $points_graph_hr); - $points_graph_cad = preg_replace($p, "", $points_graph_cad); - - $waypoints = preg_replace($p, "", $waypoints); - - if (preg_match("/^(0,?)+$/", $points_graph_dist)) - $points_graph_dist = ""; - - if (preg_match("/^(0,?)+$/", $points_graph_ele)) - $points_graph_ele = ""; - - if (preg_match("/^(0,?)+$/", $points_graph_speed)) - $points_graph_speed = ""; - - if (preg_match("/^(0,?)+$/", $points_graph_hr)) - $points_graph_hr = ""; - - if (preg_match("/^(0,?)+$/", $points_graph_cad)) - $points_graph_cad = ""; - - } - - $ngimgs_data = ''; - if ( $ngGalleries != '' || $ngImages != '' ) - { - - //print_r($points); - - $ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error); - $ngimgs_data =''; - foreach ($ngimgs as $img) { - $data = $img['data']; - $data = str_replace("\n","",$data); - $ngimgs_data .= ''.$data.''; - } - } - - if (!($skipcache == true)) - { - @file_put_contents($gpxcache, - serialize(array( "points_maps" => $points_maps, - "points_x_time" => $points_x_time, - "points_x_lat" => $points_x_lat, - "points_x_lon" => $points_x_lon, - "points_graph_dist" => $points_graph_dist, - "points_graph_ele" => $points_graph_ele, - "points_graph_speed" => $points_graph_speed, - "points_graph_hr" => $points_graph_hr, - "points_graph_cad" => $points_graph_cad, - "waypoints" => $waypoints, - "max_ele" => $max_ele, - "min_ele" => $min_ele, - "total_ele_up" => $total_ele_up, - "total_ele_down" => $total_ele_down, - "avg_speed" => $avg_speed, - "tot_len" => $tot_len, - "max_time" => $max_time, - "min_time" => $min_time - ) - ), - LOCK_EX); - @chmod($gpxcache,0755); - } - - $hideGraph = ($gh == "0" || $gh == "0px"); - - global $post; - $r = $post->ID."_".rand(1,5000000); - - $output = ' -
-
-
- -
- '. $error .' - '; - - // print summary - if ($summary=='true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') ) - { - - $output .= "
"; - if ($points_graph_dist != '' && $p_tot_len == 'true') - { - $output .= "".__("Total distance", "wp-gpx-maps").": $tot_len
"; - } - if ($points_graph_ele != '') - { - if ($p_max_ele == 'true') - $output .= "".__("Max elevation", "wp-gpx-maps").": $max_ele
"; - if ($p_min_ele == 'true') - $output .= "".__("Min elevation", "wp-gpx-maps").": $min_ele
"; - if ($p_total_ele_up == 'true') - $output .= "".__("Total climbing", "wp-gpx-maps").": $total_ele_up
"; - if ($p_total_ele_down == 'true') - $output .= "".__("Total descent", "wp-gpx-maps").": $total_ele_down
"; - } - if ($points_graph_speed != '' && $p_avg_speed == 'true') - { - $output .= "".__("Average speed", "wp-gpx-maps").": $avg_speed
"; - } - if ($p_total_time == 'true' && $max_time > 0) - { - $time_diff = date("H:i:s", ($max_time - $min_time)); - $output .= "".__("Total Time", "wp-gpx-maps").": $time_diff
"; - } - $output .= "
"; - } - - // print download link - if ($download=='true' && $gpxurl != '') - { - if ($isGpxUrl == true) - { - - } - else - { - $gpxurl = get_bloginfo('url').$gpxurl; - } - $output.="".__("Download", "wp-gpx-maps").""; - } - - return $output; -} - -function convertSeconds($s) -{ - if ($s ==0) - return 0; - $s = 1.0 / $s; - $_sSecT = $s * 60; //sec/km - $_sMin = floor ( $_sSecT / 60 ); - $_sSec = $_sSecT - $_sMin * 60; - return $_sMin + $_sSec / 100; -} - -function convertSpeed($speed,$uomspeed, $addUom = false) -{ - if ($uomspeed == '5') // knos - { - $speed *= 1.94384449; - if ($addUom == true) $speed = round($speed,2) . " knos"; - } - if ($uomspeed == '4') // min/mi - { - $speed = convertSeconds($speed * 0.037282272); - if ($addUom == true) $speed = round($speed,2) . " min/mi"; - } - else if ($uomspeed == '3') // min/km - { - $speed = convertSeconds($speed * 0.06); - if ($addUom == true) $speed = round($speed,2) . " min/km"; - } - else if ($uomspeed == '2') // miles/h - { - $speed *= 2.2369362920544025; - if ($addUom == true) $speed = round($speed,2) . " mi/h"; - } - else if ($uomspeed == '1') // km/h - { - $speed *= 3.6; - if ($addUom == true) $speed = round($speed,2) . " km/h"; - } - else // dafault m/s - { - if ($addUom == true) $speed = round($speed,2) . " m/s"; - } - return number_format ( $speed , 2 , '.' , '' ); -} - -function downloadRemoteFile($remoteFile) -{ - try - { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, str_replace(' ', '%20', $remoteFile)); - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); - curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5); - curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); - $resp = curl_exec($ch); - curl_close($ch); - $tmpfname = tempnam ( '/tmp', 'gpx' ); - - $fp = fopen($tmpfname, "w"); - fwrite($fp, $resp); - fclose($fp); - - return $tmpfname; - } catch (Exception $e) { - return ''; - } -} - -function unescape($value) -{ - $value = str_replace("'", "\'", $value); - $value = str_replace(array("\n","\r"), "", $value); - return $value; -} - -function WP_GPX_Maps_install() { - add_option("wpgpxmaps_width", '100%', '', 'yes'); - add_option("wpgpxmaps_graph_height", '200px', '', 'yes'); - add_option("wpgpxmaps_height", '450px', '', 'yes'); - add_option('wpgpxmaps_map_type','HYBRID','','yes'); - add_option('wpgpxmaps_show_waypoint','','','yes'); - add_option('wpgpxmaps_show_speed','','','yes'); - add_option('wpgpxmaps_pointsoffset','10','','yes'); - add_option('wpgpxmaps_donotreducegpx','true','','yes'); - add_option("wpgpxmaps_unit_of_measure", '0', '', 'yes'); - add_option("wpgpxmaps_unit_of_measure_speed", '0', '', 'yes'); - add_option("wpgpxmaps_graph_line_color", '#3366cc', '', 'yes'); - add_option("wpgpxmaps_graph_line_color_speed", '#ff0000', '', 'yes'); - add_option("wpgpxmaps_map_line_color", '#3366cc', '', 'yes'); - add_option("wpgpxmaps_graph_line_color_cad", '#beecff', '', 'yes'); - add_option("wpgpxmaps_graph_offset_from1", '', '', 'yes'); - add_option("wpgpxmaps_graph_offset_to1", '', '', 'yes'); - add_option("wpgpxmaps_graph_offset_from2", '', '', 'yes'); - add_option("wpgpxmaps_graph_offset_to2", '', '', 'yes'); - add_option("wpgpxmaps_map_start_icon", '', '', 'yes'); - add_option("wpgpxmaps_map_end_icon", '', '', 'yes'); - add_option("wpgpxmaps_map_current_icon", '', '', 'yes'); - add_option("wpgpxmaps_map_waypoint_icon", '', '', 'yes'); - add_option("wpgpxmaps_map_nggallery", '', '', 'yes'); - add_option("wpgpxmaps_show_hr", '', '', 'yes'); - add_option("wpgpxmaps_graph_line_color_hr", '#ff77bd', '', 'yes'); - add_option('wpgpxmaps_show_cadence','','','yes'); - add_option('wpgpxmaps_zoomonscrollwheel','','','yes'); - add_option('wpgpxmaps_download','','','yes'); - add_option('wpgpxmaps_summary','','','yes'); - add_option('wpgpxmaps_skipcache','','','yes'); -} - -function WP_GPX_Maps_remove() { - delete_option('wpgpxmaps_width'); - delete_option('wpgpxmaps_graph_height'); - delete_option('wpgpxmaps_height'); - delete_option('wpgpxmaps_map_type'); - delete_option('wpgpxmaps_show_waypoint'); - delete_option('wpgpxmaps_show_speed'); - delete_option('wpgpxmaps_pointsoffset'); - delete_option('wpgpxmaps_donotreducegpx'); - delete_option('wpgpxmaps_unit_of_measure'); - delete_option('wpgpxmaps_unit_of_measure_speed'); - delete_option('wpgpxmaps_graph_line_color'); - delete_option('wpgpxmaps_map_line_color'); - delete_option('wpgpxmaps_graph_line_color_speed'); - delete_option('wpgpxmaps_graph_offset_from1'); - delete_option('wpgpxmaps_graph_offset_to1'); - delete_option('wpgpxmaps_graph_offset_from2'); - delete_option('wpgpxmaps_graph_offset_to2'); - delete_option('wpgpxmaps_map_start_icon'); - delete_option('wpgpxmaps_map_end_icon'); - delete_option('wpgpxmaps_map_current_icon'); - delete_option('wpgpxmaps_map_waypoint_icon'); - delete_option('wpgpxmaps_map_nggallery'); - delete_option('wpgpxmaps_show_hr'); - delete_option('wpgpxmaps_graph_line_color_hr'); - delete_option('wpgpxmaps_show_cadence'); - delete_option('wpgpxmaps_graph_line_color_cad'); - delete_option('wpgpxmaps_zoomonscrollwheel'); - delete_option('wpgpxmaps_download'); - delete_option('wpgpxmaps_summary'); - delete_option('wpgpxmaps_skipcache'); -} - -?>