Hallo,
wie der Betreff schon sagt möchte ich mittels openGeoDB die Entfernung zweier Städte ermitteln.
KLappt auch wunderbar!!!
Allerdings gibt er mir immer 2 Fehlermeldungen aus und ich weiß nicht woran es liegen kann. da es ja eigentlich funktioniert!?
Php Ausgabe
PHP-Code:
require_once("../control/ogdbDistance.lib.php");
echo "Entfernung: ".ogdbDistance(44369,89079);
Der Code für das holen und berechnen der Daten
PHP-Code:
<?
define("OGDB_REMOTE_DATA_FILE","http://fa-technik.adfc.de/code/opengeodb/PLZ.tab");
define("OGDB_LOCAL_DATA_FILE","./PLZ.tab");
function ogdbDistance($origin,$destination) {
if ( !is_file(OGDB_LOCAL_DATA_FILE) || filesize(OGDB_LOCAL_DATA_FILE)==0 ) {
$fileData = file_get_contents(OGDB_REMOTE_DATA_FILE);
if ( $fileData == FALSE ) {
die("ABBRUCH: konnte Daten nicht laden (".OGDB_REMOTE_DATA_FILE.")\n");
}
if ( file_put_contents(OGDB_LOCAL_DATA_FILE,$fileData) == FALSE ) {
die("ABBRUCH: konnte Daten nicht speichern (".OGDB_LOCAL_DATA_FILE.")\n");
}
unset($fileData);
}
$fileData = @file_get_contents(OGDB_LOCAL_DATA_FILE);
if ( $fileData == FALSE ) {
die("ABBRUCH: konnte Daten nicht laden (".OGDB_LOCAL_DATA_FILE.")\n");
}
$fileData = explode("\n",$fileData);
for ( $i=0; $i < count($fileData); $i++ ) {
$fileRow = explode("\t",$fileData[$i]);
if ( $origin == $fileRow[0] ) {
$origin_lon = deg2rad($fileRow[2]);
$origin_lat = deg2rad($fileRow[3]);
}
if ( $destination == $fileRow[0] ) {
$destination_lon = deg2rad($fileRow[2]);
$destination_lat = deg2rad($fileRow[3]);
}
}
return acos(sin($destination_lat)*sin($origin_lat)+cos($destination_lat)*cos($origin_lat)*cos($destination_lon - $origin_lon))*6375;
}
?>
Die Ausgabe ist wie gesagt richitg aber wie bekomme ich die Fehlermeldungen weg!?
Ausgabe:
Notice: Undefined offset: 1 in /var/www/www/kunden/10507/dein-geschenk-tisch.de/html/chat/control/ogdbDistance.lib.php on line 24
Notice: Undefined offset: 1 in /var/www/www/kunden/10507/dein-geschenk-tisch.de/html/chat/control/ogdbDistance.lib.php on line 28
Entfernung: 397.9428652251