Skip to content

Commit

Permalink
Merge pull request #2958 from bcgov/batch_geo_unclosed_rings
Browse files Browse the repository at this point in the history
geo validation for batch update
  • Loading branch information
micheal-w-wells authored Nov 2, 2023
2 parents 2b56e0f + e33996d commit 6d11435
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/src/utils/batch/validation/spatial-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ export const autofillFromPostGIS = async (input: string, inputArea?: number): Pr
area: res.rows[0]['area'],
geog: res.rows[0]['geog']
};
} finally {

}
catch(e) {

console.log('error in autofillFromPostGIS', e)
throw new Error('Error validating geometry in the database' + e.message );

}finally {
connection.release();
}
};
Expand Down
11 changes: 11 additions & 0 deletions api/src/utils/batch/validation/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ async function _validateCell(
//@todo validate length
break;
case 'WKT':
try {

// validate if not polygon first to avoid WKT autofill and subsequent crashes
const shape = data.split(' (')[0];
if (shape !== 'POLYGON' && shape !== 'MULTIPOLYGON' && !template.key.includes('temp')) {
Expand Down Expand Up @@ -384,6 +386,15 @@ async function _validateCell(
messageTitle: `Area cannot be larger than ${lookupAreaLimit(template.subtype)}`
});
}
}
catch(e)
{
result.validationMessages.push({
severity: 'error',
messageTitle: 'Unhandled geometry error for cell',
messageDetail: e.message || e.messageDetail || e
});
}

break;
case 'tristate':
Expand Down

0 comments on commit 6d11435

Please sign in to comment.