Code Monkey home page Code Monkey logo

weatherapi's Introduction

WeatherAPI

WeatherAPI is a simple abstraction atop one or many free weather services.

Build Status

How To Use

Maven

If you're using maven, simply add a dependency for net.johnluetke.WeatherAPI:

<dependency>
    <groupId>net.johnluetke.WeatherAPI</groupId>
    <artifactId>WeatherAPI</artifactId>
    <version>0.9.4</version>
</dependency>

For a list of version numbers, see the Releases section

Other / .NET

If you're not using Maven or are using .NET, download the .jar or .dll from my artifacts repository. Also make sure to download the required dependencies! They can be found in the file ending in .dependencies

C#

    using WeatherAPI;
    
    IWeather seattle;
    
    // You can get the weather for a city and state ...
    seattle = WeatherAPI.GetWeather("Seattle", "WA");
    
    // ... for an Airport code ...
    seattle = WeatherAPI.GetWeather("SEA");
    
    // ... for a ZIP code ...
    seattle = WeatherAPI.GetWeather(98158);

    // ... or for a set of latitude and longitude coordinates
    seattle = WeatherAPI.GetWeather(47.44443, -122.300497);

Java

    import WeatherAPI.*;
    
    IWeather seattle;
    
    // You can get the weather for a city and state ...
    seattle = WeatherAPI.GetWeather("Seattle", "WA");
    
    // ... for an Airport code ...
    seattle = WeatherAPI.GetWeather("SEA");
    
    // ... for a ZIP code ...
    seattle = WeatherAPI.GetWeather(98158);

    // ... or for a set of latitude and longitude coordinates
    seattle = WeatherAPI.GetWeather(47.44443, -122.300497);

About

WeatherAPI abstracts free weather services into a simple to use API. You will need to register with the supported services and obtain an API key for them, should you choose to use them. You can use all or none of the supported services.

Supported Services

Creating a New Provider

WeatherAPI is built in a provider-agnostic way. That is, it is not tightly coupled to any one specific source of data. It obtains data by means of providers, which are tightly coupled, but return the data from thier source in a class that adheres to the IWeather interface. It's up to the provider to take the location information provided by the user, parse it into a useable format, call the service and parse the data.

WeatherAPI provides an abstract class for providers to derive from: WeatherProvider. All providers must inherit this class in order to be discovered.

FAQ

How can I use WeatherAPI with my mobile application?

Since WeatherAPI is written in C# and Java, it can easily be used on any mobile platform that supports those languages. Out of the box, this is just Windows Phone and Android. However, with commercial tools such as MonoTouch, WeatherAPI can be used by iOS as well.

How do I configure WeatherAPI?

C#

WeatherAPI will search for WeatherAPI.dll.config on the in the application directory. Take a look at src/main/config/WeatherAPI.dll.config for an example.

Java

WeatherAPI will search for WeatherAPI.properties on the classpath. Take a look at src/main/config/WeatherAPI.properties for an example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.