Skip to content

Commit

Permalink
fix: group only by main and other
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Apr 28, 2020
1 parent 444a489 commit 247880e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/src/locate.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,21 @@ function locate(location = {}) {
(ft) => intersection(ft.slope, location.slopes).length > 0,
);
}
if (location.groups) {
forestTypes = forestTypes.filter((ft) =>
location.groups.some((g) => ft.group[g]),
);
}
const allForestTypes = forestTypes.map((ft) => ft.code);
const byForestTypes = (item) =>
intersection(item.forestTypes, allForestTypes).length > 0;

options.indicator = types.indicator.filter(byForestTypes).map((i) => i.code);
options.treeType = types.treeType.filter(byForestTypes).map((tt) => tt.code);

const forestTypesByGroup = (group) =>
!location.groups || location.groups.includes(group)
? forestTypes.filter((ft) => ft.group[group]).map((ft) => ft.code)
: [];

forestTypes = {
main: forestTypesByGroup('main'),
pioneer: forestTypesByGroup('pioneer'),
special: forestTypesByGroup('special'),
volatile: forestTypesByGroup('volatile'),
riverside: forestTypesByGroup('riverside'),
main: forestTypes.filter((ft) => ft.group.main).map((ft) => ft.code),
other: forestTypes.filter((ft) => !ft.group.main).map((ft) => ft.code),
};
if (ecogram && (!location.groups || location.groups.includes('main'))) {
ecogram = ecogram.map((e) => {
Expand Down

0 comments on commit 247880e

Please sign in to comment.