[3447] | 1 | <?php |
---|
| 2 | if ( !defined('PHPWG_ROOT_PATH') ) |
---|
| 3 | define('PHPWG_ROOT_PATH','../../'); |
---|
| 4 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 5 | |
---|
| 6 | if (!isset($rvm_dir)) |
---|
| 7 | access_denied( 'Plugin not installed' ); |
---|
| 8 | |
---|
| 9 | include_once( dirname(__FILE__) .'/include/functions_map.php'); |
---|
| 10 | include_once( dirname(__FILE__) .'/include/functions.php'); |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | //set_make_full_url(); |
---|
| 14 | $page['root_path']=get_absolute_root_url(false); |
---|
| 15 | |
---|
| 16 | $rewritten = ''; |
---|
| 17 | foreach (array_keys($_GET) as $key) |
---|
| 18 | { |
---|
| 19 | $rewritten = $key; |
---|
| 20 | break; |
---|
| 21 | } |
---|
| 22 | // deleting first "/" if displayed |
---|
| 23 | $tokens = explode( |
---|
| 24 | '/', |
---|
| 25 | preg_replace('#^/#', '', $rewritten) |
---|
| 26 | ); |
---|
| 27 | $next_token = 0; |
---|
| 28 | $result = rvm_parse_map_data_url($tokens, $next_token); |
---|
| 29 | $page = array_merge( $page, $result ); |
---|
| 30 | |
---|
| 31 | $where_sql = rvm_bounds_to_sql( $page['box'] ); |
---|
| 32 | |
---|
[26331] | 33 | $img_fields = ' i.id,i.representative_ext,i.name,i.comment,i.file,i.path,i.latitude AS lat,i.longitude AS lon,i.width,i.height,i.rotation'; |
---|
[3447] | 34 | |
---|
| 35 | $was_flat = @$page['flat']; |
---|
| 36 | $page['flat']=true; |
---|
| 37 | rvm_build_section_items($img_fields, $where_sql, RVM_BUILD_HASH); |
---|
| 38 | if (!$was_flat) unset($page['flat']); |
---|
| 39 | |
---|
| 40 | /*header('Cache-Control: public' ); |
---|
| 41 | header('Expires: '.gmdate('D, d M Y H:i:s', time()+600).' GMT'); |
---|
| 42 | header('Pragma:');*/ |
---|
| 43 | header('Content-Type: text/plain; charset='.get_pwg_charset()); |
---|
[13092] | 44 | header('X-Robots-Tag: noindex'); |
---|
[3447] | 45 | |
---|
| 46 | $clusters = array(); |
---|
| 47 | $cluster_debug = ''; |
---|
| 48 | if ( !empty($page['items']) ) |
---|
| 49 | { |
---|
| 50 | include_once( dirname(__FILE__) .'/include/cluster_maker.php'); |
---|
| 51 | $cm = new ClusterMaker(); |
---|
| 52 | $clusters = $cm->make_clusters( |
---|
| 53 | $page['items'], |
---|
| 54 | isset($_GET['lap']) ? $_GET['lap'] : 0.01, |
---|
| 55 | isset($_GET['lop']) ? $_GET['lop'] : 0.01, |
---|
| 56 | isset($_GET['n']) ? $_GET['n'] : rvm_get_config_var('nb_markers',40) |
---|
| 57 | ); |
---|
| 58 | $cluster_debug .= ' cluster: '. $cm->debug_str. ';'; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | function jsgm_position( $position ) |
---|
| 62 | { |
---|
[12698] | 63 | return 'new google.maps.LatLng(' . $position['lat'] . ',' . $position['lon'] . ')'; |
---|
[3447] | 64 | } |
---|
| 65 | |
---|
| 66 | function jsgm_bounds( $bounds ) |
---|
| 67 | { |
---|
[12698] | 68 | return 'new google.maps.LatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')'; |
---|
[3447] | 69 | } |
---|
| 70 | |
---|
| 71 | function jsgm_str( $str ) |
---|
| 72 | { |
---|
| 73 | return '"'. str_replace(array("\\",'"',"\n","\r","\t"), array("\\\\",'\"',"\\n","\\r","\\t"), $str) .'"'; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | $start_output = get_moment(); |
---|
| 77 | |
---|
| 78 | |
---|
[28598] | 79 | echo "{\ntitle:", jsgm_str( strip_tags(trigger_change('render_element_description', $page['title']) ) ) |
---|
[18609] | 80 | , ",\npage_url:", jsgm_str( duplicate_index_url( array('start'=>0) ) ) |
---|
| 81 | , ",\nblowup_url:", jsgm_str( rvm_duplicate_blowup_url( array('start'=>0) ) ) |
---|
| 82 | , ",\nkml_url:", jsgm_str( rvm_duplicate_kml_index_url( array('start'=>0, 'flat'=>1) ) ) |
---|
| 83 | , ",\nnb_items:", count($page['items']); |
---|
[3447] | 84 | |
---|
[18609] | 85 | echo ",\nbounds:"; |
---|
[3447] | 86 | if ( isset($cm) ) |
---|
[18609] | 87 | echo jsgm_bounds( $cm->bounds ); |
---|
[3447] | 88 | else |
---|
[18609] | 89 | echo "null"; |
---|
[3447] | 90 | |
---|
[18609] | 91 | echo ",\n\nnb_clusters:", count($clusters); |
---|
[3447] | 92 | |
---|
[18609] | 93 | echo ",\nimage_clusters:[\n"; |
---|
[3447] | 94 | $i=0; |
---|
[17468] | 95 | $thumb_params = ImageStdParams::get_by_type(IMG_THUMB); |
---|
[18578] | 96 | $page_url_model = duplicate_picture_url( |
---|
| 97 | array( |
---|
| 98 | 'image_id' => 123456789, |
---|
| 99 | 'image_file' => 'dummy_file.txt', |
---|
| 100 | 'flat' => 1, |
---|
| 101 | ), |
---|
| 102 | array('start') |
---|
| 103 | ); |
---|
| 104 | |
---|
[3447] | 105 | foreach( $clusters as $c ) |
---|
| 106 | { |
---|
[18609] | 107 | if ($i) echo ",\n\n" ; |
---|
| 108 | echo '{position:', jsgm_position( bounds_center($c->bounds) ); |
---|
| 109 | echo ",\nbounds:", jsgm_bounds( $c->bounds ); |
---|
| 110 | echo ",\nnb_items:", count($c->items); |
---|
| 111 | echo ",\n"; |
---|
[3447] | 112 | |
---|
[18609] | 113 | echo 'blowup_url:"', rvm_duplicate_blowup_url(array('box'=>$c->bounds), array('start') ), '"'; |
---|
[3447] | 114 | |
---|
| 115 | $max_per_cluster = rvm_get_config_var('nb_images_per_marker',20); |
---|
[12719] | 116 | if ( count($c->items) > $max_per_cluster ) |
---|
| 117 | $c->items = array_slice($c->items, 0, $max_per_cluster); |
---|
[18609] | 118 | |
---|
| 119 | echo ",\nitems:["; |
---|
[12719] | 120 | for ($j=0; $j<count($c->items); $j++) |
---|
[3447] | 121 | { |
---|
[12719] | 122 | $img = $page['items'] [ $c->items[$j] ]; |
---|
[3447] | 123 | |
---|
[18578] | 124 | $page_url = str_replace(array('123456789','dummy_file'), array($img['id'], get_filename_wo_extension($img['file'])), $page_url_model); |
---|
[25792] | 125 | $thumb = new DerivativeImage($thumb_params, new SrcImage($img)); |
---|
| 126 | $thsize = $thumb->get_size(); |
---|
[3447] | 127 | |
---|
[18609] | 128 | if ($j) echo( "," ); |
---|
[25792] | 129 | echo "{tn:", jsgm_str( $thumb->get_url() ); |
---|
| 130 | echo ",w:",$thsize[0],',h:',$thsize[1]; |
---|
| 131 | echo ",t:", jsgm_str( render_element_name($img) ); |
---|
| 132 | echo ",d:", jsgm_str( render_element_description($img) ); |
---|
| 133 | echo ",url:", jsgm_str( $page_url ); |
---|
[18609] | 134 | echo "}"; |
---|
[3447] | 135 | } |
---|
[18609] | 136 | echo "]\n}"; |
---|
[3447] | 137 | $i++; |
---|
| 138 | } |
---|
[18609] | 139 | echo "] /*clusters*/\n"; |
---|
[3447] | 140 | |
---|
| 141 | $time = get_elapsed_time($t2, get_moment()); |
---|
| 142 | $page['queries_time'] = number_format($page['queries_time'],3,'.',' '); |
---|
[18609] | 143 | echo "\n,debug:'$time; out:", get_elapsed_time($start_output,get_moment()), ";$cluster_debug queries:", $page['count_queries'], " in ", $page['queries_time'], "s'\n" ; |
---|
[3447] | 144 | |
---|
[18609] | 145 | echo '}'; |
---|
[6639] | 146 | ?> |
---|