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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
<?php
//Attention a n'afficher AUCUN texte !!!!
//On doit renvoyer une image
header("Content-type: image/png");
//...
//Nombre d'image météo
$IMG_METEO_NUMBER = 4;
//Nom carte vierge
$IMG_CLEAN_NAME = "france";
$IMG_EXT = ".png";
$IMG_WEATHER_ITEM_NAME = "weather";
//Prévision
$TODAY = 1;
$TOMORROW = 2;
$METEO_DAY[$TODAY] = 'WEATHERID';
$METEO_DAY[$TOMORROW] = 'TOMORROWWEATHERID';
$TIME_LIMIT = 3600;
//...
//Si le jour est inconnu on renvoit la carte vierge
if(!isset($METEO_DAY[$mode])){
imagepng(imagecreatefrompng($IMG_CLEAN_NAME.$IMG_EXT));
exit(0);
}
//...
//Chargement de la carte de france
$fond = imagecreatefrompng($IMG_CLEAN_NAME.$IMG_EXT);
//Chargement des images météo
for($i = 0; $i < $IMG_METEO_NUMBER; $i++)
$infometeo[$i] = imagecreatefrompng($IMG_WEATHER_ITEM_NAME.$i.$IMG_EXT);
//Ouvrir le fichier descripteur
$region_def = fopen($RSS_FRENCH_REGION,"r");
//...
//Complétion de l'image
while(!feof($region_def)){
@set_time_limit(20);
//Récupération des données cartographique
list($region_name,$id,$offset_x,$offset_y) = split("/",fgets($region_def));
//...
//Récupération des données
$meteo = ...;
//Ajout du point météo sur la carte
$width = imagesx($infometeo[$meteo]);
$height = imagesy($infometeo[$meteo]);
imagecopymerge( $fond, $infometeo[$meteo], $offset_x-$width/2, $offset_y-$height/2, 0, 0, $width, $height, 75);
}
//Fermeture du fichier descripteur
fclose($region_def);
//On enregistre la mise a jour
imagepng($fond,$IMG_CLEAN_NAME.$mode.$IMG_EXT);
//...
//On affiche l'image
imagepng($fond);
//Libération de l'espace mémoire des images
imagedestroy($fond);
for($i = 0; $i < $IMG_METEO_NUMBER; $i++)
imagedestroy($infometeo[$i]);
?> |
Partager