WangDaYeeeeee / GeometricWeather

A Material Design Weather Application
GNU Lesser General Public License v3.0
2.44k stars 186 forks source link

[Feature Request] Add Environment Canada as weather source #253

Open ray-holmium opened 3 years ago

ray-holmium commented 3 years ago

Thanks a bunch for your work, this really is a top notch weather app.

Would it be possible to add the official Environment Canada api as a weather source? The AccuWeather source is often inaccurate for my area.

Here's a link to more info about the official api: https://api.weather.gc.ca/

papjul commented 3 years ago

I can't seem to find an endpoint for:

On your link.

Also, can you clarify if only canadian stations are available, or if it can be used worldwide?

austinhuang0131 commented 3 years ago

@papjul Not OP but I'll answer.

I think OP linked a different API which is not used for weather stuff. MSC Datamart is instead used for weather.

Highlights:

Only Canadian stations are available.

ray-holmium commented 3 years ago

@austinhuang0131 thanks so much for pointing to the correct api! I was obviously shooting in the dark.

0-5-0 commented 2 years ago

Was there still any interest in implementing this? It would be great to be able to select Environment Canada as a provider especially since you allow selecting different APIs already. Environment Canada is by far the most accurate source for canadian weather and the official government app looks terrible.

papjul commented 2 years ago

You want Environment Canada as a provider for the same reasons I did the one for France. But unless someone from Canada wants to step in, chances that a provider used in only a country will be developed by someone else are low :/

Just like we have many provider requests, we need people to make pull requests. I know that Wangdaye is working on modularizing the project, so it should become easier to develop in the future, but until then…

anarcat commented 1 year ago

I might be interested in implementing this... is there a sample PR on how another provider was added or generally some hacking guide for this?

papjul commented 1 year ago

I might be interested in implementing this... is there a sample PR on how another provider was added or generally some hacking guide for this?

You can check this commit: https://github.com/papjul/GeometricWeather/commit/09c5d13d377dfecafc89b3a310fd68182061db65

It's a double provider: one for the location search (Nominatim), one for the weather data (MetNO). You may only need a single one, in that case, you can check other providers equivalent files, especially AccuWeather is the most-feature complete.

If you want it merged in my repo (which has a couple of fixes and new features), please fork my "new" branch.

anarcat commented 1 year ago

that's exactly what i was looking for, nice!

i think one of the challenges for canada is they have a static list of stations they provide weather for, so i guess we'd need to implement first a location search provider to restrict the search only for that?

papjul commented 1 year ago

If they don't have a location API, you can use Nominatim as I did and restrict the search to Canada.

anarcat commented 1 year ago

yeah but that's the thing, Nominatim will yield results that don't match stations, no?

papjul commented 1 year ago

But no one requests the weather at a station. We request the weather for a specific lon and lat. The location provider only helps matching a city name to its coordinates.

It's the job of the weather provider to derivate the data from the stations and predict the weather at nearby locations from past observations.

papjul commented 1 year ago

I re-read previous messages, and understand that forecast is generated for each city. Additionally, results are generated in XML. Good luck implementing it.

I think the way to go would be: 1) Implement the location provider by requesting the full XML file of all cities and filter when cities match characters (unless you can find a native XML library that can do that for you) 2) Implement the request weather data feature, by using city ID instead of lon and lat.

And of course, all of that in XML, which was never used for other providers and am not familiar with.