Skip to content

Commit

Permalink
sampling attributes: fixed generation (#3186)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
  • Loading branch information
SteRiccio and SteRiccio authored Dec 11, 2023
1 parent f4fa810 commit 1258abd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions common/analysis/samplingNodeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ const determinePlotAreaNodeDefs = ({ survey, chain }) => {
isEntityAreaNodeDef({ nodeDef: childDef, nodeDefParent })
)
const isBaseUnit = NodeDef.isEqual(nodeDefParent)(baseUnitNodeDef)
const existingNodeDef = isBaseUnit ? childDefs.find(isWeightNodeDef) : null
const hasAreaBasedDef = childDefs.some((childDef) => NodeDef.isAreaBasedEstimatedOf(childDef))
const hasAreaBasedDef = childDefs.some(NodeDef.isAreaBasedEstimatedOf)

if (hasAreaBasedDef || isBaseUnit) {
if (isBaseUnit) {
const existingNodeDef = childDefs.find(isWeightNodeDef)
// create new weight node def only for base unit entity
createAreaNodeDefIfNecessary({ existingNodeDef, nodeDefParent, isWeight: true })
} else if (hasAreaBasedDef) {
}
if (hasAreaBasedDef) {
// create new plot_area node def only if there is an area based node def
createAreaNodeDefIfNecessary({ existingNodeDef, nodeDefParent, isWeight: false })
createAreaNodeDefIfNecessary({ existingNodeDef: existingEntityAreaNodeDef, nodeDefParent, isWeight: false })
}
} else if (existingEntityAreaNodeDef) {
// delete entity area node defs when entity doesn't have any area based node def
Expand Down

0 comments on commit 1258abd

Please sign in to comment.