ua-snap / ardac-explorer

ARDAC GUI Explorer
0 stars 0 forks source link

Validate lat/lon input and community autocomplete against extent from corresponding GeoJSON file #112

Closed cstephen closed 3 months ago

cstephen commented 3 months ago

Closes #47.

This PR solves #47, but using GeoJSON files + Turf.js instead of BBOXes to determine if a lat/lon point or community falls within the data extent. This approach is much more accurate because the extent of our data tends to be very irregular, not rectangular.

Currently, the five possible GeoJSON files used for validation and their corresponding ARDAC datasets are:

Alaska GeoJSON

"Blocky Alaska" GeoJSON (includes more panhandle communities, including Juneau)

"Mizukami" GeoJSON (named after the primary author of the citation from which these datasets were derived)

Elevation GeoJSON

Ocean GeoJSON

CMIP6 indicator items do not use GeoJSON point validation since these datasets can cover both land & sea and are not confined to political boundaries.

An additional extent Gimme component prop and Extent TypeScript type have been implemented, and the Gimme component uses these to load the corresponding GeoJSON file dynamically.

To test, load the app and view any map+chart/table ARDAC item. Try typing a community name into the Gimme widget and observe that only communities that fall within the data footprint are autocompleted. Also, if you happen to enter a lat/lon point that is within the BBOX but outside the irregularly-shaped data extent, it will show you a new error under the input box:

⚠️ This point is outside the data extent.