Search the weather record by time and StationID or longitude/latitude.
- Create the filter of find command for MongoDB.
Install directly via NPM
$ npm install weather-taiwan-timesearch
"use strict";
var TimeSearch = require('weather-taiwan-timesearch');
TimeSearch.StringByID(startTime, StationID, function(err, result) {
console.log(result);
})
TimeSearch.StringByGeo(longitude, latitude, startTime, options, function(err, result) {
console.log(result);
})
options is a Object for $near operator, currently only supports $maxDistance operator, the default value is 10000(meters), you can check the mongodb website for more info.
var config = {
"databaseLocal": {
"uri": "mongodb://localhost:27017/weatherTW",
"collection": "weatherAll"
}
}
TimeSearch.StringByID('2017-01-26T02:00:00.000Z', '466940', function(err, result) {
console.log(result);
})
TimeSearch.StringByGeo(121.534327, 25.018597, '2017-02-04T21:00:00.000Z', {}, function(err, result) {
console.log(result);
})
TimeSearch.StringByGeo(121.534327, 25.018597, '2017-02-04T21:00:00.000Z', {maxDistance: 10000}, function(err, result) {
console.log(result);
})
TimeSearch.SearchByID(config.databaseLocal.uri, config.databaseLocal.collection, '2017-02-04T21:00:00.000Z', '466940', function(err, result) {
console.log(result);
})
TimeSearch.Search(config.databaseLocal.uri, config.databaseLocal.collection, 121.534327, 25.018597, '2017-02-04T21:00:00.000Z', {maxDistance: 10000}, function(err, result) {
console.log(result);
})
$ node app.js
Licensed under the MIT License
Copyright(c) 2017 Wesley Tsai<wesleyboy42@gmail.com>