compare-geojson
Advanced tools
Comparing version 2.3.1 to 3.0.0
@@ -30,2 +30,4 @@ 'use strict'; | ||
var cfVersion = 2; | ||
if (!newVersion || !oldVersion) { | ||
@@ -53,2 +55,3 @@ return callback(null, {}); | ||
'result:compare_geometries': { | ||
'cfVersion': cfVersion, | ||
'areaDelta': areaDelta, | ||
@@ -55,0 +58,0 @@ 'centroidDisplacement': centroidDisplacement, |
@@ -13,2 +13,5 @@ 'use strict'; | ||
function feature_version(newVersion, oldVersion, callback) { | ||
var cfVersion = 2; | ||
var version = -1; | ||
@@ -18,7 +21,17 @@ var result = {}; | ||
version = newVersion.properties ? newVersion.properties['osm:version'] : newVersion['version']; | ||
result = {'result:feature_version': version}; | ||
result = { | ||
'result:feature_version': { | ||
'cfVersion': cfVersion, | ||
'version': version | ||
} | ||
}; | ||
return callback(null, result); | ||
} else if (oldVersion) { | ||
version = oldVersion.properties ? oldVersion.properties['osm:version'] : oldVersion['version']; | ||
result = {'result:feature_version': version}; | ||
result = { | ||
'result:feature_version': { | ||
'cfVersion': cfVersion, | ||
'version': version | ||
} | ||
}; | ||
return callback(null, result); | ||
@@ -25,0 +38,0 @@ } else { |
@@ -16,2 +16,4 @@ 'use strict'; | ||
var cfVersion = 2; | ||
if (!newVersion || !newVersion.properties) { | ||
@@ -39,2 +41,3 @@ return callback(null, {}); | ||
'result:low_zoom_features': { | ||
'cfVersion': cfVersion, | ||
'lowZoomCount': lowZoomCount, | ||
@@ -41,0 +44,0 @@ 'lowZoomFeatures': lowZoomFeatures |
@@ -12,2 +12,5 @@ 'use strict'; | ||
function new_mapper(newVersion, oldVersion, callback) { | ||
var cfVersion = 2; | ||
/* | ||
@@ -28,2 +31,3 @@ User IDs on OpenStreetMap are in serial order. | ||
var result = {'result:new_mapper': { | ||
'cfVersion': cfVersion, | ||
'newMapper': uid > vidhatri | ||
@@ -30,0 +34,0 @@ }}; |
@@ -15,2 +15,5 @@ 'use strict'; | ||
function uncommon_tags(newVersion, oldVersion, callback) { | ||
var cfVersion = 2; | ||
if (!newVersion || !newVersion.properties) { | ||
@@ -38,2 +41,3 @@ return callback(null, {}); | ||
'result:uncommon_tags': { | ||
'cfVersion': cfVersion, | ||
'uncommonCount': uncommonCount, | ||
@@ -40,0 +44,0 @@ 'uncommonTags': uncommonTags |
@@ -12,3 +12,3 @@ 'use strict'; | ||
'delete_create': require('./comparators/delete_create'), | ||
'landmark': require('./comparators/landmark'), | ||
'landmark_score': require('./comparators/landmark_score'), | ||
'city_deleted': require('./comparators/city_deleted'), | ||
@@ -21,3 +21,4 @@ 'compare_properties': require('./comparators/compare_properties'), | ||
'uncommon_tags': require('./comparators/uncommon_tags'), | ||
'low_zoom_features': require('./comparators/low_zoom_features') | ||
'low_zoom_features': require('./comparators/low_zoom_features'), | ||
'user_blocks': require('./comparators/user_blocks') | ||
}; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var deleteCreate = require('../comparators/delete_create'); | ||
var landmark = require('../comparators/landmark.js'); | ||
var landmarkScore = require('../comparators/landmark_score.js'); | ||
var cityDeleted = require('../comparators/city_deleted'); | ||
@@ -35,3 +35,3 @@ var compareProperties = require('../comparators/compare_properties'); | ||
deleteCreate, | ||
landmark, | ||
landmarkScore, | ||
cityDeleted, | ||
@@ -38,0 +38,0 @@ compareProperties, |
{ | ||
"name": "compare-geojson", | ||
"version": "2.3.1", | ||
"version": "3.0.0", | ||
"description": "Compare a features new and old versions in GeoJSON", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,14 +19,23 @@ # Compare-GeoJSON | ||
#### 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 checkPlaceRemoval(newVersion, oldVersion, callback) { | ||
var oldProps = oldVersion.properties; | ||
var newProps = newVersion.properties; | ||
var result = {}; | ||
if (oldProps.hasOwnProperty('place') && !newProps.hasOwnProperty('place')) { | ||
result['result:place_removed'] = true; | ||
} | ||
return callback(null, result); | ||
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 | ||
}}); | ||
} | ||
``` |
@@ -10,3 +10,4 @@ { | ||
"centroidDisplacement": 0, | ||
"geometryTransformation": -19358224.42068947 | ||
"geometryTransformation": -19358224.42068947, | ||
"cfVersion": 2 | ||
} | ||
@@ -13,0 +14,0 @@ }, |
@@ -7,3 +7,6 @@ { | ||
"expectedResult": { | ||
"result:feature_version": 1 | ||
"result:feature_version": { | ||
"cfVersion": 2, | ||
"version": 1 | ||
} | ||
}, | ||
@@ -38,3 +41,6 @@ "newVersion": null, | ||
"expectedResult": { | ||
"result:feature_version": 13 | ||
"result:feature_version": { | ||
"cfVersion": 2, | ||
"version": 13 | ||
} | ||
}, | ||
@@ -96,3 +102,6 @@ "newVersion": { | ||
"expectedResult": { | ||
"result:feature_version": 1 | ||
"result:feature_version": { | ||
"cfVersion": 2, | ||
"version": 1 | ||
} | ||
}, | ||
@@ -127,3 +136,7 @@ "newVersion": { | ||
"expectedResult": { | ||
"result:feature_version": 17 | ||
"result:feature_version": { | ||
"cfVersion": 2, | ||
"version": 17 | ||
} | ||
}, | ||
@@ -130,0 +143,0 @@ "newVersion": { |
@@ -6,3 +6,6 @@ { | ||
"result:significant_place": 195, | ||
"result:wikipedia_score": 3.4 | ||
"result:landmark_score": { | ||
"cfVersion": 2, | ||
"score": 3.4 | ||
} | ||
}, | ||
@@ -9,0 +12,0 @@ "features": [ |
{ | ||
"type": "FeatureCollection", | ||
"properties": { | ||
"result:wikipedia_score": 2.9 | ||
"result:landmark_score": { | ||
"cfVersion": 2, | ||
"score": 2.9 | ||
} | ||
}, | ||
@@ -38,2 +41,2 @@ "features": [ | ||
] | ||
} | ||
} |
@@ -8,2 +8,3 @@ { | ||
"result:low_zoom_features": { | ||
"cfVersion": 2, | ||
"lowZoomCount": 1, | ||
@@ -10,0 +11,0 @@ "lowZoomFeatures": { |
@@ -8,2 +8,3 @@ { | ||
"result:new_mapper": { | ||
"cfVersion": 2, | ||
"newMapper": true | ||
@@ -41,2 +42,3 @@ } | ||
"result:new_mapper": { | ||
"cfVersion": 2, | ||
"newMapper": false | ||
@@ -43,0 +45,0 @@ } |
@@ -8,2 +8,3 @@ { | ||
"result:uncommon_tags": { | ||
"cfVersion": 2, | ||
"uncommonCount": 0, | ||
@@ -10,0 +11,0 @@ "uncommonTags": {} |
@@ -49,5 +49,5 @@ /* eslint global-require: [0] */ | ||
} | ||
assert.deepEqual(fixture.expectedResult, result, fixture.description); | ||
assert.deepEqual(result, fixture.expectedResult, fixture.description); | ||
callback(); | ||
}); | ||
} |
@@ -34,3 +34,3 @@ 'use strict'; | ||
for (var prop in expectedProperties) { | ||
assert.equal(result[prop], expectedProperties[prop], prop + ' as expected'); | ||
assert.deepEqual(result[prop], expectedProperties[prop], prop + ' as expected'); | ||
} | ||
@@ -37,0 +37,0 @@ callback(null, null); |
Sorry, the diff of this file is too big to display
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
66110200
58
15416
41
7