logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Anhang: Meine location.php: msg#00017

Subject: Anhang: Meine location.php
Der Inhalt meiner location.php:
 
 
<?PHP
//
// This example cannot be run by itself, it requires additional
// files not included. It is just meant to give you some hints
// on the use of the GeoClass with the OpengeoDB data.
//
// Ask Stefan Motz or Arne Klempert as the maintainers of the
// GeoClass at
https://sourceforge.net/projects/geoclassphp/
// for more information.
//
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<title>OpenGeoDb - freie Geokoordinaten-Datenbank nach Orten und PLZs</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="robots" content="index,follow">
<link rel=stylesheet type="text/css" href="">
<body>
 
<?php
if ($_GET["id"]) {
 // Zurück zur Suche
 echo '<div style="float:right" class="small">';
 echo '<a href="">zurück zur Suche</a>';
 echo '</div>';
}
?>
 
<h1>OpenGeoDB - freie Geokoordinaten-Datenbank</h1>
<hr>
 
<!-- BEGIN -->
<?php
 
/*
 ###########################################################
 #
 # Beispiel für die Verwendung der GeoClass (0.3.1 alpha)
 # mit den Daten der OpenGeoDB (>= 0.2)
 #
 # Daten:
http://opengeodb.de/download/
 # GeoClass: http://opengeodb.de/software/
 #
 # Erfordert PEAR::DB
 #
 ###########################################################
 */
 
/**
 * Konfiguration
 */
 

if (!defined('DSN')) {
 // Hier müssen die Zugangsdaten für die Datenbank eingetragen werden:
 define(DSN,'mysql://root:@localhost/geodata');
}
if (!defined('PATH_DATA')) {
 // Enter the path to the E00 files (for the new creation of the map)
 // The file germany_staatline.e00 should be included here
 // Other E00 files for state borders can be found at
 //
http://www.maproom.psu.edu/dcw/
 
 // Hier muss der Pfad zu den E00-Dateien angegeben werden (zum
 // Neuzeichnen der Karte)
 // Die Datei germany_staatline.e00 sollte bei dieser Datei dabeisein
 // Weitere E00-Dateien für Staatsgrenzen gibt es bei
 //
http://www.maproom.psu.edu/dcw/
 define(PATH_DATA,'maps');
}
 
/**
 * GeoClass einbinden und instanzieren
 *
 * Das Verzeichnis Geo muss sich im
 * Include-Verzeichnis befinden.
 */
 
require_once('Geo/Geo.php');
 
$options = array(
 'table' => "geodb_coordinates",
 'fields' => array(
 'name' => 'name',
 'longitude' => 'lon',
 'latitude' => 'lat',
 ),
 'encoding' => GEO_ENCODING_UTF_8,
);
 
$geodb = Geo::setupSource("DB_OpenGeoDB",DSN,$options);
 

// Suchformular
echo '<h2>Ortsdatenbank</h2>';
 
echo '<form action="" method="GET">';
echo '<input style="width:200px;" type="text" name="q" value="'.htmlentities(utf8_decode($_GET["q"])).'">';
echo '<input type="submit" name="" value="Suche starten">';
echo '</form>';
 
echo '<hr>';
 

/**
 * Verarbeitung der Benutzereingaben
 */
 
