Created
May 4, 2017 01:11
-
-
Save josef81/5574ee67555c59936d01bcdc91f678df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ########## Updated Code to get current METAR conditions over SSL from official NOAA xml feed ########### | |
| //START OF MODIFIED CODE | |
| else{ | |
| // url updated to reflect official NOAA METAR data site: https://aviationweather.gov/metar. (see notice: http://www.nws.noaa.gov/om/notification/scn16-16wngccb.htm) | |
| $urlMETAR = "https://aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&hoursBeforeNow=3&mostRecent=true&stationString=".strtoupper($ICAO); | |
| // get raw METAR data in xml format. | |
| $metarXMLData = curlMain($urlMETAR,3); | |
| // parse METAR XML string using SimpleXML (which is included in PHP base install) | |
| $metarXMLDataString = simplexml_load_string($metarXMLData); | |
| $metarDataString = $metarXMLDataString->data->METAR[0]->raw_text; | |
| // writes METAR data to a text file for debugging/verification (line can be removed if desired). | |
| file_put_contents($baseURL."cache/metar.txt",$metarDataString); | |
| // Continue with existing code as written. | |
| preg_match("/^.*?".strtoupper($ICAO)."(.*?)$/",$metarDataString,$matchedHeaderMetar); | |
| if(isset($matchedHeaderMetar[1])){ | |
| $metarDataString = $matchedHeaderMetar[1]; | |
| $condition = getWeatherGrafic($metarDataString,$ICAO); // options: clear, few, partly, mostly, overcast, NA, fog, drizzle, rain, lightrain, snow, thunderstorm | |
| } | |
| //END MODIFIED CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment