compare-geojson
Advanced tools
Comparing version 4.3.0 to 4.3.1
'use strict'; | ||
var request = require('request'); | ||
var moment = require('moment'); | ||
var sax = require('sax'); | ||
module.exports = pokemonFootway; | ||
function pokemonFootway(newVersion, oldVersion, callback) { | ||
try { | ||
if (newVersion.properties.highway === 'footway' && newVersion.properties['osm:version'] === 1) { | ||
return callback(null, { | ||
'result:pokemonFootway': true, | ||
'result:escalate': true | ||
function getAccountCreated(userID, callback) { | ||
var url = ' http://api.openstreetmap.org/api/0.6/user/' + userID; | ||
request(url, function (error, response, body) { | ||
if (error) return callback(error); | ||
if (!error && response.statusCode === 200) { | ||
var accountCreated; | ||
var parser = sax.createStream(true); | ||
parser.on('opentag', function(element) { | ||
if ('attributes' in element && ('account_created' in element.attributes)) { | ||
accountCreated = element.attributes.account_created; | ||
} | ||
}); | ||
parser.on('end', function() { | ||
return callback(null, moment(accountCreated)); | ||
}); | ||
parser.write(body); | ||
parser.end(); | ||
} else { | ||
return callback(null, null); | ||
} | ||
} catch (error) { | ||
console.log(String(error)); | ||
}); | ||
} | ||
function pokemonFootway(newVersion, oldVersion, callback) { | ||
// Yeah. moment.js is wierd, month start from zero | ||
var newUserDate = moment([2016, 11, 23]); | ||
if (newVersion && newVersion.properties && newVersion.properties.highway === 'footway' && newVersion.properties['osm:version'] === 1) { | ||
getAccountCreated(newVersion.properties['osm:uid'], function (error, accountCreated) { | ||
if (error) { | ||
console.log(String(error)); | ||
return callback(null, {}); | ||
} | ||
if (accountCreated.unix() >= newUserDate.unix()) { | ||
return callback(null, { | ||
'result:pokemon_footway': true, | ||
'result:escalate': true | ||
}); | ||
} else { | ||
return callback(null, {}); | ||
} | ||
}); | ||
} else { | ||
return callback(null, {}); | ||
} | ||
return callback(null, {}); | ||
} |
{ | ||
"name": "compare-geojson", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Compare a features new and old versions in GeoJSON", | ||
@@ -19,4 +19,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"moment": "^2.17.1", | ||
"queue-async": "^1.2.1", | ||
"request": "^2.72.0", | ||
"sax": "^1.2.1", | ||
"sqlite3": "^3.1.3", | ||
@@ -23,0 +25,0 @@ "turf-area": "^1.1.1", |
@@ -5,3 +5,3 @@ { | ||
{ | ||
"description": "Looking for highway = footway with version = 1", | ||
"description": "Looking for highway = footway with version != 1 and new mapper", | ||
"newVersion": { | ||
@@ -11,3 +11,4 @@ "type": "Feature", | ||
"highway": "footway", | ||
"osm:version": 1 | ||
"osm:version": 4, | ||
"osm:uid": 5008734 | ||
}, | ||
@@ -33,14 +34,42 @@ "geometry": { | ||
"oldVersion": null, | ||
"expectedResult": { | ||
"result:pokemonFootway": true, | ||
"result:escalate": true | ||
} | ||
"expectedResult": {} | ||
}, | ||
{ | ||
"description": "Looking for highway = footway with version != 1", | ||
"description": "Looking for highway != footway with version != 1 and new mapper", | ||
"newVersion": { | ||
"type": "Feature", | ||
"properties": { | ||
"highway": "primary", | ||
"osm:version": 4, | ||
"osm:uid": 5008734 | ||
}, | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": [ | ||
[ | ||
77.57569670677185, | ||
12.969890973519856 | ||
], | ||
[ | ||
77.57473111152648, | ||
12.968186782548875 | ||
], | ||
[ | ||
77.57380843162537, | ||
12.96650349043761 | ||
] | ||
] | ||
} | ||
}, | ||
"oldVersion": null, | ||
"expectedResult": {} | ||
}, | ||
{ | ||
"description": "Looking for highway = footway with version = 1 and old mapper", | ||
"newVersion": { | ||
"type": "Feature", | ||
"properties": { | ||
"highway": "footway", | ||
"osm:version": 4 | ||
"osm:version": 1, | ||
"osm:uid": 81735 | ||
}, | ||
@@ -69,8 +98,9 @@ "geometry": { | ||
{ | ||
"description": "Looking for highway != footway with version != 1", | ||
"description": "Looking for highway = footway with version = 1 and new mapper", | ||
"newVersion": { | ||
"type": "Feature", | ||
"properties": { | ||
"highway": "primary", | ||
"osm:version": 4 | ||
"highway": "footway", | ||
"osm:version": 1, | ||
"osm:uid": 5008734 | ||
}, | ||
@@ -96,5 +126,8 @@ "geometry": { | ||
"oldVersion": null, | ||
"expectedResult": {} | ||
"expectedResult": { | ||
"result:pokemon_footway": true, | ||
"result:escalate": true | ||
} | ||
} | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1772986
27136
11
+ Addedmoment@^2.17.1
+ Addedsax@^1.2.1
+ Addedmoment@2.30.1(transitive)
+ Addedsax@1.4.1(transitive)