Setting weather QNH problem

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Post Reply
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Setting weather QNH problem

Post by redouane_bpw »

Hello
i made a weather engine
it gets metar from the net and apply to P3D
it works but

when setting the weather , there are many changes : for example(the worst ) the QNH

in the metar it's 1023 but in the sim 1000 ( always 1000 )

for winds, metar : 05kt sim : 10kt

any fixes ?

i use C# and i set the set mode to global();

thnx in advance
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

Hi,

the Metar format in P3D is pretty unique. You cannot just download a METAR string from the Internet and inject it into the sim, hoping that it will show the same weather. Most of the time this will not work. You have to parse the weather information that you download and build a new METAR string specific for the simulator as per its own specification:
Learning Center -> Software Development Kit (SDK) -> SimConnect API -> References -> World Functions -> SimConnect_WeatherSetObservation -> Metar Data Format

This will take some figuring out, the sim is really temperamental when it comes to understanding your METAR strings. This spec will also answer your other question about how to set the weather globally:
STATION ID (has an extension) : CCCC - a three or four character station ID. For example KORD for O'Hare airport in Chicago. The string GLOB can be used to set global weather data.
Best regards
Oliver Binder
Lorby-SI
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

ah thnx
can i use the setmode custom with the GLOB ID to get a specific values ( i found that set mode custom make the qnh and winds values more precized )
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

redouane_bpw wrote: Wed Feb 13, 2019 12:06 pm ah thnx
can i use the setmode custom with the GLOB ID to get a specific values ( i found that set mode custom make the qnh and winds values more precized )
It is not one or the other. WeatherSetModeCustom and WeatherSetModeGlobal don't have any parameters, they control what the weather engine is doing in general.

As far as I know you must set the weather mode to custom in any case when you plan on changing the weather manually (no matter if globally or locally). Otherwise the simulators weather engine remains active and changes your values.

You set WeatherSetModeCustom and you set WeatherSetModeGlobal and then you inject a valid METAR string using GLOB as the ID of the weather station with WeatherSetObservation. Then weather should be the same everywhere (?).

But to make realistic weather, you will have to send many METAR strings to all the local weather stations, maybe even create your own stations, while tweaking the METAR just so that the right cloud formations etc. appear. Making a proper weather engine is not a small task.

Best regards
Oliver Binder
Lorby-SI
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

i'm thinking of making many stations to apply enroute weather
the problem is there is no weather source that i can use to get good informations
we are not living in an aviation world so the weather infos are just for cities :'(
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

redouane_bpw wrote: Wed Feb 13, 2019 5:35 pm i'm thinking of making many stations to apply enroute weather
That is not what I mean. The weather is not uniform out to the horizon. Weather may be clear above you, but have clouds 40 miles out. You cannot simulate real weather in global mode.
the problem is there is no weather source that i can use to get good informations
we are not living in an aviation world so the weather infos are just for cities :'(
Not true. There are several web services that provide aviation weather.

For example, the NOAA AWC Text Data Server will give you METARs for lat/lon coordinates, stations ids, and many other request formats. I have implemented that a while ago in one of my freeware apps, and it seems to work OK-ish.

Best regards
Oliver Binder
Lorby-SI
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

For example, the NOAA AWC Text Data Server will give you METARs for lat/lon coordinates, stations ids, and many other request formats. I have implemented that a while ago in one of my freeware apps, and it seems to work OK-ish.
Hey
i took a look at the NOAA AWC Text Data Server, i found the documentation.
they didn't mention how can we request those data, as i saw it uses an xml
is there a link to use to download a specific xml ?
thnx in advance :)
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

redouane_bpw wrote: Wed Feb 13, 2019 8:54 pm Hey
i took a look at the NOAA AWC Text Data Server, i found the documentation.
they didn't mention how can we request those data, as i saw it uses an xml
is there a link to use to download a specific xml ?
thnx in advance :)
You just build a simple web request with the parameters that they suggest on the site (current, with constraints) and the response is a list of datasets as a standard XML web service response (or a CSV file download if you set that parameter). This example queries all Metar reports 120nm around a specific lat/lon location that were created in the last hour:

http://www.aviationweather.gov/adds/dat ... eforeNow=1

If you want to see what this looks like in the sim, this method is used in my LorbyLiveTraffic app to set the real world weather. Then you can decide if it is worth the effort that you plan to invest. To achieve this, I am not using the METAR strings at all, instead I build new ones, specific for the simulator, using the raw information contained in the datasets.

Best regards
Oliver Binder
Lorby-SI
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

i'm a noobie in programming , i never done web requests :)
i think time to learn new things
thnx for the info and i'll check your app :)
cheers
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

redouane_bpw wrote: Thu Feb 14, 2019 5:30 pm i never done web requests
You do that a thousand times every day, the whole Internet works like this. What you type in the address bar is the request, and what you are getting back (= the web page) is the response. Most of the time you don't know that you are doing it, but every button that you click (=submit) will send a request like this in the background. The web page/response is also in XML format, but a special one: HTML. Your browser knows this, and instead of presenting you with XML code, it displays what the XML=HTML tells it to do. (Yes, of course it is more complex than that, there are many advanced web based technologies out there - but this is the basic operation). Right-click in any webpage and select "Show Sourcecode" - and you will see the XML behind it.

Best regards
Oliver Binder
Lorby-SI
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

hey
i understood now the web request concept
i also tried programming it
and i succeeded doing it :D
now i need the NOAA link to request from, and that's what i'm trying to find in the text server documentation
redouane_bpw
Posts: 31
Joined: Sat Dec 01, 2018 1:29 pm

Re: Setting weather QNH problem

Post by redouane_bpw »

i think i just found it
aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&stationString=STATION&hoursBeforeNow=What ever&mostRecent=true
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Re: Setting weather QNH problem

Post by obinder »

The "Text Data Server (TDS) ver 1.3" page lists the various data types that you can query, with examples.

Click "Examples" next to "METARs", look for the parameters that interest you and just click on the link in the column "Example(s)". The result will be displayed in your browser and the request string is in the browser address bar at the top, complete with all parameters used to get the result.

Best regards
Oliver Binder
Lorby-SI
Post Reply