-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cristiam Diaz
committed
Mar 26, 2016
0 parents
commit b19fa22
Showing
5 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Ideam-weather | ||
|
||
#### Alarmas y Pronósticos climatológicos para el territorio Colombiano suministrados por el IDEAM | ||
|
||
## Instalación | ||
|
||
```sh | ||
npm install ideam-weather --save | ||
``` | ||
|
||
## Ejemplo de Uso | ||
|
||
```js | ||
var weather = require('ideam-weather'); | ||
|
||
weather.getCiudades(function(err, ciudades) { | ||
if (err) { | ||
return console.error(err); | ||
} | ||
console.log(ciudades); | ||
}) | ||
``` | ||
|
||
```js | ||
weather.getPronosticoCiudades('18001000',function(err, pronostico) { | ||
if (err) { | ||
return console.error(err); | ||
} | ||
console.log(pronostico); | ||
}) | ||
``` | ||
|
||
## Métodos disponibles: | ||
|
||
+ `getRegiones()` | ||
+ `getCiudades()` | ||
+ `getFenomenos()` | ||
+ `getZonasMaritimas()` | ||
+ `getNivelesAlarma()` | ||
|
||
##### Pronósticos: | ||
+ `getPronosticoCiudades('codigoDivipolaDane')` | ||
+ `getPronosticoRegiones('codigoRegion')` | ||
+ `getPronosticoMaritimos('codigoZonaMaritima')` | ||
|
||
##### Alarmas: | ||
+ `getAlarmasNacionales()` | ||
+ `getAlarmasDepartamento('codigoDivipolaDane')` | ||
+ `getAlarmasMunicipio('codigoDivipolaDane')` | ||
+ `getAlarmasZonaMaritima('codigoZonaMaritima')` | ||
|
||
## Notas: | ||
|
||
El servicio de pronóstico por ciudad solo está disponible para algunas ciudades principales; para obtener la lista de ciudades disponibles y su respectivo código del DANE puede utilizar el método `getCiudades()` | ||
|
||
Los códigos de región y zona maritima se obtienen con los métodos `getRegiones()` y `getZonasMaritimas()` respectivamente | ||
|
||
Los pronósticos y Alarmas por Departamento y Municipio requieren el codigo asignado por el DANE en la codificación de la División Política Administrativa (Divipola) para dichas entidades territoriales, para mas información consultar el siguiente link: http://www.dane.gov.co/index.php/esp/nomenclaturas-y-clasificaciones/divipola | ||
|
||
|
||
#### Documentación Oficial del servicio web: | ||
|
||
http://institucional.ideam.gov.co/jsp/info/ws/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/ideam-weather'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
var soap = require('soap'); | ||
var parseString = require('xml2js').parseString; | ||
var callerId = require('caller-id'); | ||
var WSDL_URL = 'http://tausa.ideam.gov.co/portal/WebServicesIDEAMService?WSDL'; | ||
|
||
function Ideam () { | ||
|
||
} | ||
|
||
Ideam.prototype.getRegiones = function (cb) { | ||
webService({}, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.REGIONES.REGION)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getCiudades = function (cb) { | ||
webService({}, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.CIUDADES.CIUDAD)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getFenomenos = function (cb) { | ||
webService({}, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.FENOMENOS.FENOMENO)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getZonasMaritimas = function (cb) { | ||
webService({}, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.ZONAS_MARITIMAS.ZONA_MARITIMA)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getNivelesAlarma = function (cb) { | ||
webService({}, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.NIVELES.NIVEL)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getPronosticoCiudades = function (args,cb) { | ||
var params = {':codigoDivipolaDANE':args,':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.PRONOSTICOS)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getPronosticoRegiones = function (args,cb) { | ||
var params = {':codigoRegion':args, ':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.PRONOSTICOS)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getPronosticoMaritimos = function (args,cb) { | ||
var params = {':codigoZonaMaritima':args, ':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.PRONOSTICOS)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getAlarmasNacionales = function (cb) { | ||
var params = {':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.ALARMAS.ALARMA)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getAlarmasDepartamento = function (args,cb) { | ||
var params = {':codigoDivipolaDane':args,':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.ALARMAS)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getAlarmasMunicipio = function (args,cb) { | ||
var params = {':codigoDivipolaDane':args,':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.ALARMAS)); | ||
}); | ||
} | ||
|
||
Ideam.prototype.getAlarmasZonaMaritima = function (args,cb) { | ||
var params = {':codigoZonaMaritima':args, ':idioma':'es'}; | ||
webService(params, function(err, result) { | ||
if(err) return cb(err); | ||
return cb(err, JSON.stringify(result.ALARMAS)); | ||
}); | ||
} | ||
|
||
var webService = function(args,cb) { | ||
|
||
var Method = callerId.getData().methodName; | ||
soap.createClient(WSDL_URL, { | ||
ignoredNamespaces: { | ||
namespaces: [], | ||
override: true | ||
} | ||
},function (err, client) { | ||
if(err) { | ||
return cb(err); | ||
} | ||
|
||
client[Method](args,function (err,result) { | ||
if(!err) { | ||
parseString(result.return, function (err, result) { | ||
if (!err) { | ||
return cb(null, result); | ||
} else { | ||
return cb(err); | ||
} | ||
}); | ||
} else { | ||
return cb(err.root.Envelope.Body.Fault.faultstring); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = new Ideam(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "ideam-weather", | ||
"description": "Alarmas y Pronósticos climatológicos para el territorio Colombiano suministrados por el IDEAM", | ||
"version": "0.1.0", | ||
"author": "Cristiam Diaz <cdiaz@quantux.co>", | ||
"maintainers": [ | ||
"cdiaz <cdiaz@quantux.co>" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cdiaz/ideam-weather.git" | ||
}, | ||
"keywords": [ | ||
"weather forecast", | ||
"clima colombia", | ||
"pronosticos del clima", | ||
"monitoreo del clima", | ||
"ideam", | ||
"meteorologia" | ||
], | ||
"dependencies": { | ||
"caller-id": "^0.1.0", | ||
"soap": "^0.13.0", | ||
"xml2js": "^0.4.16" | ||
}, | ||
"main": "./lib/ideam-weather", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 0.6.12" | ||
} | ||
} |