Skip to content

Commit

Permalink
CLMS-3171-3170 (bug): missing or incomplete shapefiles show up as err…
Browse files Browse the repository at this point in the history
…or message in popup
  • Loading branch information
ujbolivar committed Apr 10, 2024
1 parent bfc6e19 commit 35eec0c
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/components/MapViewer/AreaWidget.jsx
Expand Up @@ -366,6 +366,23 @@ class AreaWidget extends React.Component {
//Check for more than a single feature
if (this.checkFeatureCount(response.data.featureCollection) === false)
return;
//Check that attributes and geometry are not null or undefined
if (
response.data.featureCollection.layers[0].featureSet.features[0]
.attributes === null ||
response.data.featureCollection.layers[0].featureSet.features[0]
.attributes === undefined ||
response.data.featureCollection.layers[0].featureSet.features[0]
.geometry === null ||
response.data.featureCollection.layers[0].featureSet.features[0]
.geometry === undefined
) {
this.setState({
showInfoPopup: true,
infoPopupType: 'invalidShapefile',
});
return;
}
//Create a feature layer from the feature collection
this.addFeatureCollectionToMap(response.data.featureCollection);
//console.log(data);
Expand All @@ -375,7 +392,18 @@ class AreaWidget extends React.Component {
}
})
.catch((error) => {
//console.error('Failed to generate feature collection:', error);
if (
error &&
error.details.httpStatus === 400 &&
error.message === 'Invalid Shapefile: missing shp file.'
) {
this.setState({
showInfoPopup: true,
infoPopupType: 'invalidShapefile',
});
} else {
// Handle other errors
}
});
}
// add the feature collection to the map and zoom to the feature collection extent
Expand Down Expand Up @@ -1244,6 +1272,16 @@ class AreaWidget extends React.Component {
</div>
</>
)}
{this.state.infoPopupType === 'invalidShapefile' && (
<>
<span className="drawRectanglePopup-icon">
<FontAwesomeIcon icon={['fas', 'info-circle']} />
</span>
<div className="drawRectanglePopup-text">
Invalid Shapefile: missing or incomplete shp file.
</div>
</>
)}
</div>
</div>
</div>
Expand Down

0 comments on commit 35eec0c

Please sign in to comment.