1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| <?
/*
Exportation d'une table bdd en format OV2 (Tomtom)
(c) Damien Griessinger (HpAlpha)
*/
function packerligne($longitude,$latitude,$description)
{
return chr(0x02).pack("V",strlen($description)+14).pack("V",round($longitude*100000)).pack("V",round($latitude*100000)).$description.chr(0x00);
}
function db2ov2($nomfichier)
{
$fichier=fopen($nomfichier, 'wb+');
$db = pg_connect("host=$dbserveur dbname=$dbdatabase user=$dbuser password=$dbpass")
or die('Error Connexion : ' . pg_last_error());
$resultat=pg_query("SELECT longitude,latitude,description FROM t_poi");
while($out=pg_fetch_array($resultat)){
fwrite($fichier,packerligne($out['longitude'],$out['latitude'],$out['description']));
}
fclose ($fichier);
pg_free_result($resultat);
pg_close($db);
}
db2ov2('out.ov2');
?> |