Compare-GeoJSON
Compare functions take as inputs the following:
oldVersion
- GeoJSON of the feature's old versionnewVersion
- GeoJSON of the feature's new versioncallback
- A function to call after processing.
Compare functions output the following:
error
- Error if any during processing or null
.result
- Object containing key value pairs representing findings of the compare function or an empty object.
Versioning
The version of the compare function is returned as part of the result as cfVersion
. Every time a compare function is modified, we increment the cfVersion
.
A sample compare function would look something like this:
function place_removed(newVersion, oldVersion, callback) {
var cfVersion = 2;
var oldProps = oldVersion.properties;
var newProps = newVersion.properties;
var placeRemoved = false;
if (oldProps.hasOwnProperty('place') && !newProps.hasOwnProperty('place')) {
placeRemoved = true;
}
return callback(null, {'result:place_removed': {
'cfVersion': cfVersion,
'placeRemoved': placeRemoved
}});
}