if ($_GET["id"]) {
 
 // Ein Datensatz ausgewählt
 
 // Datensatz des gewählten Ortes auslesen
 $sql = 'SELECT name.loc_id, name.text_val as "name", iso.text_val as "iso", land.text_val as "land", level, lon, lat '.
 'FROM geodb_hierarchies hi, geodb_textdata name, geodb_textdata iso, geodb_textdata land, geodb_coordinates co '.
 'WHERE hi.loc_id = '.$_GET["id"].' and name.loc_id = hi.loc_id and name.text_type = 500100000 and name.is_default_name = 1 and '.
 'iso.loc_id = hi.id_lvl2 and iso.text_type = 500100001 and '.
 'land.loc_id = hi.id_lvl2 and land.text_type = 500100000 and land.is_default_name = 1 and '.
 'co.loc_id = hi.loc_id '.
 'ORDER BY hi.valid_until DESC';
 list($ort) = $geodb->performQuery($sql);
 echo '<h2>'.$ort->dbValues['name'].'</h2>';
 
 if (!file_exists('maps/'.(int)$_GET["id"].'.png') || $_GET["newMap"]) {
 
 // Der Parameter newMap erzwingt das Neuzeichnen der Karte
 if ($_GET["newMap"]) {
 //$map2 = Geo::setupMap(188,235);
 $map2 = Geo::setupMap(376,470);
 $map2->setRange(5.5, 15.5, 47.2, 55.1);
 $map2->color['borders'] = $map2->color(192, 192, 192);
 $map2->color['states'] = $map2->color(212, 212, 212);
 
 $map2->addDataFile(PATH_DATA."/germany_staatline.e00", 'states'); // Grenzen Bundesländer
 $map2->addDataFile(PATH_DATA."/ponet.e00", 'borders'); // Grenzen Staat
 $map2->saveImage('maps/D.png');
 } else {
 $map2 = Geo::setupMap("maps/D.png");
 $map2->setRange(5.5, 15.5, 47.2, 55.1);
 }
 
 $map2->addGeoObject($ort, 'red', 3);
 $map2->saveImage('maps/'.(int)$_GET["id"].'.png');
 }
 

 echo '<div style="float:left">';
 

 if ($_GET["style"] == "1") {
 echo '<img src=""id"].'.png" width="188" height="235" alt="Lage von '.$ort->dbValues['name'].' in Deutschland">';
 } else {
 echo '<img src=""id"].'.png" width="188" height="235" alt="Lage von '.$ort->dbValues['name'].' in Deutschland">';
 }
 echo '</div>';
 
 // Detailinfos zum gewählten Ort
 
 $lvl_name = array(3 => "Bundesland", "Regierungsbezirk", "Landkreis");
 
 // Verwaltungsgliederung
 echo '<table cellpadding=0 cellspacing=0 width="400">';
 echo '<tr><td colspan=2 style="border-bottom:1px solid #CCCCCC;"><b>Verwaltungsgliederung</b></td></tr>';
 echo '<tr><td valign="top" width="150">Staat&nbsp;</td><td valign="top">'.$ort->dbValues["land"].'</td></tr>';
 // Bundesland / Regierungsbezirk / Landkreis:
 for($n = 3; $n < 6; $n++) {
 $sql2 = 'SELECT text_val '.
 'FROM geodb_hierarchies hi, geodb_textdata td '.
 'WHERE hi.loc_id = '.$_GET["id"].' and td.loc_id = hi.id_lvl'.$n.' and text_type = 500100000 and is_default_name = 1 '.
 'ORDER BY hi.valid_until DESC';
 $tv = $geodb->performQuery($sql2);
 if (is_array($tv) && count($tv)>=1) {
 echo '<tr><td valign="top">'.$lvl_name[$n].'&nbsp;</td><td valign="top">'.$tv[0]->dbValues["text_val"].'</td></tr>';
 }
 }
 // Verwaltungsgemeinschaft:
 $sql2 = 'SELECT text_val '.
 'FROM geodb_textdata '.
 'WHERE loc_id = '.$_GET["id"].' and text_type = 500700000 and is_default_name = 1 '.
 'ORDER BY valid_until DESC';
 $tv = $geodb->performQuery($sql2);
 if (is_array($tv) && count($tv)>=1) {
 echo '<tr><td valign="top">Verwaltungsgemeinschaft&nbsp;</td><td valign="top">'.$tv[0]->dbValues["text_val"].'</td></tr>';
 }
 // Stadt/Gemeinde bei Ortsteilen:
 if ($ort->dbValues["level"]>6) {
 $sql2 = 'SELECT text_val '.
 'FROM geodb_hierarchies hi, geodb_textdata td '.
 'WHERE hi.loc_id = '.$_GET["id"].' and td.loc_id = hi.id_lvl6 and text_type = 500100000 and is_default_name = 1 '.
 'ORDER BY hi.valid_until DESC';
 $tv = $geodb->performQuery($sql2);
 if (is_array($tv) && count($tv)>=1) {
 echo '<tr><td valign="top">Stadt/Gemeinde&nbsp;</td><td valign="top">'.$tv[0]->dbValues["text_val"].'</td></tr>';
 }
 }
 echo '</table><br>';
 
 // Koordinaten
 echo '<table cellpadding=0 cellspacing=0 width="400">';
 echo '<tr><td colspan=2 style="border-bottom:1px solid #CCCCCC;"><b>Koordinaten</b></td></tr>';
 echo '<tr><td valign="top" width="150">Länge</td><td valign="top">'.$ort->dbValues["lon"].' &nbsp;/&nbsp; '.htmlentities ( $ort->longitudeDMS ).'</td></tr>';
 echo '<tr><td valign="top">Breite</td><td valign="top">'.$ort->dbValues["lat"].' &nbsp;/&nbsp; '.htmlentities ( $ort->latitudeDMS ).'</td></tr>';
 echo '</table><br>';
 
 // Zusatzinformationen
 echo '<table cellpadding=0 cellspacing=0 width="400">';
 echo '<tr><td colspan=2 style="border-bottom:1px solid #CCCCCC;"><b>Zusatzinformationen</b></td></tr>';
 $sql2 = 'SELECT text_val '.
 'FROM geodb_textdata '.
 'WHERE loc_id = '.$_GET["id"].' and text_type = 500600000 '.
 'ORDER BY valid_until DESC';
 $tv = $geodb->performQuery($sql2);
 if (is_array($tv) && count($tv)>=1) {
 echo '<tr><td valign="top">Gemeindekennzahl&nbsp;</td><td valign="top">'.$tv[0]->dbValues["text_val"].'</td></tr>';
 }
 $sql2 = 'SELECT text_val '.
 'FROM geodb_textdata '.
 'WHERE loc_id = '.$_GET["id"].' and text_type = 500500000 '.
 'ORDER BY valid_until DESC';
 $tv = $geodb->performQuery($sql2);
 if (is_array($tv) && count($tv)>=1) {
 echo '<tr><td valign="top">Kfz-Kennzeichen&nbsp;</td><td valign="top">'.$tv[0]->dbValues["text_val"].'</td></tr>';
 }
 $sql2 = 'SELECT text_val '.
 'FROM geodb_textdata '.
 'WHERE loc_id = '.$_GET["id"].' and text_type = 500300000 '.
 'ORDER BY valid_until DESC';
 $plz = $geodb->performQuery($sql2);
 if (is_array($plz) && count($plz)>=1) {
 $plzs = "";
 foreach ($plz as $val) {
 $plzs = $plzs.", ".$val->dbValues["text_val"];
 }
 if (count($plz) > 3) {
 echo '<tr><td valign="top" width="150">Postleitzahl(en)&nbsp;</td><td valign="top">'.$plz[0]->dbValues["text_val"].', '.$plz[1]->dbValues["text_val"].', '.$plz[2]->dbValues["text_val"].' <a href="" title="'.substr($plzs,2).'">...</a></td></tr>';
 } else {
 echo '<tr><td valign="top" width="150">Postleitzahl(en)&nbsp;</td><td valign="top">'.substr($plzs,2).'</td></tr>';
 }
 }
 echo '</table><br>';
 
 // Korrekturen
 //echo '<table cellpadding=0 cellspacing=0>';
 //echo '<tr><td colspan=2 style="border-bottom:1px solid #CCCCCC;"><b>Korrekturvorschlag f&uuml;r '.$ort->dbValues['name'].'</b></td></tr>';
 //echo '<form action=""http://www.nettz.de/Formular-Chef/Formular-Chef.cgi">http://www.nettz.de/Formular-Chef/Formular-Chef.cgi" method="post">';
 //echo '<tr><td colspan=2><i>Bitte KEINE(!) Google Earth Koordinaten eingeben: sie sind bei weitem zu ungenau!</i></td></tr>';
 //echo '<tr><td valign="top">Ihre Email-Anschrift&nbsp;<br>(optional)&nbsp;</td><td><input style="width:200px;" type="text" name="absender"></td></tr>';
 //echo '<tr><td valign="top">L&auml;ngengrad&nbsp;</td><td><input style="width:200px;" type="text" name="lon_new" value="'.htmlentities ( $ort->longitudeDMS ).'"></td></tr>';
 //echo '<tr><td valign="top">Breitengrad&nbsp;</td><td valign="top"><input style="width:200px;" type="text" name="lat_new" value="'.htmlentities ( $ort->latitudeDMS ).'"></td></tr>';
 //echo '<tr><td valign="top">Kommentar&nbsp;/<br>andere &Auml;nderungen&nbsp;</td><td valign="top"><textarea cols="40" rows="4" name="comm"></textarea></td></tr>';
 //echo '<input type="hidden" name="locID" value="'.$_GET["id"].'"><br>';
 //echo '<input type="hidden" name="location" value="'.$ort->dbValues["iso"].'-'.$ort->dbValues["name"].'"><br>';
 //echo '<input type="hidden" name="empfaenger" value="
mack-WMLsJPcVvUbeKaaq6wa0og@xxxxxxxxxxxxxxxx"><br>';
 //echo '<input type="hidden" name="betreff" value="OpenGeoDB Update Wunsch"><br>';
 //echo '<input type="hidden" name="lat_old" value="'.$ort->latitudeDMS.'"><br>';
 //echo '<input type="hidden" name="lon_old" value="'.$ort->longitudeDMS.'"><br>';
 //echo '<tr><td valign="top"><input type="submit" name="correct" value="Abschicken">&nbsp;</td><td valign="top"></td></tr>';
 //echo '</form>';
 //echo '</table><br>';
 //echo '<i>Unterst&uuml;tzt von <a href=""http://www.nettz.de/">http://www.nettz.de/
'" href="">http://www.nettz.de/">http://www.nettz.de/</i></a><br>';
 //echo '<hr><br>';
 
 // Externe Informationsquellen
 echo '<p style="clear:all;border-bottom:1px solid #CCCCCC;"><b>Externe Informationsquellen</b></p>';
 echo '<ul>';
 echo '<li><b><a href=""http://de.wikipedia.org/w/wiki.phtml?search='.urlencode($ort->dbValues['name']).'&go=Los" href="">http://de.wikipedia.org/w/wiki.phtml?search='.urlencode($ort->dbValues['name']).'&go=Los" target="_blank">'.$ort->dbValues['name'].'</a></b> suchen in <i><a href=""http://de.wikipedia.org/">http://de.wikipedia.org" target="_blank">Wikipedia - Die freie Enzyklopädie</a></i></li>';
 echo '<li><b><a href=""http://www.google.de/search?hl=de&='.urlencode('"'.$ort->dbValues['name'].'"').'&meta=lr=lang_de" href="">http://www.google.de/search?hl=de&='.urlencode('"'.$ort->dbValues['name'].'"').'&meta=lr%3Dlang_de" target="_blank">'.$ort->dbValues['name'].'</a></b> suchen in <i><a href=""http://google.de/">http://google.de" target="_blank">Google</a></i></li>';
 // echo '<li><b><a href=""http://www.bund.de/Staedte-Kreise-Gemeinden-.6476.htm?neuesuche=true&neueseitenzahl=0&startsuche=true&blocknumber=1&neueseitenzahl=0&gemeinde='.urlencode($ort->dbValues['name']).'" href="">http://www.bund.de/Staedte-Kreise-Gemeinden-.6476.htm?neuesuche=true&neueseitenzahl=0&startsuche=true&blocknumber=1&neueseitenzahl=0&gemeinde='.urlencode($ort->dbValues['name']).'" target="_blank">'.$ort->dbValues['name'].'</a></b> suchen in <i><a href=""http://www.bund.de/Staedte-Kreise-Gemeinden-.6476.htm">http://www.bund.de/Staedte-Kreise-Gemeinden-.6476.htm" target="_blank">Verzeichnis Städte, Kreise & Gemeinden (bund.de)</a></i></li>';
 echo '</ul>';
 
 // Orte in der Umgebung finden
 $treffer = $geodb->findCloseByGeoObjects($ort, 10, false);
 $home = $ort;
 if (is_array($treffer) && count($treffer)>1) {
 echo '<div style="border-bottom:1px solid #CCCCCC;"><b>Orte im Umkreis von 10 km</b></div><br>';
 echo '<ol>';
 foreach ($treffer AS $ort) {
 if ($ort->dbValues["loc_type"] == GEO_OGDB_POPULATED_AREA && $home->dbValues["loc_id"] != $ort->dbValues["id"]) {
 echo '<li>';
 if ($ort->dbValues['typ']>6) {
 echo '<a href="">'.$ort->dbValues['name'].'</a>';
 } else {
 echo '<b><a href="">'.$ort->dbValues['name'].'</a></b>';
 }
 echo '<br>';
 
 echo '<small>';
 // Land / Bundesland / Regierungsbezirk / Landkreis:
 for($n = 2; $n < 6; $n++) {
 if ($n == 4) { // Skip Regierungsbezirk
 continue;
 }
 $sql3 = 'SELECT text_val '.
 'FROM geodb_hierarchies hi, geodb_textdata td '.
 'WHERE hi.loc_id = '.$ort->dbValues["id"].' and td.loc_id = hi.id_lvl'.$n.' and text_type = 500100000 and is_default_name = 1 '.
 'ORDER BY hi.valid_until DESC';
 $tx = $geodb->performQuery($sql3);
 if (is_array($tx) && count($tx)>=1) {
 echo ($n != 2?' &gt; ':'').$tx[0]->dbValues["text_val"];
 }
 }
 // Verwaltungsgemeinschaft:
 $sql3 = 'SELECT text_val '.
 'FROM geodb_textdata '.
 'WHERE loc_id = '.$ort->dbValues["id"].' and text_type = 500700000 and is_default_name = 1 '.
 'ORDER BY valid_until DESC';
 $tx = $geodb->performQuery($sql3);
 if (is_array($tv) && count($tx)>=1) {
 echo ' &gt; '.$tx[0]->dbValues["text_val"];
 }
 // Stadt/Gemeinde bei Ortsteilen:
 if ($ort->dbValues["typ"]>6) {
 $sql3 = 'SELECT text_val '.
 'FROM geodb_hierarchies hi, geodb_textdata td '.
 'WHERE hi.loc_id = '.$ort->dbValues["id"].' and td.loc_id = hi.id_lvl6 and text_type = 500100000 and is_default_name = 1 '.
 'ORDER BY hi.valid_until DESC';
 $tx = $geodb->performQuery($sql3);
 if (is_array($tv) && count($tx)>=1) {
 echo ' &gt; '.$tx[0]->dbValues["text_val"];
 }
 }
 echo '<br>Entfernung: '.$home->getDistanceString($ort).'';
 echo '</small>';
 echo '</li>';
 }
 }
 echo '</ol>';
 }
 
} else {
 
 if ($_GET["q"]) {
 
 // Suchbegriff
 
 // Suche durchführen
 if (preg_match('/^[0-9]{1,5}$/',$_GET["q"])) {
 $sql = 'SELECT hi.loc_id as "loc_id", level, name.text_val as "name", land.text_val as "land" '.
 'FROM geodb_hierarchies hi, geodb_textdata name, geodb_textdata land '.
 'WHERE name.loc_id = hi.loc_id and name.text_type = 500300000 and name.is_default_name = 1 and name.text_val LIKE "%'.$_GET["q"].'%" and '.
 'land.loc_id = hi.id_lvl2 and land.text_type = 500100000 and land.is_default_name = 1 and '.
 'land.loc_id = hi.id_lvl2 and land.text_type = 500100000 and land.is_default_name = 1 and '.
 'level >= 6 and '.
 'hi.date_type_until = 300500000 and '.
 'name.date_type_until = 300500000 and '.
 'land.date_type_until = 300500000 '.
 'ORDER BY land, name';
 } else {
 $sql = 'SELECT hi.loc_id as "loc_id", level, name.text_val as "name", land.text_val as "land" '.
 'FROM geodb_hierarchies hi, geodb_textdata name, geodb_textdata land '.
 'WHERE name.loc_id = hi.loc_id and name.text_type = 500100000 and name.is_default_name = 1 and name.text_val LIKE "%'.utf8_decode($_GET["q"]).'%" and '.
 'land.loc_id = hi.id_lvl2 and land.text_type = 500100000 and land.is_default_name = 1 and '.
 'level >= 6 and '.
 'hi.date_type_until = 300500000 and '.
 'name.date_type_until = 300500000 and '.
 'land.date_type_until = 300500000 '.
 'ORDER BY land, name';
 }
 $treffer = $geodb->performQuery($sql);
 
 // Anzahl Treffer
 echo 'Ihre Suche nach "'.$_GET["q"].'" ergab '.count($treffer).' Treffer:<br>';
 
 // Trefferliste (wenn vorhanden)
 if (is_array($treffer) && count($treffer)>=1) {
 echo '<ol>';
 foreach ($treffer AS $ort) {
 echo '<li>';
 if ($ort->dbValues['level']>6) {
 echo '<a href="">'.$ort->dbValues['name'].'</a><br>';
 } else {
 echo '<b><a href="">'.$ort->dbValues['name'].'</a></b><br>';
 }
 echo '<small>';
 echo $ort->dbValues["land"];
 for($n = 3; $n < 6; $n++) {
 if ($n == 4) { // Skip Regierungsbezirk
 continue;
 }
 $sql2 = 'SELECT text_val '.
 'FROM geodb_hierarchies hi, geodb_textdata td '.
 'WHERE hi.loc_id = '.$ort->dbValues['loc_id'].' and td.loc_id = hi.id_lvl'.$n.' and text_type = 500100000 and is_default_name = 1 '.
 'ORDER BY hi.valid_until';
 $tv = $geodb->performQuery($sql2);
 $val = '-';
 if (is_array($tv) && count($tv)>=1) {
 $val = $tv[0]->dbValues["text_val"];
 }
 if ($n != 5 || $val != '-') {
 echo ' &gt; '.$val;
 }
 }
 
//foreach($ort->dbValues as $key => $val) {
// echo $key.": ".$val."<br>\n";
//}
 if ($ort->dbValues["level"]>6) {
 echo ' &gt; '.$ort->dbValues["name"];
 }
 echo '</small>';
 echo '</li>';
 }
 echo '</ol>';
 }
 } else {
 // Kein Suchbegriff
 echo "Bitte geben Sie als Suchbegriff einen<br>Namensbestandteil oder eine Postleitzahl ein.";
 }
}
?>
<!-- END -->
 
<?php
//TM, 6.4.2005//$site->endContent();
?>
******************************************************************************************************************
 
-- 
Mailingliste OpenGeoDB
Listenadresse: opengeodb-r1mDYR0DdAyzQB+pC5nmwQ@xxxxxxxxxxxxxxxx
Informationen: http://opengeodb.de
Mit freundlicher Unterstütztung von php::bar (http://phpbar.de)
<Prev in Thread] Current Thread [Next in Thread>