2013-02-04 08:58:18 +00:00
|
|
|
<?php
|
2019-06-18 07:09:56 +00:00
|
|
|
/**
|
2018-04-04 09:40:51 +00:00
|
|
|
* Plugin Name: WP-GPX-Maps
|
|
|
|
* Plugin URI: http://www.devfarm.it/
|
|
|
|
* Description: Draws a GPX track with altitude chart
|
2020-05-09 15:22:14 +00:00
|
|
|
* Version: 1.7.00.1
|
2018-04-04 09:40:51 +00:00
|
|
|
* Author: Bastianon Massimo
|
|
|
|
* Author URI: http://www.devfarm.it/
|
|
|
|
* Text Domain: wp-gpx-maps
|
|
|
|
* Domain Path: /languages
|
2020-05-09 15:22:14 +00:00
|
|
|
* Gitea Plugin URI: https://gitea.dyomedea.com/Dyomedea/wp-gpx-maps
|
2019-06-18 07:09:56 +00:00
|
|
|
*
|
|
|
|
* @package WP-GPX-Maps
|
2018-04-04 09:40:51 +00:00
|
|
|
*/
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
|
|
//error_reporting (E_ALL);
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
require 'wp-gpx-maps_utils.php';
|
|
|
|
require 'wp-gpx-maps_admin.php';
|
2013-02-04 08:58:18 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
add_shortcode( 'sgpx', 'handle_WP_GPX_Maps_Shortcodes' );
|
|
|
|
add_shortcode( 'sgpxf', 'handle_WP_GPX_Maps_folder_Shortcodes' );
|
|
|
|
register_activation_hook( __FILE__, 'WP_GPX_Maps_install' );
|
|
|
|
register_deactivation_hook( __FILE__, 'WP_GPX_Maps_remove' );
|
|
|
|
add_filter( 'plugin_action_links', 'WP_GPX_Maps_action_links', 10, 2 );
|
|
|
|
add_action( 'wp_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts' );
|
|
|
|
add_action( 'admin_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts_admin' );
|
|
|
|
add_action( 'plugins_loaded', 'WP_GPX_Maps_lang_init' );
|
2013-04-03 14:51:40 +00:00
|
|
|
|
|
|
|
function WP_GPX_Maps_lang_init() {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( function_exists( 'load_plugin_textdomain' ) ) {
|
|
|
|
load_plugin_textdomain( 'wp-gpx-maps', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
|
|
|
}
|
2013-04-03 14:51:40 +00:00
|
|
|
}
|
2013-02-04 08:58:18 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function WP_GPX_Maps_action_links( $links, $file ) {
|
|
|
|
|
|
|
|
static $this_plugin;
|
|
|
|
|
|
|
|
if ( ! $this_plugin ) {
|
|
|
|
$this_plugin = plugin_basename( __FILE__ );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check to make sure we are on the correct plugin.
|
|
|
|
if ( $file == $this_plugin ) {
|
|
|
|
// the anchor tag and href to the URL we want. For a "Settings"
|
|
|
|
// link, this needs to be the url of your settings page. Authors
|
|
|
|
// access tracks via the admin page.
|
|
|
|
if ( current_user_can( 'manage_options' ) ) {
|
|
|
|
$menu_root = 'options-general.php';
|
|
|
|
} elseif ( current_user_can( 'publish_posts' ) ) {
|
|
|
|
$menu_root = 'admin.php';
|
|
|
|
}
|
|
|
|
$settings_link = '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/' . $menu_root . '?page=WP-GPX-Maps">' . __( 'Settings', 'wp-gpx-maps' ) . '</a>';
|
|
|
|
// Add the link to the list.
|
|
|
|
array_unshift( $links, $settings_link );
|
|
|
|
}
|
|
|
|
return $links;
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function enqueue_WP_GPX_Maps_scripts_admin( $hook ) {
|
|
|
|
|
|
|
|
if ( strpos( $hook, 'WP-GPX-Maps' ) !== false ) {
|
|
|
|
|
|
|
|
/* Admin Style CSS */
|
2019-07-02 06:39:27 +00:00
|
|
|
wp_register_style( 'admin-style', plugins_url( 'css/admin-style.css', __FILE__ ), array(), '1.0.0' );
|
|
|
|
wp_enqueue_style( 'admin-style' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* mColorPicker */
|
|
|
|
wp_register_script( 'mColorPicker', plugins_url( '/js/mColorPicker_min.js', __FILE__ ), array(), '1.0 r39' );
|
|
|
|
wp_enqueue_script( 'mColorPicker' );
|
|
|
|
/* bootstrap-table */
|
2019-07-02 06:39:27 +00:00
|
|
|
wp_register_script( 'bootstrap-table', plugins_url( '/js/bootstrap-table.js', __FILE__ ), array(), '1.13.2' );
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_enqueue_script( 'bootstrap-table' );
|
2019-07-02 06:39:27 +00:00
|
|
|
wp_register_style( 'bootstrap-table', plugins_url( '/css/bootstrap-table.css', __FILE__ ), array(), '1.13.2' );
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_enqueue_style( 'bootstrap-table' );
|
2018-03-13 08:19:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function enqueue_WP_GPX_Maps_scripts() {
|
2018-03-10 10:40:30 +00:00
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
/* Output Style CSS */
|
|
|
|
wp_register_style( 'output-style', plugins_url( 'css/output-style.css', __FILE__ ), array(), '1.0.0' );
|
|
|
|
wp_enqueue_style( 'output-style' );
|
|
|
|
|
|
|
|
/* Leaflet */
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_style( 'leaflet', plugins_url( '/ThirdParties/Leaflet_1.5.1/leaflet.css', __FILE__ ), array(), '1.5.1' );
|
|
|
|
wp_enqueue_style( 'leaflet' );
|
2019-07-02 06:39:27 +00:00
|
|
|
|
|
|
|
/* Leaflet.markercluster */
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_style( 'leaflet.markercluster', plugins_url( '/ThirdParties/Leaflet.markercluster-1.4.1/MarkerCluster.css', __FILE__ ), array(), '1.4.1,' );
|
|
|
|
wp_enqueue_style( 'leaflet.markercluster' );
|
2019-07-02 06:39:27 +00:00
|
|
|
|
|
|
|
/* Leaflet.Photo */
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_style( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.css', __FILE__ ), array(), '0' );
|
|
|
|
wp_enqueue_style( 'leaflet.Photo' );
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
/* Leaflet.fullscreen */
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_style( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.css', __FILE__ ), array(), '1.5.1' );
|
2018-07-27 15:21:52 +00:00
|
|
|
wp_enqueue_style( 'leaflet.fullscreen' );
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_script( 'leaflet', plugins_url( '/ThirdParties/Leaflet_1.5.1/leaflet.js', __FILE__ ), array(), '1.5.1' );
|
|
|
|
wp_register_script( 'leaflet.markercluster', plugins_url( '/ThirdParties/Leaflet.markercluster-1.4.1/leaflet.markercluster.js', __FILE__ ), array( 'leaflet' ), '1.4.1' );
|
|
|
|
wp_register_script( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.js', __FILE__ ), array( 'leaflet', 'leaflet.markercluster' ), '0' );
|
|
|
|
wp_register_script( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.js', __FILE__ ), array( 'leaflet' ), '1.4.5' );
|
2018-07-27 15:21:52 +00:00
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
/* Chartjs */
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_register_script( 'chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), '2.8.0' );
|
|
|
|
|
|
|
|
wp_register_script( 'WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array( 'jquery', 'leaflet', 'chartjs' ), '1.6.02' );
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
wp_enqueue_script( 'output-style' );
|
2019-06-18 07:09:56 +00:00
|
|
|
wp_enqueue_script( 'leaflet' );
|
|
|
|
wp_enqueue_script( 'leaflet.markercluster' );
|
|
|
|
wp_enqueue_script( 'leaflet.Photo' );
|
|
|
|
wp_enqueue_script( 'leaflet.fullscreen' );
|
|
|
|
wp_enqueue_script( 'jquery' );
|
|
|
|
wp_enqueue_script( 'chartjs' );
|
|
|
|
wp_enqueue_script( 'WP-GPX-Maps' );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function wpgpxmaps_findValue( $attr, $attributeName, $optionName, $defaultValue ) {
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
$val = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( isset( $attr[$attributeName] ) ) {
|
2013-02-04 08:58:18 +00:00
|
|
|
$val = $attr[$attributeName];
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $val == '' ) {
|
|
|
|
$val = get_option( $optionName );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $val == '' && isset( $_GET[$attributeName] ) && $attributeName != 'download' ) {
|
2013-02-04 08:58:18 +00:00
|
|
|
$val = $_GET[$attributeName];
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $val == '' ) {
|
2013-02-04 08:58:18 +00:00
|
|
|
$val = $defaultValue;
|
|
|
|
}
|
|
|
|
return $val;
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
|
|
|
|
|
|
|
|
$folder = wpgpxmaps_findValue( $attr, 'folder', '', '' );
|
|
|
|
$pointsoffset = wpgpxmaps_findValue( $attr, 'pointsoffset', 'wpgpxmaps_pointsoffset', 10 );
|
|
|
|
$distanceType = wpgpxmaps_findValue( $attr, 'distanceType', 'wpgpxmaps_distance_type', 0 );
|
|
|
|
$donotreducegpx = wpgpxmaps_findValue( $attr, 'donotreducegpx', 'wpgpxmaps_donotreducegpx', false );
|
|
|
|
$uom = wpgpxmaps_findValue( $attr, 'uom', 'wpgpxmaps_unit_of_measure', '0' );
|
|
|
|
|
|
|
|
/* Fix folder path */
|
|
|
|
$sitePath = wp_gpx_maps_sitePath();
|
|
|
|
$folder = trim( $folder );
|
|
|
|
$folder = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $folder );
|
|
|
|
$folder = $sitePath . $folder;
|
|
|
|
|
|
|
|
$files = scandir( $folder );
|
|
|
|
|
|
|
|
foreach ( $files as $file ) {
|
|
|
|
|
|
|
|
if ( strtolower( substr( $file, - 4 ) ) == '.gpx' ) {
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
$gpx = $folder . DIRECTORY_SEPARATOR . $file;
|
2019-06-18 07:09:56 +00:00
|
|
|
$points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType );
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_maps = '';
|
2014-03-14 13:38:36 +00:00
|
|
|
$points_graph_dist = '';
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_ele = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( is_array( $points_x_lat ) )
|
2019-06-18 07:09:56 +00:00
|
|
|
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 ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_maps .= 'null,';
|
2014-03-14 13:38:36 +00:00
|
|
|
$points_graph_dist .= 'null,';
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_ele .= 'null,';
|
2014-03-14 13:38:36 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
} 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' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / miles */
|
2014-03-14 13:38:36 +00:00
|
|
|
$_dist *= 0.000621371192;
|
2019-06-18 07:09:56 +00:00
|
|
|
$_ele *= 3.2808399;
|
|
|
|
|
|
|
|
} elseif ( $uom == '2' ) {
|
|
|
|
/* meters / kilometers */
|
|
|
|
$_dist = (float) ( $_dist / 1000 );
|
|
|
|
|
|
|
|
} elseif ( $uom == '3' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* meters / nautical miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$_dist = (float) ( $_dist / 1000 / 1.852 );
|
|
|
|
|
|
|
|
} elseif ( $uom == '4' ) {
|
|
|
|
/* meters / miles */
|
2014-03-14 13:38:36 +00:00
|
|
|
$_dist *= 0.000621371192;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
} elseif ( $uom == '5' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / nautical miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$_dist = (float) ( $_dist / 1000 / 1.852 );
|
2014-06-09 13:18:24 +00:00
|
|
|
$_ele *= 3.2808399;
|
2014-03-14 13:38:36 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$points_graph_dist .= number_format( $_dist, 2, '.', '' ) . ',';
|
|
|
|
$points_graph_ele .= number_format( $_ele, 2, '.', '' ) . ',';
|
|
|
|
|
2014-03-14 13:38:36 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
}
|
|
|
|
print_r( $points );
|
2014-03-14 13:38:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
|
|
$error = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
/* General */
|
|
|
|
$gpx = wpgpxmaps_findValue( $attr, 'gpx', '', '' );
|
|
|
|
$w = wpgpxmaps_findValue( $attr, 'width', 'wpgpxmaps_width', '100%' );
|
|
|
|
$mh = wpgpxmaps_findValue( $attr, 'mheight', 'wpgpxmaps_height', '450px' );
|
|
|
|
$gh = wpgpxmaps_findValue( $attr, 'gheight', 'wpgpxmaps_graph_height', '200px' );
|
|
|
|
$distanceType = wpgpxmaps_findValue( $attr, 'distanceType', 'wpgpxmaps_distance_type', 0 );
|
|
|
|
$skipcache = wpgpxmaps_findValue( $attr, 'skipcache', 'wpgpxmaps_skipcache', '' );
|
|
|
|
$download = wpgpxmaps_findValue( $attr, 'download', 'wpgpxmaps_download', '' );
|
|
|
|
$usegpsposition = wpgpxmaps_findValue( $attr, 'usegpsposition', 'wpgpxmaps_usegpsposition', false );
|
|
|
|
/* Print Summary Table */
|
2019-07-02 06:39:27 +00:00
|
|
|
$summary = wpgpxmaps_findValue( $attr, 'summary', 'wpgpxmaps_summary', false );
|
2019-06-18 07:09:56 +00:00
|
|
|
$p_tot_len = wpgpxmaps_findValue( $attr, 'summarytotlen', 'wpgpxmaps_summary_tot_len', false );
|
|
|
|
$p_max_ele = wpgpxmaps_findValue( $attr, 'summarymaxele', 'wpgpxmaps_summary_max_ele', false );
|
|
|
|
$p_min_ele = wpgpxmaps_findValue( $attr, 'summaryminele', 'wpgpxmaps_summary_min_ele', false );
|
|
|
|
$p_total_ele_up = wpgpxmaps_findValue( $attr, 'summaryeleup', 'wpgpxmaps_summary_total_ele_up', false );
|
|
|
|
$p_total_ele_down = wpgpxmaps_findValue( $attr, 'summaryeledown', 'wpgpxmaps_summary_total_ele_down', false );
|
|
|
|
$p_avg_speed = wpgpxmaps_findValue( $attr, 'summaryavgspeed', 'wpgpxmaps_summary_avg_speed', false );
|
|
|
|
$p_avg_cad = wpgpxmaps_findValue( $attr, 'summaryavgcad', 'wpgpxmaps_summary_avg_cad', false );
|
|
|
|
$p_avg_hr = wpgpxmaps_findValue( $attr, 'summaryavghr', 'wpgpxmaps_summary_avg_hr', false );
|
|
|
|
$p_avg_temp = wpgpxmaps_findValue( $attr, 'summaryavgtemp', 'wpgpxmaps_summary_avg_temp', false );
|
|
|
|
$p_total_time = wpgpxmaps_findValue( $attr, 'summarytotaltime', 'wpgpxmaps_summary_total_time', false );
|
|
|
|
/* Map */
|
|
|
|
$mt = wpgpxmaps_findValue( $attr, 'mtype', 'wpgpxmaps_map_type', 'HYBRID' );
|
|
|
|
$color_map = wpgpxmaps_findValue( $attr, 'mlinecolor', 'wpgpxmaps_map_line_color', '#3366cc' );
|
|
|
|
$zoomOnScrollWheel = wpgpxmaps_findValue( $attr, 'zoomonscrollwheel', 'wpgpxmaps_zoomonscrollwheel', false );
|
|
|
|
$showW = wpgpxmaps_findValue( $attr, 'waypoints', 'wpgpxmaps_show_waypoint', false );
|
|
|
|
$startIcon = wpgpxmaps_findValue( $attr, 'starticon', 'wpgpxmaps_map_start_icon', '' );
|
|
|
|
$endIcon = wpgpxmaps_findValue( $attr, 'endicon', 'wpgpxmaps_map_end_icon', '' );
|
|
|
|
$currentpositioncon = wpgpxmaps_findValue( $attr, 'currentpositioncon', 'wpgpxmaps_currentpositioncon', '' );
|
|
|
|
$currentIcon = wpgpxmaps_findValue( $attr, 'currenticon', 'wpgpxmaps_map_current_icon', '' );
|
|
|
|
$waypointIcon = wpgpxmaps_findValue( $attr, 'waypointicon', 'wpgpxmaps_map_waypoint_icon', '' );
|
|
|
|
/* Diagram - Elevation */
|
2019-07-02 06:39:27 +00:00
|
|
|
$showEle = wpgpxmaps_findValue( $attr, 'showele', 'wpgpxmaps_show_elevation', true );
|
2019-06-18 07:09:56 +00:00
|
|
|
$color_graph = wpgpxmaps_findValue( $attr, 'glinecolor', 'wpgpxmaps_graph_line_color', '#3366cc' );
|
|
|
|
$uom = wpgpxmaps_findValue( $attr, 'uom', 'wpgpxmaps_unit_of_measure', '0' );
|
|
|
|
$chartFrom1 = wpgpxmaps_findValue( $attr, 'chartfrom1', 'wpgpxmaps_graph_offset_from1', '' );
|
|
|
|
$chartTo1 = wpgpxmaps_findValue( $attr, 'chartto1', 'wpgpxmaps_graph_offset_to1', '' );
|
|
|
|
/* Diagram - Speed */
|
|
|
|
$showSpeed = wpgpxmaps_findValue( $attr, 'showspeed', 'wpgpxmaps_show_speed', false );
|
|
|
|
$color_graph_speed = wpgpxmaps_findValue( $attr, 'glinecolorspeed', 'wpgpxmaps_graph_line_color_speed', '#ff0000' );
|
|
|
|
$uomspeed = wpgpxmaps_findValue( $attr, 'uomspeed', 'wpgpxmaps_unit_of_measure_speed', '0' );
|
|
|
|
$chartFrom2 = wpgpxmaps_findValue( $attr, 'chartfrom2', 'wpgpxmaps_graph_offset_from2', '' );
|
|
|
|
$chartTo2 = wpgpxmaps_findValue( $attr, 'chartto2', 'wpgpxmaps_graph_offset_to2', '' );
|
|
|
|
/* Diagram - Heart rate */
|
|
|
|
$showHr = wpgpxmaps_findValue( $attr, 'showhr', 'wpgpxmaps_show_hr', false );
|
|
|
|
$color_graph_hr = wpgpxmaps_findValue( $attr, 'glinecolorhr', 'wpgpxmaps_graph_line_color_hr', '#ff77bd' );
|
|
|
|
/* Diagram - Temperature */
|
|
|
|
$showAtemp = wpgpxmaps_findValue( $attr, 'showatemp', 'wpgpxmaps_show_atemp', false );
|
|
|
|
$color_graph_atemp = wpgpxmaps_findValue( $attr, 'glinecoloratemp', 'wpgpxmaps_graph_line_color_atemp', '#ff77bd' );
|
|
|
|
/* Diagram - Cadence */
|
2019-07-02 06:39:27 +00:00
|
|
|
$showCad = wpgpxmaps_findValue( $attr, 'showcad', 'wpgpxmaps_show_cadence', false );
|
|
|
|
$color_graph_cad = wpgpxmaps_findValue( $attr, 'glinecolorcad', 'wpgpxmaps_graph_line_color_cad', '#beecff' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Diagram - Grade */
|
|
|
|
$showGrade = wpgpxmaps_findValue( $attr, 'showgrade', 'wpgpxmaps_show_grade', false );
|
|
|
|
$color_graph_grade = wpgpxmaps_findValue( $attr, 'glinecolorgrade', 'wpgpxmaps_graph_line_color_grade', '#beecff' );
|
|
|
|
/* Pictures */
|
|
|
|
$ngGalleries = wpgpxmaps_findValue( $attr, 'nggalleries', 'wpgpxmaps_map_ngGalleries', '' );
|
|
|
|
$ngImages = wpgpxmaps_findValue( $attr, 'ngimages', 'wpgpxmaps_map_ngImages', '' );
|
|
|
|
$attachments = wpgpxmaps_findValue( $attr, 'attachments', 'wpgpxmaps_map_attachments', false );
|
|
|
|
$dtoffset = wpgpxmaps_findValue( $attr, 'dtoffset', 'wpgpxmaps_dtoffset', 0 );
|
|
|
|
/* Advanced */
|
|
|
|
$pointsoffset = wpgpxmaps_findValue( $attr, 'pointsoffset', 'wpgpxmaps_pointsoffset', 10 );
|
|
|
|
$donotreducegpx = wpgpxmaps_findValue( $attr, 'donotreducegpx', 'wpgpxmaps_donotreducegpx', false );
|
|
|
|
$allow_users_upload = wpgpxmaps_findValue( $attr, 'wpgpxmaps_allow_users_upload', 'wpgpxmaps_allow_users_view', false );
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
$colors_map = "\"" . implode( "\",\"", ( explode( ' ', $color_map ) ) ) . "\"";
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
|
|
$gpxurl = $gpx;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
/* Add file modification time to cache filename to catch new uploads with same file name */
|
|
|
|
$mtime = wp_gpx_maps_sitePath() . str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, trim( $gpx ) );
|
|
|
|
if ( file_exists( $mtime ) ) {
|
|
|
|
$mtime = filemtime( $mtime );
|
2014-09-08 07:19:44 +00:00
|
|
|
} else {
|
|
|
|
$mtime = 0;
|
|
|
|
}
|
2019-01-03 11:11:14 +00:00
|
|
|
$cacheFileName = "$gpx,$mtime,$w,$mh,$mt,$gh,$showEle,$showW,$showHr,$showAtemp,$showCad,$donotreducegpx,$pointsoffset,$showSpeed,$showGrade,$uomspeed,$uom,$distanceType,v1.3.9";
|
2013-02-04 08:58:18 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
$cacheFileName = md5( $cacheFileName );
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
$gpxcache = gpxCacheFolderPath();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( ! ( file_exists( $gpxcache ) && is_dir( $gpxcache ) ) )
|
|
|
|
@mkdir( $gpxcache, 0755, true );
|
|
|
|
|
|
|
|
$gpxcache .= DIRECTORY_SEPARATOR . $cacheFileName . '.tmp';
|
|
|
|
|
|
|
|
/* Try to load cache */
|
|
|
|
if ( file_exists( $gpxcache ) && ! ( $skipcache == true ) ) {
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
try {
|
2019-06-18 07:09:56 +00:00
|
|
|
$cache_str = file_get_contents( $gpxcache );
|
|
|
|
$cache_obj = unserialize( $cache_str );
|
|
|
|
$points_maps = $cache_obj['points_maps'];
|
|
|
|
$points_x_time = $cache_obj['points_x_time'];
|
|
|
|
$points_x_lat = $cache_obj['points_x_lat'];
|
|
|
|
$points_x_lon = $cache_obj['points_x_lon'];
|
|
|
|
$points_graph_dist = $cache_obj['points_graph_dist'];
|
|
|
|
$points_graph_ele = $cache_obj['points_graph_ele'];
|
|
|
|
$points_graph_speed = $cache_obj['points_graph_speed'];
|
|
|
|
$points_graph_hr = $cache_obj['points_graph_hr'];
|
|
|
|
$points_graph_atemp = $cache_obj['points_graph_atemp'];
|
|
|
|
$points_graph_cad = $cache_obj['points_graph_cad'];
|
|
|
|
$points_graph_grade = $cache_obj['points_graph_grade'];
|
|
|
|
$waypoints = $cache_obj['waypoints'];
|
|
|
|
$max_ele = $cache_obj['max_ele'];
|
|
|
|
$min_ele = $cache_obj['min_ele'];
|
|
|
|
$max_time = $cache_obj['max_time'];
|
|
|
|
$min_time = $cache_obj['min_time'];
|
|
|
|
$total_ele_up = $cache_obj['total_ele_up'];
|
|
|
|
$total_ele_down = $cache_obj['total_ele_down'];
|
|
|
|
$avg_speed = $cache_obj['avg_speed'];
|
|
|
|
$avg_cad = $cache_obj['avg_cad'];
|
|
|
|
$avg_hr = $cache_obj['avg_hr'];
|
|
|
|
$avg_temp = $cache_obj['avg_temp'];
|
|
|
|
$tot_len = $cache_obj['tot_len'];
|
|
|
|
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
$points_maps = '';
|
|
|
|
$points_x_time = '';
|
|
|
|
$points_x_lat = '';
|
|
|
|
$points_x_lon = '';
|
|
|
|
$points_graph_dist = '';
|
|
|
|
$points_graph_ele = '';
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_speed = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$points_graph_hr = '';
|
2014-03-14 13:38:36 +00:00
|
|
|
$points_graph_atemp = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$points_graph_cad = '';
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_grade = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$waypoints = '';
|
|
|
|
$max_ele = 0;
|
|
|
|
$min_ele = 0;
|
|
|
|
$max_time = 0;
|
|
|
|
$min_time = 0;
|
|
|
|
$total_ele_up = 0;
|
|
|
|
$total_ele_down = 0;
|
|
|
|
$avg_speed = 0;
|
|
|
|
$avg_cad = 0;
|
|
|
|
$avgv_hr = 0;
|
|
|
|
$avg_temp = 0;
|
|
|
|
$tot_len = 0;
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
$isGpxUrl = ( preg_match( '/^(http(s)?\:\/\/)/', trim( $gpx ) ) == 1 );
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( ( ! isset( $points_maps ) || $points_maps == '' ) && $gpx != '' ) {
|
|
|
|
// if (true) {
|
|
|
|
|
2018-03-13 08:23:40 +00:00
|
|
|
$sitePath = wp_gpx_maps_sitePath();
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$gpx = trim( $gpx );
|
|
|
|
|
|
|
|
if ( $isGpxUrl == true ) {
|
|
|
|
$gpx = downloadRemoteFile( $gpx );
|
|
|
|
} else {
|
|
|
|
$gpx = str_replace( array( '/', '\\' ), DIRECTORY_SEPARATOR, $gpx );
|
2013-02-04 08:58:18 +00:00
|
|
|
$gpx = $sitePath . $gpx;
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $gpx == '' ) {
|
2013-02-04 08:58:18 +00:00
|
|
|
return "No gpx found";
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType );
|
|
|
|
|
|
|
|
$points_maps = '';
|
|
|
|
$points_graph_dist = '';
|
|
|
|
$points_graph_ele = '';
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_speed = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$points_graph_hr = '';
|
2014-03-14 13:38:36 +00:00
|
|
|
$points_graph_atemp = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$points_graph_cad = '';
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_grade = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
$waypoints = '';
|
2013-02-04 08:58:18 +00:00
|
|
|
|
|
|
|
$points_x_time = $points->dt;
|
2019-06-18 07:09:56 +00:00
|
|
|
$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;
|
2013-02-04 08:58:18 +00:00
|
|
|
$total_ele_down = $points->totalEleDown;
|
2019-06-18 07:09:56 +00:00
|
|
|
$avg_speed = $points->avgSpeed;
|
|
|
|
$avg_cad = $points->avgCad;
|
|
|
|
$avg_hr = $points->avgHr;
|
|
|
|
$avg_temp = $points->avgTemp;
|
|
|
|
$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,';
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_dist .= 'null,';
|
2019-06-18 07:09:56 +00:00
|
|
|
$points_graph_ele .= 'null,';
|
|
|
|
|
|
|
|
if ( $showSpeed == true )
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_speed .= 'null,';
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $showHr == true )
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_hr .= 'null,';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showAtemp == true )
|
2014-03-14 13:38:36 +00:00
|
|
|
$points_graph_atemp .= 'null,';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showCad == true )
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_cad .= 'null,';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showGrade == true )
|
2013-02-04 08:58:18 +00:00
|
|
|
$points_graph_grade .= 'null,';
|
2019-06-18 07:09:56 +00:00
|
|
|
} 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') {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / miles */
|
2013-02-04 08:58:18 +00:00
|
|
|
$_dist *= 0.000621371192;
|
|
|
|
$_ele *= 3.2808399;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
} elseif ( $uom == '2') {
|
|
|
|
/* meters / kilometers */
|
|
|
|
$_dist = (float) ( $_dist / 1000 );
|
|
|
|
|
|
|
|
} elseif ( $uom == '3') {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* meters / nautical miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$_dist = (float) ( $_dist / 1000 / 1.852 );
|
|
|
|
|
|
|
|
} elseif ( $uom == '4' ) {
|
|
|
|
/* meters / miles */
|
2013-07-22 06:55:54 +00:00
|
|
|
$_dist *= 0.000621371192;
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
} elseif ( $uom == '5' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / nautical miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$_dist = (float) ( $_dist / 1000 / 1.852 );
|
2014-06-09 13:18:24 +00:00
|
|
|
$_ele *= 3.2808399;
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$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 ) . ',';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showHr == true ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_hr .= number_format( $points->hr[$i], 2, '.', '' ) . ',';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showAtemp == true ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_atemp .= number_format( $points->atemp[$i], 1, '.', '' ) . ',';
|
2014-03-14 13:38:36 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showCad == true ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_cad .= number_format( $points->cad[$i], 2, '.', '' ) . ',';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $showGrade == true ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$points_graph_grade .= number_format( $points->grade[$i], 2, '.', '' ) . ',';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-09 13:18:24 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $uom == '1' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$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';
|
|
|
|
|
|
|
|
} elseif ( $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';
|
|
|
|
|
|
|
|
} elseif ( $uom == '3' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* meters / nautical miles */
|
|
|
|
$tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
|
2019-06-18 07:09:56 +00:00
|
|
|
$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';
|
|
|
|
|
|
|
|
} elseif ( $uom == '4' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* meters / miles */
|
2019-06-18 07:09:56 +00:00
|
|
|
$tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi';
|
|
|
|
$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';
|
|
|
|
|
|
|
|
} elseif ( $uom == '5' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
/* feet / nautical miles */
|
|
|
|
$tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
|
2019-06-18 07:09:56 +00:00
|
|
|
$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 {
|
|
|
|
/* 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';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
$avg_speed = convertSpeed( $avg_speed, $uomspeed, true );
|
2015-12-17 10:56:23 +00:00
|
|
|
$waypoints = '[]';
|
2013-02-04 08:58:18 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $showW == true ) {
|
|
|
|
$wpoints = wpgpxmaps_getWayPoints( $gpx );
|
|
|
|
$waypoints = wp_json_encode( $wpoints );
|
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $showEle == false ) {
|
|
|
|
$points_graph_ele = '';
|
2013-11-18 13:45:18 +00:00
|
|
|
}
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
$p = '/(,|,null,)$/';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$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_atemp = preg_replace( $p, '', $points_graph_atemp );
|
|
|
|
$points_graph_cad = preg_replace( $p, '', $points_graph_cad );
|
|
|
|
$points_graph_grade = preg_replace( $p, '', $points_graph_grade );
|
|
|
|
|
|
|
|
$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_hr ) )
|
|
|
|
$points_graph_hr = '';
|
|
|
|
|
|
|
|
if ( preg_match( '/^(0,?)+$/', $points_graph_atemp ) )
|
|
|
|
$points_graph_atemp = '';
|
|
|
|
|
|
|
|
if ( preg_match( '/^(0,?)+$/', $points_graph_grade ) )
|
|
|
|
$points_graph_grade = '';
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
$ngimgs_data = '';
|
2013-07-05 12:43:58 +00:00
|
|
|
if ( $ngGalleries != '' || $ngImages != '' ) {
|
2019-06-18 07:09:56 +00:00
|
|
|
$ngimgs = getNGGalleryImages( $ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
|
2019-07-02 06:39:27 +00:00
|
|
|
$ngimgs_data = '';
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
foreach ( $ngimgs as $img ) {
|
|
|
|
$data = $img['data'];
|
2019-07-02 06:39:27 +00:00
|
|
|
$data = str_replace( '\n', '', $data );
|
2019-06-18 07:09:56 +00:00
|
|
|
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
if ( $attachments == true ) {
|
|
|
|
$attimgs = wpgpxmaps_getAttachedImages( $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
|
|
|
|
foreach ( $attimgs as $img ) {
|
|
|
|
$data = $img['data'];
|
2019-07-02 06:39:27 +00:00
|
|
|
$data = str_replace( '\n', '', $data );
|
2019-06-18 07:09:56 +00:00
|
|
|
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
|
2015-03-20 09:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
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_atemp' => $points_graph_atemp,
|
|
|
|
'points_graph_cad' => $points_graph_cad,
|
|
|
|
'points_graph_grade' => $points_graph_grade,
|
|
|
|
'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,
|
|
|
|
'avg_cad' => $avg_cad,
|
|
|
|
'avg_hr' => $avg_hr,
|
|
|
|
'avg_temp' => $avg_temp,
|
|
|
|
'tot_len' => $tot_len,
|
|
|
|
'max_time' => $max_time,
|
|
|
|
'min_time' => $min_time,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
LOCK_EX);
|
|
|
|
@chmod( $gpxcache, 0755 );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$hideGraph = ( $gh == '0' || $gh == '0px' );
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
global $post;
|
2019-06-18 07:09:56 +00:00
|
|
|
$r = $post->ID . '_' . rand( 1,5000000 );
|
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
$output = '
|
2019-06-18 07:09:56 +00:00
|
|
|
<div id="wpgpxmaps_' . $r . '" class="wpgpxmaps">
|
|
|
|
<div id="map_' . $r . '_cont" style="width:' . $w . '; height:' . $mh . ';position:relative" >
|
|
|
|
<div id="map_' . $r . '" style="width:' . $w . '; height:' . $mh . '"></div>
|
|
|
|
<div id="wpgpxmaps_' . $r . '_osm_footer" class="wpgpxmaps_osm_footer" style="display:none;"><span> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors</span></div>
|
2014-06-09 13:18:24 +00:00
|
|
|
</div>
|
2019-06-18 07:09:56 +00:00
|
|
|
<canvas id="myChart_' . $r . '" class="plot" style="width:' . $w . '; height:' . $gh . '"></canvas>
|
|
|
|
<div id="ngimages_' . $r . '" class="ngimages" style="display:none">' . $ngimgs_data . '</div>
|
|
|
|
<div id="report_' . $r . '" class="report"></div>
|
2013-02-04 08:58:18 +00:00
|
|
|
</div>
|
2019-06-18 07:09:56 +00:00
|
|
|
' . $error . '
|
2013-02-04 08:58:18 +00:00
|
|
|
<script type="text/javascript">
|
2019-06-18 07:09:56 +00:00
|
|
|
|
2015-12-17 10:56:23 +00:00
|
|
|
jQuery(document).ready(function() {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
jQuery( "#wpgpxmaps_' . $r . '" ).wpgpxmaps( {
|
|
|
|
targetId : "' . $r . '",
|
|
|
|
mapType : "' . $mt . '",
|
|
|
|
mapData : [' . $points_maps . '],
|
|
|
|
graphDist : [' . ( $hideGraph ? '' : $points_graph_dist ) . '],
|
|
|
|
graphEle : [' . ( $hideGraph ? '' : $points_graph_ele ) . '],
|
|
|
|
graphSpeed : [' . ( $hideGraph ? '' : $points_graph_speed ) . '],
|
|
|
|
graphHr : [' . ( $hideGraph ? '' : $points_graph_hr ) . '],
|
|
|
|
graphAtemp : [' . ( $hideGraph ? '' : $points_graph_atemp ) . '],
|
|
|
|
graphCad : [' . ( $hideGraph ? '' : $points_graph_cad ) . '],
|
|
|
|
graphGrade : [' . ( $hideGraph ? '' : $points_graph_grade ) . '],
|
|
|
|
waypoints : ' . $waypoints . ',
|
|
|
|
unit : "' . $uom . '",
|
|
|
|
unitspeed : "' . $uomspeed . '",
|
|
|
|
color1 : [' . $colors_map . '],
|
|
|
|
color2 : "' . $color_graph . '",
|
|
|
|
color3 : "' . $color_graph_speed . '",
|
|
|
|
color4 : "' . $color_graph_hr . '",
|
|
|
|
color5 : "' . $color_graph_cad . '",
|
|
|
|
color6 : "' . $color_graph_grade . '",
|
|
|
|
color7 : "' . $color_graph_atemp . '",
|
|
|
|
chartFrom1 : "' . $chartFrom1 . '",
|
|
|
|
chartTo1 : "' . $chartTo1 . '",
|
|
|
|
chartFrom2 : "' . $chartFrom2 . '",
|
|
|
|
chartTo2 : "' . $chartTo2 . '",
|
|
|
|
startIcon : "' . $startIcon . '",
|
|
|
|
endIcon : "' . $endIcon . '",
|
|
|
|
currentIcon : "' . $currentIcon . '",
|
|
|
|
waypointIcon : "' . $waypointIcon . '",
|
2019-06-18 07:09:56 +00:00
|
|
|
currentpositioncon : "' . $currentpositioncon . '",
|
2019-07-02 06:39:27 +00:00
|
|
|
usegpsposition : "' . $usegpsposition . '",
|
|
|
|
zoomOnScrollWheel : "' . $zoomOnScrollWheel . '",
|
|
|
|
ngGalleries : [' . $ngGalleries . '],
|
|
|
|
ngImages : [' . $ngImages . '],
|
|
|
|
pluginUrl : "' . plugins_url() . '",
|
|
|
|
TFApiKey : "' . get_option( 'wpgpxmaps_openstreetmap_apikey' ) . '",
|
|
|
|
langs : {
|
|
|
|
altitude : "' . __( 'Altitude', 'wp-gpx-maps' ) . '",
|
|
|
|
currentPosition : "' . __( 'Current position', 'wp-gpx-maps' ) . '",
|
|
|
|
speed : "' . __( 'Speed', 'wp-gpx-maps' ) . '",
|
|
|
|
grade : "' . __( 'Grade', 'wp-gpx-maps' ) . '",
|
|
|
|
heartRate : "' . __( 'Heart rate', 'wp-gpx-maps' ) . '",
|
|
|
|
atemp : "' . __( 'Temperature', 'wp-gpx-maps' ) . '",
|
|
|
|
cadence : "' . __( 'Cadence', 'wp-gpx-maps' ) . '",
|
|
|
|
goFullScreen : "' . __( 'Go full screen', 'wp-gpx-maps' ) . '",
|
|
|
|
exitFullFcreen : "' . __( 'Exit full screen', 'wp-gpx-maps' ) . '",
|
|
|
|
hideImages : "' . __( 'Hide images', 'wp-gpx-maps' ) . '",
|
|
|
|
showImages : "' . __( 'Show images', 'wp-gpx-maps' ) . '",
|
|
|
|
backToCenter : "' . __( 'Back to center', 'wp-gpx-maps' ) . '"
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
});
|
|
|
|
|
2015-12-17 10:56:23 +00:00
|
|
|
});
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
</script>';
|
|
|
|
|
|
|
|
/* Print summary */
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $summary == true && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '' ) ) {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
$output .= "<div id='wpgpxmaps_summary_" . $r . "' class='wpgpxmaps_summary'>";
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $points_graph_dist != '' && $p_tot_len == true ) {
|
|
|
|
$output .= "<span class='totlen'><span class='summarylabel'>" . __( 'Total distance:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $tot_len</span></span><br />";
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $points_graph_ele != ' ' ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $p_max_ele == true )
|
|
|
|
$output .= "<span class='maxele'><span class='summarylabel'>" . __( 'Max elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $max_ele</span></span><br />";
|
|
|
|
if ( $p_min_ele == true )
|
|
|
|
$output .= "<span class='minele'><span class='summarylabel'>" . __( 'Min elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $min_ele</span></span><br />";
|
|
|
|
if ( $p_total_ele_up == true )
|
|
|
|
$output .= "<span class='totaleleup'><span class='summarylabel'>" . __( 'Total climbing:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_up</span></span><br />";
|
|
|
|
if ( $p_total_ele_down == true )
|
|
|
|
$output .= "<span class='totaleledown'><span class='summarylabel'>" . __( 'Total descent:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_down</span></span><br />";
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $points_graph_speed != '' && $p_avg_speed == true ) {
|
|
|
|
$output .= "<span class='avgspeed'><span class='summarylabel'>" . __( 'Average speed:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_speed</span></span><br />";
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $points_graph_cad != '' && $p_avg_cad == true ) {
|
|
|
|
$output .= "<span class='avgcad'><span class='summarylabel'>" . __( 'Average cadence:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_cad</span></span><br />";
|
2018-12-08 09:44:28 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $points_graph_hr != '' && $p_avg_hr == true ) {
|
|
|
|
$output .= "<span class='avghr'><span class='summarylabel'>" . __( 'Average heart rate:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_hr</span></span><br />";
|
2019-01-03 11:11:14 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $points_graph_atemp != '' && $p_avg_temp == true ) {
|
|
|
|
$output .= "<span class='avgtemp'><span class='summarylabel'>" . __( 'Average temperature:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_temp</span></span><br />";
|
2019-01-03 11:11:14 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $p_total_time == true && $max_time > 0 ) {
|
|
|
|
$time_diff = date( 'H:i:s', ( $max_time - $min_time ) );
|
|
|
|
$output .= "<span class='totaltime'><span class='summarylabel'>" . __( 'Total time:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $time_diff</span></span><br />";
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
$output .= '</div>';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Print download link */
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( $download == true && $gpxurl != '' ) {
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $isGpxUrl == true ) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$dummy = ( defined( 'WP_SITEURL' ) ) ? WP_SITEURL : get_bloginfo( 'url' );
|
|
|
|
$gpxurl = $dummy . $gpxurl;
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
$output .= "<a href='$gpxurl' target='_new' download>" . __( 'Download', 'wp-gpx-maps' ) . '</a>';
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function convertSeconds( $s ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $s == 0 )
|
|
|
|
return 0;
|
|
|
|
$s = 1.0 / $s;
|
|
|
|
$_sSecT = $s * 60; // sec/km
|
2019-07-02 06:39:27 +00:00
|
|
|
$_sMin = floor( $_sSecT / 60 );
|
2019-06-18 07:09:56 +00:00
|
|
|
$_sSec = $_sSecT - $_sMin * 60;
|
2013-02-04 08:58:18 +00:00
|
|
|
return $_sMin + $_sSec / 100;
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function convertSpeed( $speed, $uomspeed, $addUom = false ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
|
2013-02-04 08:58:18 +00:00
|
|
|
$uom = '';
|
2019-07-02 06:39:27 +00:00
|
|
|
|
|
|
|
if ( $uomspeed == '6' ) {
|
2019-06-18 07:09:56 +00:00
|
|
|
/* min/100 meters */
|
|
|
|
$speed = 1 / $speed * 100 / 60;
|
|
|
|
$uom = ' min/100m';
|
|
|
|
|
|
|
|
} elseif ( $uomspeed == '5' ) {
|
|
|
|
/* knots */
|
|
|
|
$speed *= 1.94384449;
|
|
|
|
$uom = ' knots';
|
|
|
|
|
|
|
|
} elseif ( $uomspeed == '4' ) {
|
|
|
|
/* min/mi */
|
|
|
|
$speed = convertSeconds( $speed * 0.037282272 );
|
|
|
|
$uom = ' min/mi';
|
|
|
|
|
|
|
|
} elseif ( $uomspeed == '3' ) {
|
|
|
|
/* min/km */
|
|
|
|
$speed = convertSeconds( $speed * 0.06 );
|
|
|
|
$uom = ' min/km';
|
|
|
|
|
|
|
|
} elseif ( $uomspeed == '2' ) {
|
|
|
|
/* miles/h */
|
|
|
|
$speed *= 2.2369362920544025;
|
|
|
|
$uom = ' mi/h';
|
|
|
|
|
|
|
|
} elseif ( $uomspeed == '1' ) {
|
|
|
|
/* km/h */
|
|
|
|
$speed *= 3.6;
|
|
|
|
$uom = ' km/h';
|
2019-07-02 06:39:27 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
} else {
|
|
|
|
/* dafault m/s */
|
|
|
|
$uom = ' m/s';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $addUom == true ) {
|
|
|
|
return number_format( $speed, 2, '.', '' ) . $uom;
|
|
|
|
} else {
|
|
|
|
return number_format( $speed, 2, '.', '' );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function downloadRemoteFile( $remoteFile ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
try {
|
|
|
|
$newfname = tempnam( '/tmp', 'gpx' );
|
|
|
|
|
2019-07-02 06:39:27 +00:00
|
|
|
if ( function_exists( 'file_put_contents' ) ) {
|
2019-06-18 07:09:56 +00:00
|
|
|
file_put_contents( $newfname, fopen( $remoteFile, 'r' ) );
|
2014-09-08 07:19:44 +00:00
|
|
|
return $newfname;
|
2019-06-18 07:09:56 +00:00
|
|
|
}
|
2019-07-02 06:39:27 +00:00
|
|
|
$file = fopen( $remoteFile, 'rb' );
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $file ) {
|
2019-07-02 06:39:27 +00:00
|
|
|
$newf = fopen( $newfname, 'wb' );
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $newf )
|
|
|
|
while ( ! feof( $file ) ) {
|
|
|
|
fwrite( $newf, fread( $file, 1024 * 8 ), 1024 * 8 );
|
2014-09-08 07:19:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $file ) {
|
|
|
|
fclose( $file );
|
2014-09-08 07:19:44 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
if ( $newf ) {
|
|
|
|
fclose( $newf );
|
2014-09-08 07:19:44 +00:00
|
|
|
}
|
2019-06-18 07:09:56 +00:00
|
|
|
return $newfname;
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
print_r( $e );
|
2013-02-04 08:58:18 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 07:09:56 +00:00
|
|
|
function unescape( $value ) {
|
|
|
|
|
|
|
|
$value = str_replace( "'", "\'", $value );
|
2019-07-02 06:39:27 +00:00
|
|
|
$value = str_replace( array( '\n', '\r' ), '', $value );
|
2013-02-04 08:58:18 +00:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
function WP_GPX_Maps_install() {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
/* General */
|
|
|
|
add_option( 'wpgpxmaps_width', '100%', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_height', '450px', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_height', '200px', '', 'yes' );
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_distance_type', '0', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
add_option( 'wpgpxmaps_skipcache', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_download', '', '', 'yes' );
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_usegpsposition', '', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Print Summary Table */
|
|
|
|
add_option( 'wpgpxmaps_summary', '', '', 'yes' );
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_summary_tot_len', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_max_ele', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_min_ele', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_total_ele_up', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_total_ele_down', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_avg_speed', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_avg_cad', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_avg_hr', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_avg_temp', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_summary_total_time', '', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Map */
|
|
|
|
add_option( 'wpgpxmaps_map_type', 'HYBRID', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_map_line_color', '#3366cc', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_zoomonscrollwheel', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_show_waypoint', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_map_start_icon', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_map_end_icon', '', '', 'yes' );
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_currentpositioncon', '', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
add_option( 'wpgpxmaps_map_current_icon', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_map_waypoint_icon', '', '', 'yes' );
|
|
|
|
/* Diagram - Elevation */
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_show_elevation', 'true', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
add_option( 'wpgpxmaps_graph_line_color', '#3366cc', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_unit_of_measure', '0', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_offset_from1', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_offset_to1', '', '', 'yes' );
|
|
|
|
/* Diagram - Speed */
|
|
|
|
add_option( 'wpgpxmaps_show_speed', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_line_color_speed', '#ff0000', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_unit_of_measure_speed', '0', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_offset_from2', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_offset_to2', '', '', 'yes' );
|
|
|
|
/* Diagram - Heart rate */
|
|
|
|
add_option( 'wpgpxmaps_show_hr', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_line_color_hr', '#ff77bd', '', 'yes' );
|
|
|
|
/* Diagram - Temperature */
|
|
|
|
add_option( 'wpgpxmaps_show_atemp', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_line_color_atemp', '#ff77bd', '', 'yes' );
|
|
|
|
/* Diagram - Cadence */
|
|
|
|
add_option( 'wpgpxmaps_show_cadence', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_line_color_cad', '#beecff', '', 'yes' );
|
|
|
|
/* Diagram - Grade */
|
2019-07-02 06:39:27 +00:00
|
|
|
add_option( 'wpgpxmaps_show_grade', '', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_graph_line_color_grade', '#beecff', '', 'yes' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Pictures */
|
|
|
|
add_option( 'wpgpxmaps_map_nggallery', '', '', 'yes' );
|
|
|
|
/* Advanced */
|
|
|
|
add_option( 'wpgpxmaps_pointsoffset', '10', '', 'yes' );
|
|
|
|
add_option( 'wpgpxmaps_donotreducegpx', 'true', '', 'yes' );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function WP_GPX_Maps_remove() {
|
2019-06-18 07:09:56 +00:00
|
|
|
|
|
|
|
/* General */
|
|
|
|
delete_option( 'wpgpxmaps_width' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_height' );
|
|
|
|
delete_option( 'wpgpxmaps_height' );
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_distance_type' );
|
2019-06-18 07:09:56 +00:00
|
|
|
delete_option( 'wpgpxmaps_skipcache' );
|
|
|
|
delete_option( 'wpgpxmaps_download' );
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_usegpsposition' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Print Summary Table */
|
|
|
|
delete_option( 'wpgpxmaps_summary' );
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_summary_tot_len' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_max_ele' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_min_ele' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_total_ele_up' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_total_ele_down' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_avg_speed' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_avg_cad' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_avg_hr' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_avg_temp' );
|
|
|
|
delete_option( 'wpgpxmaps_summary_total_time' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Map */
|
|
|
|
delete_option( 'wpgpxmaps_map_type' );
|
|
|
|
delete_option( 'wpgpxmaps_map_line_color' );
|
|
|
|
delete_option( 'wpgpxmaps_zoomonscrollwheel' );
|
|
|
|
delete_option( 'wpgpxmaps_show_waypoint' );
|
|
|
|
delete_option( 'wpgpxmaps_map_start_icon' );
|
|
|
|
delete_option( 'wpgpxmaps_map_end_icon' );
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_currentpositioncon' );
|
2019-06-18 07:09:56 +00:00
|
|
|
delete_option( 'wpgpxmaps_map_current_icon' );
|
|
|
|
delete_option( 'wpgpxmaps_map_waypoint_icon' );
|
|
|
|
/* Diagram - Elevation */
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_show_elevation' );
|
2019-06-18 07:09:56 +00:00
|
|
|
delete_option( 'wpgpxmaps_graph_line_color' );
|
|
|
|
delete_option( 'wpgpxmaps_unit_of_measure' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_offset_from1' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_offset_to1' );
|
|
|
|
/* Diagram - Speed */
|
|
|
|
delete_option( 'wpgpxmaps_show_speed' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_line_color_speed' );
|
|
|
|
delete_option( 'wpgpxmaps_unit_of_measure_speed' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_offset_from2' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_offset_to2' );
|
|
|
|
/* Diagram - Heart rate */
|
|
|
|
delete_option( 'wpgpxmaps_show_hr' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_line_color_hr' );
|
|
|
|
/* Diagram - Temperature */
|
|
|
|
delete_option( 'wpgpxmaps_show_atemp' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_line_color_atemp' );
|
|
|
|
/* Diagram - Cadence */
|
|
|
|
delete_option( 'wpgpxmaps_show_cadence' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_line_color_cad' );
|
|
|
|
/* Diagram - Grade */
|
2019-07-02 06:39:27 +00:00
|
|
|
delete_option( 'wpgpxmaps_show_grade' );
|
|
|
|
delete_option( 'wpgpxmaps_graph_line_color_grade' );
|
2019-06-18 07:09:56 +00:00
|
|
|
/* Pictures */
|
|
|
|
delete_option( 'wpgpxmaps_map_nggallery' );
|
|
|
|
/* Advanced */
|
|
|
|
delete_option( 'wpgpxmaps_pointsoffset' );
|
|
|
|
delete_option( 'wpgpxmaps_donotreducegpx' );
|
2013-02-04 08:58:18 +00:00
|
|
|
}
|