meteo-test

Meteo test package

License

License

GroupId

GroupId

no.api.meteo
ArtifactId

ArtifactId

meteo-test
Last Version

Last Version

3.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

meteo-test
Meteo test package
Project Organization

Project Organization

Amedia

Download meteo-test

How to add to project

<!-- https://jarcasting.com/artifacts/no.api.meteo/meteo-test/ -->
<dependency>
    <groupId>no.api.meteo</groupId>
    <artifactId>meteo-test</artifactId>
    <version>3.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/no.api.meteo/meteo-test/
implementation 'no.api.meteo:meteo-test:3.0.1'
// https://jarcasting.com/artifacts/no.api.meteo/meteo-test/
implementation ("no.api.meteo:meteo-test:3.0.1")
'no.api.meteo:meteo-test:jar:3.0.1'
<dependency org="no.api.meteo" name="meteo-test" rev="3.0.1">
  <artifact name="meteo-test" type="jar" />
</dependency>
@Grapes(
@Grab(group='no.api.meteo', module='meteo-test', version='3.0.1')
)
libraryDependencies += "no.api.meteo" % "meteo-test" % "3.0.1"
[no.api.meteo/meteo-test "3.0.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j jar 1.7.12
org.slf4j : slf4j-api jar 1.7.12
org.projectlombok : lombok jar 1.16.4
ch.qos.logback : logback-classic jar 1.1.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19

Project Modules

There are no modules declared in this project.

METEO

Meteo is an Open-Source Java based library/client for handling weather data from http://api.met.no.

It mainly consists of two parts: A Java client that parses data from the MET api into java objects and helper tools to help you pick the right kind of data for different scenarios.

Please note that Meteo is in no way affiliated with the Norwegian Meteorological Institute except for the fact that it use their API to provide you with weather data.

Meteo is developed and maintained by Amedia Utvikling AS. It is in use within all the Amedia sites (more than 70). It mainly supports the services that Amedia needs at any given time. But we will consider adding other services as well upon request (or send a pull request).

The MET terms of use

Make sure to read the Conditions for use of the service from the Norwegian Meteorological Institute.

Also make sure to read this http://api.met.no/license_data.html.

Reverse proxying

As MET states in their terms of use, you must respect their cache headers. Meaning that you should only fetch one resource one time within the TTL set by MET in each response.

The easiest way to achieve this is by installing a Reverse Proxy like Squid. An alternative solution is to implement your own MeteoClient that respects these requirements.

The default implementation of MeteoClient does not have any caching what so ever, but it does support configuring a proxy.

The core library and client

The core library in Meteo is all about offering access to the raw MET data through a Java API. As stated earlier we have only implemented support for the services that Amedia needs or that is requested/implemented by other users (Please send pull requests).

Requirements

Meteo requires Java 8.x or later.

Installation

You will find Meteo in the central maven repository: http://search.maven.org/#search|ga|1|a%3A%22meteo%22

For Maven you would add this to your pom:

<dependency>
    <groupId>no.api.meteo</groupId>
    <artifactId>meteo-core</artifactId>
    <version>3.0.0</version>
</dependency>

If you want to use the default implementation of a MeteoClient, then you would also have to add this:

<dependency>
    <groupId>no.api.meteo</groupId>
    <artifactId>meteo-client</artifactId>
    <version>3.0.0</version>
</dependency>

Usage

In the meteo-examples module you will find several useful examples that should get you up and running

Creating a default client

If you feel fine with the default MeteoClient shipped with Meteo, then create a client like this:

MeteoClient meteoClient = new DefaultMeteoClient();

This client allows you to configure a proxy and connection timeout if needed:

meteoClient.setProxy("myproxy.host", 9000);
meteoClient.setTimeout(1000);

You can also create you own client easily by implementing the MeteoClient interface in your own class.

Services

The Meteo core library is organized in a set of services where each service represents on of the services in the MET API. Each service will need an Meteo client to be able to fetch data.

Current services:

  • Location forecast
  • Sunrise
  • Text forecast (Experimental)
  • Text locations (Experimental)

Location forecast service

This is the service for fetching raw data from http://api.met.no/weatherapi/locationforecastlts/1.2/documentation.

LocationforecastLTSService service = new LocationforecastLTSService(meteoClient);
try {
    MeteoData<LocationForecast> data = service.fetchContent(longitude, latitude, altitude);
} catch (MeteoException e) {
    // Handle exception.
}

Sunrise service

This is the service for fetching raw data from http://api.met.no/weatherapi/sunrise/1.0/documentation.

SunriseService service = new SunriseService(meteoClient);
try {
    MeteoData<Sunrise> data = service.fetchContent(longitude, latitude, date);
} catch (MeteoException e) {
    // Handle exception.
}

General developer notes

Meteo uses checked exceptions at the moment. This will change in the 3.1.x versions.

no.api.meteo

Amedia Utvikling

Versions

Version
3.0.1
3.0.0
2.0.3
2.0.2