Skip to content

Commit

Permalink
filter out feature amounts per PU rows where amount is not a positive…
Browse files Browse the repository at this point in the history
… number [MRXNM-43]

Reason: the Marxan solver will show unexpected behaviour when it sees
`puvspr.dat` rows with amount = 0.
  • Loading branch information
hotzevzl committed Apr 23, 2024
1 parent eaf7a07 commit e7ced45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export class MemoryFeatureAmountsPerPlanningUnitRepository

if (!featureAmountsPerPlanningUnit) return [];

return featureAmountsPerPlanningUnit.filter(({ featureId }) =>
featureIds.includes(featureId),
return (
featureAmountsPerPlanningUnit
.filter(({ featureId }) => featureIds.includes(featureId))
/** The Marxan solver will show unexpected behaviour when seeing
* puvspr.dat rows with amount = 0 */
.filter(({ amount }) => amount > 0)
);
}
async saveAmountPerPlanningUnitAndFeature(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export class TypeormFeatureAmountsPerPlanningUnitRepository
.from(FeatureAmountsPerPlanningUnitEntity, 'fappu')
.where('project_id = :projectId', { projectId })
.andWhere('feature_id IN (:...featureIds)', { featureIds })
/** The Marxan solver will show unexpected behaviour when seeing
* puvspr.dat rows with amount = 0 */
.andWhere('amount > 0')
.execute();
}

Expand Down

0 comments on commit e7ced45

Please sign in to comment.