require_once $opt['rootpath'] . 'lib2/cli.inc.php'; require_once $opt['rootpath'] . 'lib2/search/search.inc.php'; $rsLocations = sql("SELECT `uni`, `lat`, `lon`, `rc`, `cc1`, `adm1` FROM `gns_locations` WHERE `dsg` LIKE 'PPL%'"); while ($rLocations = sql_fetch_array($rsLocations)) { $minlat = geomath::getMinLat($rLocations['lon'], $rLocations['lat'], 10, 1); $maxlat = geomath::getMaxLat($rLocations['lon'], $rLocations['lat'], 10, 1); $minlon = geomath::getMinLon($rLocations['lon'], $rLocations['lat'], 10, 1); $maxlon = geomath::getMaxLon($rLocations['lon'], $rLocations['lat'], 10, 1); // den nächsgelegenen Ort in den geodb ermitteln $sql = "SELECT " . geomath::getSqlDistanceFormula($rLocations['lon'], $rLocations['lat'], 10, 1, 'lon', 'lat', 'geodb_coordinates') . " `distance`,\n `geodb_coordinates`.`loc_id` `loc_id`\n FROM `geodb_coordinates`\n WHERE\n `lon` > '" . sql_escape($minlon) . "' AND `lon` < '" . sql_escape($maxlon) . "' AND\n `lat` > '" . sql_escape($minlat) . "' AND `lat` < '" . sql_escape($maxlat) . "'\n HAVING `distance` < 10\n ORDER BY `distance` ASC\n LIMIT 1"; $rs = sql($sql); if (mysql_num_rows($rs) == 1) { $r = sql_fetch_array($rs); mysql_free_result($rs); $locid = $r['loc_id']; $admtxt1 = GeoDb::landFromLocid($locid); if ($admtxt1 == '0') { $admtxt1 = ''; } // bundesland ermitteln $rsAdm2 = sql("SELECT `full_name`, `short_form`\n FROM `gns_locations`\n WHERE `rc`='&1'\n AND `fc`='A'\n AND `dsg`='ADM1'\n AND `cc1`='&2'\n AND `adm1`='&3'\n AND `nt`='N'\n LIMIT 1", $rLocations['rc'], $rLocations['cc1'], $rLocations['adm1']); if (mysql_num_rows($rsAdm2) == 1) { $rAdm2 = sql_fetch_array($rsAdm2); $admtxt2 = $rAdm2['short_form']; if ($admtxt2 == '') { $admtxt2 = $rAdm2['full_name']; } } else { $admtxt3 = ''; } $admtxt3 = GeoDb::regierungsbezirkFromLocid($locid);
function outputLocidSelectionForm($locSql, $options) { global $tpl; global $locline, $bgcolor1, $bgcolor2; require_once __DIR__ . '/lib2/logic/geodb.class.php'; $urlparamString = prepareLocSelectionForm($options) . '&locid={locid}'; sql_temp_table_slave('locids'); sql_slave("CREATE TEMPORARY TABLE &locids ENGINE=MEMORY " . $locSql); sql_slave("ALTER TABLE &locids ADD PRIMARY KEY (`loc_id`)"); $rs = sql_slave("SELECT\n `geodb_textdata`.`loc_id` `loc_id`,\n `geodb_textdata`.`text_val` `text_val`\n FROM `geodb_textdata`, &locids\n WHERE\n &locids.`loc_id`=`geodb_textdata`.`loc_id`\n AND `geodb_textdata`.`text_type`=500100000\n ORDER BY `text_val`"); $nr = 1; $locations = ''; while ($r = sql_fetch_array($rs)) { $thislocation = $locline; // locationsdings zusammenbauen $locString = ''; $land = GeoDb::landFromLocid($r['loc_id']); if ($land != '') { $locString .= htmlspecialchars($land, ENT_COMPAT, 'UTF-8'); } $rb = GeoDb::regierungsbezirkFromLocid($r['loc_id']); if ($rb != '') { $locString .= ' > ' . htmlspecialchars($rb, ENT_COMPAT, 'UTF-8'); } $lk = GeoDb::landkreisFromLocid($r['loc_id']); if ($lk != '') { $locString .= ' > ' . htmlspecialchars($lk, ENT_COMPAT, 'UTF-8'); } $thislocation = mb_ereg_replace('{parentlocations}', $locString, $thislocation); // koordinaten ermitteln $r['loc_id'] = $r['loc_id'] + 0; $rsCoords = sql_slave("SELECT `lon`, `lat`\n FROM `geodb_coordinates`\n WHERE loc_id='&1'\n LIMIT 1", $r['loc_id']); if ($rCoords = sql_fetch_array($rsCoords)) { $coordString = help_latToDegreeStr($rCoords['lat']) . ' ' . help_lonToDegreeStr($rCoords['lon']); } else { $coordString = '[' . $no_location_coords . ']'; } $thislocation = mb_ereg_replace('{coords}', htmlspecialchars($coordString, ENT_COMPAT, 'UTF-8'), $thislocation); $thislocation = mb_ereg_replace('{locationname}', htmlspecialchars($r['text_val'], ENT_COMPAT, 'UTF-8'), $thislocation); $thislocation = mb_ereg_replace('{urlparams}', $urlparamString, $thislocation); $thislocation = mb_ereg_replace('{locid}', urlencode($r['loc_id']), $thislocation); $thislocation = mb_ereg_replace('{nr}', $nr, $thislocation); $thislocation = mb_ereg_replace('{secondlocationname}', '', $thislocation); if ($nr % 2) { $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor1, $thislocation); } else { $thislocation = mb_ereg_replace('{bgcolor}', $bgcolor2, $thislocation); } $nr++; $locations .= $thislocation . "\n"; } $tpl->assign('locations', $locations); $tpl->assign('resultscount', sql_num_rows($rs)); $tpl->assign('pages', ''); sql_free_result($rs); sql_drop_temp_table_slave('locids'); $tpl->display(); exit; }