This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from mapbox/large-building
compare function to catch large buildings
- Loading branch information
Showing
2 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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":{ | ||
|
||
} | ||
} | ||
] | ||
} |