cvs: pear /Services_Weather buildMetarDB.php

From: Date: Mon, 06 Oct 2003 14:57:47 +0000
Subject: cvs: pear /Services_Weather buildMetarDB.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13424@lists.php.net to get a copy of this message
eru Mon Oct 6 10:57:47 2003 EDT Modified files: /pear/Services_Weather buildMetarDB.php Log: *Added elevation to location-data Index: pear/Services_Weather/buildMetarDB.php diff -u pear/Services_Weather/buildMetarDB.php:1.6 pear/Services_Weather/buildMetarDB.php:1.7 --- pear/Services_Weather/buildMetarDB.php:1.6 Mon Oct 6 07:07:23 2003 +++ pear/Services_Weather/buildMetarDB.php Mon Oct 6 10:57:47 2003 @@ -17,7 +17,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: buildMetarDB.php,v 1.6 2003/10/06 11:07:23 eru Exp $ +// $Id: buildMetarDB.php,v 1.7 2003/10/06 14:57:47 eru Exp $ require_once "DB.php"; @@ -315,7 +315,7 @@ if (DB::isError($result)) { // Create new table - $create = "CREATE TABLE ".$tableName."(id int(5),block int(2),station int(3),icao varchar(4),name varchar(50),state varchar(2),country varchar(50),wmo int(1),latitude float,longitude float,x float,y float,z float)"; + $create = "CREATE TABLE ".$tableName."(id int(5),block int(2),station int(3),icao varchar(4),name varchar(50),state varchar(2),country varchar(50),wmo int(1),latitude float,longitude float,elevation float,x float,y float,z float)"; if ($verbose > 0) { echo "Services_Weather: Creating table '".$tableName."'.\n"; } @@ -361,6 +361,7 @@ } } } + // Calculate the cartesian coordinates for latitude and longitude $theta = deg2rad($latitude); $phi = deg2rad($longitude); @@ -368,6 +369,10 @@ $x = SERVICES_WEATHER_RADIUS_EARTH * cos($phi) * cos($theta); $y = SERVICES_WEATHER_RADIUS_EARTH * sin($phi) * cos($theta); $z = SERVICES_WEATHER_RADIUS_EARTH * sin($theta); + + // Check for elevation in data + $elevation = is_numeric($data[11]) ? $data[11] : 0; + // escape data strings for ( $i = 0; $i <= 6; $i++ ) { $data[$i] = $db->quote($data[$i]); @@ -378,8 +383,8 @@ $insert .= $data[$dataOrder["b"]].",".$data[$dataOrder["s"]].","; $insert .= $data[$dataOrder["i"]].",".$data[3].",".$data[4].","; $insert .= $data[5].",".$data[6].",".round($latitude, 4).","; - $insert .= round($longitude, 4).",".round($x, 4).",".round($y, 4).","; - $insert .= round($z, 4).")"; + $insert .= round($longitude, 4).",".$elevation.",".round($x, 4).","; + $insert .= round($y, 4).",".round($z, 4).")"; $result = $db->query($insert); if (DB::isError($result)) {

« previous php.pear.cvs (#13424) next »