mv
This commit is contained in:
commit
a4dae5342e
31
index.js
Normal file
31
index.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
const request = require('request');
|
||||||
|
const regression = require('regression');
|
||||||
|
|
||||||
|
const old_url = 'https://gisanddata.maps.arcgis.com/sharing/rest/content/items/bda7594740fd40299423467b48e9ecf6/data?f=json';
|
||||||
|
const base_url = "https://services1.arcgis.com/0MSEUqKaxRlEPj5g/arcgis/rest/services/cases_time/FeatureServer/0/query?f=json";
|
||||||
|
const date_arg = "&where=Report_Date%3C%3D%272020-02-02 22:59:59%27";
|
||||||
|
const more_arg = "&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=Report_Date%20asc&resultOffset=0&resultRecordCount=2000&cacheHint=true";
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = function(){
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
|
||||||
|
request(base_url + date_arg + more_arg, function (error, response, body) {
|
||||||
|
if(response.statusCode == 200){
|
||||||
|
const cnt = JSON.parse(body);
|
||||||
|
//console.log('body:',cnt.features); // Print the HTML for the Google homepage.
|
||||||
|
var data = [[0,0]];
|
||||||
|
for (var dp of cnt.features) {
|
||||||
|
if(dp.attributes.Total_Confirmed != null){
|
||||||
|
data.push([dp.attributes.ObjectId, dp.attributes.Total_Confirmed]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var cur_result = regression.polynomial(data, { order: 3 });
|
||||||
|
resolve(cur_result.predict(cnt.features.length))
|
||||||
|
}else{
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user