Clime Tool API

Weather library for Java applications

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.malkomich
ArtifactId

ArtifactId

climet
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Clime Tool API
Weather library for Java applications
Project URL

Project URL

https://github.com/malkomich/climet
Source Code Management

Source Code Management

https://github.com/malkomich/climet

Download climet

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.json : json jar 20140107

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Clime Tool for Java

Build Status

Overview

This is a Java library wich provides a powerful tool for getting weather information and forecasts from any city you request. The weather data comes from external APIs, like Open Weather Map.

You must to be careful using this dependency in an Android application, because you have to call ClimeT methods in an Async Task in order to avoid performing networking operations in the main thread. If you don't, you will get a NetworkOnMainThreadException.

Install

Gradle

	dependencies {
	    compile 'com.github.malkomich:climet:1.0'
	}

Maven

	<dependency>
	    <groupId>com.github.malkomich</groupId>
	    <artifactId>climet</artifactId>
	    <version>1.0</version>
	</dependency>

Usage

  • Getting current weather by a city name.
	CurrentWeatherData data = ClimeT.getCurrentWeather("London");
	City city = data.getCity();
	Weather weather = data.getWeather();

	// You have all weather information in the City and Weather objects.
	String state = weather.getState().getMain();
	float temp = weather.getTemp().getCurrentTemp(Weather.CELSIUS);

	System.out.println("The current weather in " + city.getName() + " is: " + state + ", with a temperature of "
			+ temp + "\u00b0.");
  • Getting hour forecast by coordinates.
	HourForecastData data = ClimeT.getHourForecast(51.51, -0.13);
	List<Weather> forecast = data.getForecast();

	Weather weather = forecast.get(2);
	Calendar date = weather.getDateTime();
	float speed = weather.getWind().getSpeed();
	int cloudiness = weather.getClouds().getCloudiness();

	System.out.println("The day " + sdf.format(date.getTime()) + " at " + date.get(Calendar.HOUR_OF_DAY)
			+ ", the wind will have a speed of " + speed + " m/s, and the percentage of cloudiness will be "
			+ cloudiness + "%.");
  • Getting date forecast by city.
	DateForecastData data = ClimeT.getDateForecast("London");
	List<Weather> forecast = data.getForecast();

	Weather weather1 = forecast.get(2);
	Calendar date1 = weather1.getDateTime();
	float rain = weather1.getRain().getValue();
	Weather weather2 = forecast.get(5);
	Calendar date2 = weather2.getDateTime();
	float snow = weather2.getSnow().getValue();

	String rainMessage = (rain > 0) ? (" there will be rainfall with a volume of " + rain + " l/m2")
			: " there won't be rainfall";
	String snowMessage = (snow > 0) ? (" there will be snowfall with a volume of " + snow + " l/m2.")
			: " there won't be snowfall.";

	System.out.println("In the day " + sdf.format(date1.getTime()) + rainMessage + ", and in the day "
			+ sdf.format(date2.getTime()) + snowMessage);

Versions

Version
1.0