Skip to content
Permalink
Browse files

show search results on map; updates #30, updates #235

  • Loading branch information...
following5 committed Jun 18, 2013
1 parent bfefda8 commit eb4a4aec722f88197f5a878b505a6036b603c31a
@@ -2505,6 +2505,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2083', 'NEW', '
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2084', 'show archived', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2085', 'hide archived', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2086', 'unknown search type', '2013-04-25 23:00:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2087', 'Show on map', '2013-04-25 23:00:00');

-- Table sys_trans_ref
SET NAMES 'utf8';
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2084', 'DE', 'archivierte einblenden', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2085', 'DE', 'archivierte ausblenden', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2086', 'DE', 'unbekannter Suchtyp', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2087', 'DE', 'auf Karte anzeigen', '2013-04-25 23:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
@@ -95,6 +95,7 @@
$search_in_gm_zip = '<a href="http://maps.google.de/maps?f=q&hl=de&q=' . urlencode("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."&output=kml&zip=1&count=max") . '" title="' . $translate->t('Show in Google Maps','','',0) . '">' . $translate->t('(in GM)','','',0) . '</a>';
$unknown_searchtype = t('unknown search type');
$showonmap = t('Show on map');
function dateDiff($interval, $dateTimeBegin, $dateTimeEnd)
@@ -27,14 +27,21 @@
?>

<div class="content2-container bg-blue02" style="margin-top:20px;">
<p class="content-title-noshade-size3">
<img src="resource2/ocstyle/images/cacheicon/traditional.gif" width="32" height="32" style="align:left;" alt="{t}Search{/t}" />&nbsp;
{t}{results_count} caches<span style="{search_headline_caches}"> matched</span>{/t}
<span style="font-weight:normal;float:right;font-size:80%;" >
[<a href="query.php?action=save&queryid={queryid}">{t}Save options{/t}</a>]&nbsp;
[<a href="search.php?queryid={queryid}&showresult=0">{t}Edit options{/t}</a>]
</span>
</p>
<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr>
<td style="white-space:nowrap">
<p class="content-title-noshade-size15" style="padding:0; margin:4px;">&nbsp;{t}{results_count} caches<span style="{search_headline_caches}"> matched</span>{/t}&nbsp;</p>
</td>
<td style="text-align:right; width:1px">
<a href="search.php?queryid={queryid}&output=map2bounds&showresult=1&skipqueryid=1&expert=0&utf8=1" class="nooutline"><img src="resource2/ocstyle/images/misc/32x32-world.png"/></a>
</td>
<td style="white-space:nowrap; text-align:left; padding-bottom:2px">
<p class="inheader"><a href="search.php?queryid={queryid}&output=map2bounds&showresult=1&skipqueryid=1&expert=0&utf8=1">{showonmap}</a></p>
</td>
<td style="text-align:right; padding-bottom:2px"><p class="inheader">
<span style="white-space:nowrap">[<a href="query.php?action=save&queryid={queryid}">{t}Save options{/t}</a>]</span>
&nbsp;<span style="white-space:nowrap">[<a href="search.php?queryid={queryid}&showresult=0">{t}Edit options{/t}</a>]</span></p>
</td>
</tr></table>
</div>
<div class="buffer" style="height:5px;"></div>

@@ -44,9 +51,9 @@
<td class="header-small" colspan="2">
<table width="98.5%">
<tr>
<td width="100%">{pages}</td>
<td>{t}Download{/t}:</td>
<td>
<td rowspan="1" style="vertical-align:top; width:300px">{pages}</td>
<td style="text-align:right;">{t}Download{/t}:&nbsp;</td>
<td><nobr>
<select name="wpdownload-page" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value">
<option value="#">{t}Results on this page{/t}</option>
<option value="search.php?queryid={queryid}&output=gpx&startat={startat}">GPX</option>
@@ -56,8 +63,6 @@
<option value="search.php?queryid={queryid}&output=ovl&startat={startat}">OVL</option>
<option value="search.php?queryid={queryid}&output=txt&startat={startat}">TXT</option>
</select>
</td>
<td style="width:120px">
<select name="wpdownload-all" class="wpdownload" onChange="location.href=this.options[this.selectedIndex].value">
<option value="#">{t}Result {startatp1} to {endat} (as zip){/t}</option>
<option value="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1">GPX</option>
@@ -66,7 +71,7 @@
<option value="search.php?queryid={queryid}&output=ov2&startat={startat}&count=max&zip=1">OV2</option>
<option value="search.php?queryid={queryid}&output=ovl&startat={startat}&count=max&zip=1">OVL</option>
<option value="search.php?queryid={queryid}&output=txt&startat={startat}&count=max&zip=1">TXT</option>
</select>
</select></nobr>
</td>
</tr>
</table>
@@ -94,12 +99,12 @@
<tr>
<td colspan="2" class="header-small">{pages}</td>
</tr>
<tr><td class="spacer" colspan="2">&nbsp;</td></tr>
<tr><td style="height:0.6em"></td></tr>
</table>
<table class="content" width="100%">
<table width="100%">
<tr>
<td><b>{t}Download{/t}:</b></td>
<td align="right" style="padding-right:20px;">
<td style="text-align:right; width:50%">{t}Download{/t}:&nbsp;&nbsp;</td>
<td align="right" style="padding-right:20px; white-space:nowrap">
<b>{t}Results on this page:{/t}</b>
<a href="search.php?queryid={queryid}&output=gpx&startat={startat}" title="{t}GPS Exchange Format .gpx{/t}">GPX</a>
<a href="search.php?queryid={queryid}&output=loc&startat={startat}" title="{t}Waypointfile .loc{/t}">LOC</a>
@@ -108,12 +113,7 @@
<a href="search.php?queryid={queryid}&output=ov2&startat={startat}" title="{t}TomTom POI .ov2{/t}">OV2</a>
<a href="search.php?queryid={queryid}&output=ovl&startat={startat}" title="{t}TOP50-Overlay .ovl{/t}">OVL</a>
<a href="search.php?queryid={queryid}&output=txt&startat={startat}" title="{t}Textfile .txt{/t}">TXT</a>
</td>
</tr>
<tr>
<td class="help">
</td>
<td align="right" style="padding-right:20px;">
<br />
<b>{t}Result {startatp1} to {endat} (as zip):{/t}</b>
<a href="search.php?queryid={queryid}&output=gpx&startat={startat}&count=max&zip=1" title="{t}GPS Exchange Format .gpx{/t}">GPX</a>
<a href="search.php?queryid={queryid}&output=loc&startat={startat}&count=max&zip=1" title="{t}Waypointfile .loc{/t}">LOC</a>
@@ -325,12 +325,13 @@
//$caches_per_page
//count($caches) - 1
tpl_set_var('pages', $pages);
tpl_set_var('showonmap', $showonmap);
// downloads
tpl_set_var('queryid', $options['queryid']);
tpl_set_var('startat', $startat);
tpl_set_var('startatp1', $startat + 1);
tpl_set_var('startatp1', min($resultcount,$startat + 1));
if (($resultcount - $startat) < 500)
tpl_set_var('endat', $startat + $resultcount - $startat);
@@ -10,8 +10,9 @@
***************************************************************************/
global $dblink, $dbslaveid;
$sqlchecksum = sprintf('%u', crc32($sqlFilter));
$sqlchecksum = sprintf('%u', crc32($cachesFilter."\n".$sqlFilter));
/* config */
$opt['map']['maxcacheage'] = 3600;
@@ -30,13 +31,42 @@
sql_slave("CREATE TEMPORARY TABLE `tmpmapresult` (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY");
sql_slave("INSERT INTO `tmpmapresult` (`cache_id`) " . $sqlFilter);
sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $dbslaveid, $sqlchecksum, $sqlFilter);
sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $dbslaveid, $sqlchecksum, $cachesFilter."\n".$sqlFilter);
$resultId = mysql_insert_id($dblink);
sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM `tmpmapresult`", $resultId);
sql_slave("DROP TEMPORARY TABLE `tmpmapresult`");
}
echo $resultId;
if ($map2_bounds)
{
$rs = sql_slave("SELECT MIN(`latitude`) AS `lat_min`,
MAX(`latitude`) AS `lat_max`,
MIN(`longitude`) AS `lon_min`,
MAX(`longitude`) AS `lon_max`
FROM `map2_data`, `caches`
WHERE `result_id`='&1'
AND `caches`.`cache_id`=`map2_data`.`cache_id`",
$resultId);
if (($rBounds = sql_fetch_assoc($rs)) && $rBounds['lat_min'] !== null /* >0 caches */)
{
if ($rBounds['lat_min'] == $rBounds['lat_max'] &&
$rBounds['lon_min'] == $rBounds['lon_max']) // 1 Cache
{
$halfwin = 0.02;
$rBounds['lat_min'] -= $halfwin;
$rBounds['lat_max'] += $halfwin;
$rBounds['lon_min'] -= $halfwin;
$rBounds['lon_max'] += $halfwin;
}
$bounds_param = "&lat_min=" . round($rBounds['lat_min'],5) . "&lat_max=" . round($rBounds['lat_max'],5) . '&lon_min=' . round($rBounds['lon_min'],5) . '&lon_max=' . round($rBounds['lon_max'],5);
}
sql_free_result($rs);
tpl_redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
}
else
echo $resultId;
exit;
?>
@@ -52,9 +52,10 @@
$nLat2 = isset($_REQUEST['lat2']) ? $_REQUEST['lat2']+0 : 0;
$cachenames = isset($_REQUEST['cachenames']) ? $_REQUEST['cachenames']+0 : 0;
$smallmap = isset($_REQUEST['smallmap']) ? $_REQUEST['smallmap']+0 : 0;
$showlockedcaches = isset($_REQUEST['locked']) ? $_REQUEST['locked']<>0 : true;
output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2,
$cachenames, $smallmap);
$cachenames, $smallmap, $showlockedcaches);
}
else if ($sMode == 'fullscreen' ||
($sMode == '' &&
@@ -70,6 +71,21 @@
$fullscreen = false;
}
// set queryid data for displaying search results on map
$nQueryId = isset($_REQUEST['queryid']) ? $_REQUEST['queryid']+0 : 0;
$nResultId = isset($_REQUEST['resultid']) ? $_REQUEST['resultid']+0 : 0;
$tpl->assign('queryid',$nQueryId);
if (!isset($_REQUEST['lat_min']))
$tpl->assign('lat_min',null);
else
{
$tpl->assign('lat_min',$_REQUEST['lat_min']);
$tpl->assign('lat_max',$_REQUEST['lat_max']);
$tpl->assign('lon_min',$_REQUEST['lon_min']);
$tpl->assign('lon_max',$_REQUEST['lon_max']);
}
// save options
if (isset($_REQUEST['submit']) && $_REQUEST['submit'] && $login->userid > 0)
{
@@ -386,7 +402,7 @@ function output_namesearch($sName, $nLat, $nLon, $nResultId)
}
function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2,
$cachenames, $smallmap)
$cachenames, $smallmap, $showlockedcaches)
{
global $login, $opt, $useragent_msie;
@@ -433,7 +449,8 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
{
$namequery = ($cachenames ? ", `caches`.`name` AS `cachename`" : "");
$rs = sql_slave("SELECT SQL_BUFFER_RESULT
`caches`.`wp_oc`, `caches`.`longitude`, `caches`.`latitude`,
distinct `caches`.`wp_oc`,
`caches`.`longitude`, `caches`.`latitude`,
`caches`.`type`,
`caches`.`status`>1 AS `inactive`,
`caches`.`type`=6 AND `caches`.`date_hidden`+INTERVAL 1 DAY < NOW() AS `oldevent`,
@@ -444,19 +461,21 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
$namequery . "
FROM `map2_data`
INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id`
LEFT JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`
LEFT JOIN `cache_logs` `found_logs` ON `found_logs`.`cache_id`=`caches`.`cache_id` AND `found_logs`.`user_id`='&6' AND `found_logs`.`type` IN (1,7)
LEFT JOIN `cache_logs` `notfound_logs` ON `notfound_logs`.`cache_id`=`caches`.`cache_id` AND `notfound_logs`.`user_id`='&6' AND `notfound_logs`.`type`=2
LEFT JOIN `caches_attributes` ON `caches_attributes`.`cache_id`=`caches`.`cache_id` AND `caches_attributes`.`attrib_id`=6
WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5'
AND `caches`.`status`<>6 /* hide vandalized listings, locked duplicates etc. */
AND `caches`.`status`<>7 /* ... and locked/invisible caches */
AND `caches`.`status`<>'&7' /* hide vandalized listings, locked duplicates etc. */
AND `caches`.`status`<>7 /* ... and locked/invisible caches */
ORDER BY `caches`.`status` DESC, `oconly` AND NOT (`found` OR `notfound`), NOT (`found` OR `notfound`), `caches`.`type`<>4, MD5(`caches`.`name`)
LIMIT &7",
LIMIT &8",
// sort in reverse order, because last are on top of map;
// fixed order avoids oscillations when panning;
// MD5 pseudo-randomness gives equal changes for all kinds of caches to be on top
$nResultId, $nLon1, $nLon2, $nLat1, $nLat2, $login->userid, $maxrecords);
$nResultId, $nLon1, $nLon2, $nLat1, $nLat2, $login->userid,
$showlockedcaches ? 0 : 6,
$maxrecords);
while ($r = sql_fetch_assoc($rs))
{
@@ -466,7 +485,6 @@ function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat
if ($r['notfound']) $flags |= 4;
if ($r['inactive'] || $r['oldevent']) $flags |= 8;
if ($r['oconly']) $flags |= 16;
if ($compact)
echo '<c d="' .
xmlentities(
@@ -302,6 +302,7 @@ p.embed-caption {float: left; margin: 5px 0px 0px 0px; padding: 0px; font-style:
div.cachedesc {font-size: 120%;}
div.cachedesc p {font-size: 100%;}
div.welcome p {line-height: 1.6em;}
p.inheader {margin:4px; font-size:125%;}

/* Quote */
p.quote {clear: left; margin: 0em 30px 0.6em 30px; line-height: 120%; font-size: 110%;}
@@ -445,10 +445,13 @@
if (!isset($options['showresult'])) $options['showresult']='0';
if ($options['showresult'] == 1)
{
//===============================================================
// X6. build SQL statement from search options
//===============================================================
$cachesFilter = '';
if(!isset($options['output'])) $options['output']='';
if ((mb_strpos($options['output'], '.') !== false) ||
(mb_strpos($options['output'], '/') !== false) ||
@@ -551,7 +554,8 @@
$lon_rad = $lon * 3.14159 / 180;
$lat_rad = $lat * 3.14159 / 180;
sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
$cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id`
@@ -560,7 +564,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0));
HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');
$sql_select[] = '`result_caches`.`cache_id`';
@@ -691,7 +696,8 @@
//TODO: check!!!
$max_lon_diff = $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180 )) * 6378 * $multiplier[$distance_unit] * 3.14159);
sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
$cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id`
@@ -700,7 +706,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0));
HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');
$sql_select[] = '`result_caches`.`cache_id`';
@@ -805,7 +812,8 @@
$lon_rad = $lon * 3.14159 / 180;
$lat_rad = $lat * 3.14159 / 180;
sql_slave('CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
$cachesFilter =
'CREATE TEMPORARY TABLE result_caches ENGINE=MEMORY
SELECT
(' . getSqlDistanceFormula($lon, $lat, $distance, $multiplier[$distance_unit]) . ') `distance`,
`caches`.`cache_id` `cache_id`
@@ -814,7 +822,8 @@
AND `longitude` < ' . ($lon + $max_lon_diff) . '
AND `latitude` > ' . ($lat - $max_lat_diff) . '
AND `latitude` < ' . ($lat + $max_lat_diff) . '
HAVING `distance` < ' . ($distance+0));
HAVING `distance` < ' . ($distance+0);
sql_slave($cachesFilter);
sql_slave('ALTER TABLE result_caches ADD PRIMARY KEY ( `cache_id` )');
$sql_select[] = '`result_caches`.`cache_id`';
@@ -1054,11 +1063,22 @@
// $options['sortby']
// $options['orderRatingFirst']
// $options['queryid']
// $sqlFilter
// $cachesFilter, $sqlFilter
// $map2_bounds
//=================================================================
$map2_bounds = ($options['output'] == 'map2bounds');
if ($map2_bounds)
$options['output'] = 'map2';
// Ocprop: HTML, gpx
if (!file_exists($opt['rootpath'] . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php'))
if ($map2_bounds && $options['queryid'] == 0)
{
tpl_set_var('tplname', $tplname);
$tplname = 'error';
tpl_set_var('error_msg', 'map2bounds requires queryid');
}
elseif (!file_exists($opt['rootpath'] . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php'))
{
tpl_set_var('tplname', $tplname);
$tplname = 'error';
Oops, something went wrong.

0 comments on commit eb4a4ae

Please sign in to comment.
You can’t perform that action at this time.