Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from mapbox/large-building
Browse files Browse the repository at this point in the history
compare function to catch large buildings
  • Loading branch information
manoharuss authored Dec 14, 2016
2 parents be85448 + 6f9cf8f commit 53fa4bc
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
17 changes: 17 additions & 0 deletions comparators/large-building.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

var turfArea = require('turf-area');
module.exports = largeBuilding;

function largeBuilding(newVersion, oldVersion, callback) {
var result = {};
if (!newVersion) {
return callback(null, result);
}
var area = turfArea(newVersion);

if (area > 100000 && newVersion.properties.hasOwnProperty('building')) {
result['result:large-building'] = area;
}
return callback(null, result);
}
125 changes: 125 additions & 0 deletions tests/fixtures/large-building.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"compareFunction":"large-building",
"fixtures":[
{
"Description":"This is a too large building input that should be caught",
"oldVersion": null,
"newVersion":{
"type":"Feature",
"properties":{
"building":"yes"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-124.49707031249999,
37.19533058280065
],
[
-124.49707031249999,
41.04621681452063
],
[
-120.62988281249999,
41.04621681452063
],
[
-120.62988281249999,
37.19533058280065
],
[
-124.49707031249999,
37.19533058280065
]
]
]
}
},
"expectedResult":{
"result:large-building": 143145029782.25003
}
},
{
"Description":"This is a small building input that should not be caught",
"oldVersion": null,
"newVersion":{
"type":"Feature",
"properties":{
"building":"yes"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-118.36797058582306,
33.81124046079714
],
[
-118.36797058582306,
33.81136971841298
],
[
-118.36779892444609,
33.81136971841298
],
[
-118.36779892444609,
33.81124046079714
],
[
-118.36797058582306,
33.81124046079714
]
]
]
}
},
"expectedResult":{

}
},
{
"Description":"This is a too large water body input that should not be caught",
"oldVersion": null,
"newVersion":{
"type":"Feature",
"properties":{
"natural":"water"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
-124.49707031249999,
37.19533058280065
],
[
-124.49707031249999,
41.04621681452063
],
[
-120.62988281249999,
41.04621681452063
],
[
-120.62988281249999,
37.19533058280065
],
[
-124.49707031249999,
37.19533058280065
]
]
]
}
},
"expectedResult":{

}
}
]
}

0 comments on commit 53fa4bc

Please sign in to comment.