-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add missing toJsonFile helper * getBiggestPolygon: break out into helper function * change getBiggestPolygon to biggestPolygon * polygonSmokeTest simplify thrown error message * polygonSmokeTest: only log on ValidationError * polygonSmokeTest: tune logging * update preprocessing functions to use new global datasources (needs to be changed at end) * switch back to production global-datasources urls, update e2e tests * clipToGeography - increase test timeout
- Loading branch information
Showing
27 changed files
with
37,693 additions
and
33,869 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
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
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
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
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
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,22 @@ | ||
import { area, flatten } from "@turf/turf"; | ||
import { Feature, MultiPolygon, Polygon } from "geojson"; | ||
|
||
/** | ||
* If feature is a MultiPolygon, scans and returns the polygon with the largest area. | ||
*/ | ||
export function biggestPolygon(feature: Feature<Polygon | MultiPolygon>) { | ||
if (feature.geometry.type === "MultiPolygon") { | ||
// If multipolygon clip result, keep only the biggest piece | ||
const flattened = flatten(feature); | ||
let biggest = [0, 0]; | ||
for (let i = 0; i < flattened.features.length; i++) { | ||
const a = area(flattened.features[i]); | ||
if (a > biggest[0]) { | ||
biggest = [a, i]; | ||
} | ||
} | ||
return flattened.features[biggest[1]] as Feature<Polygon>; | ||
} else { | ||
return feature; | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.