Skip to content

Commit 74be4ea

Browse files
Merge pull request #3 from JohnnyTheTank/5-day-forecast
bump to new version (v0.6.0)
2 parents 6adafb8 + 3ae1316 commit 74be4ea

File tree

7 files changed

+185
-14
lines changed

7 files changed

+185
-14
lines changed

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
1111
1. `bower install --save angular-openweathermap-api-factory`
1212
2. `npm install --save angular-openweathermap-api-factory`
1313
3. download [angular-openweathermap-api-factory.zip](https://github.com/JohnnyTheTank/angular-openweathermap-api-factory/zipball/master)
14-
2. Add `jtt_openweathermap` to your application's module dependencies.
14+
2. Add **`jtt_openweathermap`** to your application's module dependencies.
1515
3. Include dependencies in your HTML.
1616
1. When using bower:
1717
```html
@@ -28,9 +28,11 @@ Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
2828
4. Use the factory `openweathermapFactory`
2929

3030

31-
### factory methods
31+
## factory methods
3232

33-
#### weather from city by name
33+
### current weather
34+
35+
#### current weather from city by name
3436
```js
3537
// docs: http://openweathermap.org/current#name
3638
openweathermapFactory.getWeatherFromCitySearchByName({
@@ -46,7 +48,7 @@ openweathermapFactory.getWeatherFromCitySearchByName({
4648
});
4749
```
4850

49-
#### weather from city by id
51+
#### current weather from city by id
5052
```js
5153
// docs: http://openweathermap.org/current#cityid
5254
openweathermapFactory.getWeatherFromCityById({
@@ -61,7 +63,7 @@ openweathermapFactory.getWeatherFromCityById({
6163
});
6264
```
6365

64-
#### weather from group of cities by id
66+
#### current weather from group of cities by id
6567
```js
6668
// docs: http://openweathermap.org/current#severalid
6769
openweathermapFactory.getWeatherFromGroupOfCitiesById({
@@ -76,7 +78,7 @@ openweathermapFactory.getWeatherFromGroupOfCitiesById({
7678
});
7779
```
7880

79-
#### weather from location by coordinates
81+
#### current weather from location by coordinates
8082
```js
8183
// docs: http://openweathermap.org/current#geo
8284
openweathermapFactory.getWeatherFromLocationByCoordinates({
@@ -92,7 +94,7 @@ openweathermapFactory.getWeatherFromLocationByCoordinates({
9294
});
9395
```
9496

95-
#### weather from location by zipcode
97+
#### current weather from location by zipcode
9698
```js
9799
// docs: http://openweathermap.org/current#zip
98100
openweathermapFactory.getWeatherFromLocationByCoordinates({
@@ -107,6 +109,56 @@ openweathermapFactory.getWeatherFromLocationByCoordinates({
107109
});
108110
```
109111

112+
### 5-day-forecast
113+
114+
#### 5-day-forecast from city by name
115+
```js
116+
// docs: http://openweathermap.org/forecast5#name5
117+
openweathermapFactory.cityForecast5SearchByName({
118+
q:"<CITY_NAME>,<COUNTRY_CODE>", //city name and country code divided by comma, use ISO 3166 country codes eg "London,uk"
119+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
120+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
121+
type:"<TYPE>", // (optional) 'like' = close result, 'accurate' = accurate result
122+
appid:"<APP_ID>"
123+
}).then(function(_data){
124+
//on success
125+
}).catch(function (_data) {
126+
//on error
127+
});
128+
```
129+
130+
#### 5-day-forecast from city by id
131+
```js
132+
// docs: http://openweathermap.org/forecast5#cityid5
133+
openweathermapFactory.getForecast5FromCityById({
134+
id:"<CITY_ID>", //List of city ID can be downloaded here http://bulk.openweathermap.org/sample/city.list.json.gz
135+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
136+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
137+
appid:"<APP_ID>"
138+
}).then(function(_data){
139+
//on success
140+
}).catch(function (_data) {
141+
//on error
142+
});
143+
```
144+
145+
#### 5-day-forecast from location by coordinates
146+
```js
147+
// docs: http://openweathermap.org/forecast5#geo5
148+
openweathermapFactory.getForecast5FromLocationByCoordinates({
149+
lat:"<LAT>",
150+
lon:"<LONG>",
151+
lang:"<LANGUAGE>", // (optional) http://openweathermap.org/current#multi
152+
units:"<UNITS>", // (optinal) http://openweathermap.org/current#data
153+
appid:"<APP_ID>"
154+
}).then(function(_data){
155+
//on success
156+
}).catch(function (_data) {
157+
//on error
158+
});
159+
```
160+
161+
110162
## OpenWeatherMap JSON API
111163
* docs: http://openweathermap.org/api
112164

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-openweathermap-api-factory",
33
"description": "angularjs factory for openweathermap json rest api requests",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"main": "dist/angular-openweathermap-api-factory.js",
66
"authors": [
77
"Jonathan Hornung"

demo/js/app.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,26 @@ app.controller('controller', ['$scope', 'openweathermapFactory', function($scope
3939
console.info("weather from location by zipcode", _data);
4040
});
4141

42+
openweathermapFactory.getForecast5FromCitySearchByName({
43+
q:"munich",
44+
appid:_appid
45+
}).then(function(_data){
46+
console.info("5 day forecast from city by name", _data);
47+
});
48+
49+
openweathermapFactory.getForecast5FromCityById({
50+
id:"3220838",
51+
appid:_appid
52+
}).then(function(_data){
53+
console.info("5 day forecast from city by id", _data);
54+
});
55+
56+
openweathermapFactory.getForecast5FromLocationByCoordinates({
57+
lat:"48.1",
58+
lon:"11.63",
59+
appid:_appid
60+
}).then(function(_data){
61+
console.info("5 day forecast from location by coordinates", _data);
62+
});
63+
4264
}]);

dist/angular-openweathermap-api-factory.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
@name: angular-openweathermap-api-factory
3-
@version: 0.5.0 (25-02-2016)
3+
@version: 0.6.0 (25-09-2016)
44
@author: Jonathan Hornung
55
@url: https://github.com/JohnnyTheTank/angular-openweathermap-api-factory#readme
66
@license: MIT
@@ -57,6 +57,33 @@ angular.module("jtt_openweathermap", [])
5757
});
5858
};
5959

60+
openweathermapFactory.getForecast5FromCitySearchByName = function (_params) {
61+
var searchData = openweathermapSearchDataService.getNew("cityForecast5SearchByName", _params);
62+
return $http({
63+
method: 'GET',
64+
url: searchData.url,
65+
params: searchData.object,
66+
});
67+
};
68+
69+
openweathermapFactory.getForecast5FromCityById = function (_params) {
70+
var searchData = openweathermapSearchDataService.getNew("cityForecast5ById", _params);
71+
return $http({
72+
method: 'GET',
73+
url: searchData.url,
74+
params: searchData.object,
75+
});
76+
};
77+
78+
openweathermapFactory.getForecast5FromLocationByCoordinates = function (_params) {
79+
var searchData = openweathermapSearchDataService.getNew("locationForecast5ByCoordinates", _params);
80+
return $http({
81+
method: 'GET',
82+
url: searchData.url,
83+
params: searchData.object,
84+
});
85+
};
86+
6087
return openweathermapFactory;
6188
}])
6289
.service('openweathermapSearchDataService', function () {
@@ -117,7 +144,28 @@ angular.module("jtt_openweathermap", [])
117144
]);
118145
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
119146
break;
147+
148+
case "cityForecast5SearchByName":
149+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
150+
'q', 'lang', 'type', "units",
151+
]);
152+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
153+
break;
154+
155+
case "cityForecast5ById":
156+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
157+
'id', 'lang', "units",
158+
]);
159+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
160+
break;
161+
162+
case "locationForecast5ByCoordinates":
163+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
164+
'lat', 'lon', 'lang', "units",
165+
]);
166+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
167+
break;
120168
}
121169
return openweathermapSearchData;
122170
};
123-
});
171+
});

dist/angular-openweathermap-api-factory.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-openweathermap-api-factory",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"description": "angularjs factory for openweathermap json rest api requests",
55
"main": "dist/angular-openweathermap-api-factory.js",
66
"scripts": {

src/angular-openweathermap-api-factory.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,33 @@ angular.module("jtt_openweathermap", [])
5050
});
5151
};
5252

53+
openweathermapFactory.getForecast5FromCitySearchByName = function (_params) {
54+
var searchData = openweathermapSearchDataService.getNew("cityForecast5SearchByName", _params);
55+
return $http({
56+
method: 'GET',
57+
url: searchData.url,
58+
params: searchData.object,
59+
});
60+
};
61+
62+
openweathermapFactory.getForecast5FromCityById = function (_params) {
63+
var searchData = openweathermapSearchDataService.getNew("cityForecast5ById", _params);
64+
return $http({
65+
method: 'GET',
66+
url: searchData.url,
67+
params: searchData.object,
68+
});
69+
};
70+
71+
openweathermapFactory.getForecast5FromLocationByCoordinates = function (_params) {
72+
var searchData = openweathermapSearchDataService.getNew("locationForecast5ByCoordinates", _params);
73+
return $http({
74+
method: 'GET',
75+
url: searchData.url,
76+
params: searchData.object,
77+
});
78+
};
79+
5380
return openweathermapFactory;
5481
}])
5582
.service('openweathermapSearchDataService', function () {
@@ -110,7 +137,29 @@ angular.module("jtt_openweathermap", [])
110137
]);
111138
openweathermapSearchData.url = this.getApiBaseUrl() + "weather";
112139
break;
140+
141+
case "cityForecast5SearchByName":
142+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
143+
'q', 'lang', 'type', "units",
144+
]);
145+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
146+
break;
147+
148+
case "cityForecast5ById":
149+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
150+
'id', 'lang', "units",
151+
]);
152+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
153+
break;
154+
155+
case "locationForecast5ByCoordinates":
156+
openweathermapSearchData = this.fillDataInObjectByList(openweathermapSearchData, _params, [
157+
'lat', 'lon', 'lang', "units",
158+
]);
159+
openweathermapSearchData.url = this.getApiBaseUrl() + "forecast";
160+
break;
161+
113162
}
114163
return openweathermapSearchData;
115164
};
116-
});
165+
});

0 commit comments

Comments
 (0)