diff --git a/config.py b/config.py index 1c16eca0..627ad8a1 100644 --- a/config.py +++ b/config.py @@ -9,7 +9,7 @@ WEST_BBOX = [-180, 51.3492, -122.8098, 71.3694] EAST_BBOX = [172.4201, 51.3492, 180, 71.3694] SEAICE_BBOX = [-180, 30.98, 180, 90] -INDICATORS_BBOX = [0, 49.94, 359.37, 90] +CMIP6_BBOX = [-180, 49.95, 180, 90] WEB_APP_URL = os.getenv("WEB_APP_URL") or "https://northernclimatereports.org/" if os.getenv("SITE_OFFLINE"): diff --git a/routes/cmip6.py b/routes/cmip6.py index 2b3653dc..f627d24f 100644 --- a/routes/cmip6.py +++ b/routes/cmip6.py @@ -11,7 +11,7 @@ from postprocessing import postprocess, prune_nulls_with_max_intensity from csv_functions import create_csv from . import routes -from config import WEST_BBOX, EAST_BBOX +from config import CMIP6_BBOX cmip6_api = Blueprint("cmip6_api", __name__) @@ -127,14 +127,12 @@ def run_fetch_cmip6_monthly_point_data(lat, lon): example request: http://localhost:5000/cmip6/point/65.06/-146.16?vars=tas,pr """ # Validate the lat/lon values - validation = validate_latlon(lat, lon) + validation = validate_latlon(lat, lon, CMIP6_BBOX) if validation == 400: return render_template("400/bad_request.html"), 400 if validation == 422: return ( - render_template( - "422/invalid_latlon.html", west_bbox=WEST_BBOX, east_bbox=EAST_BBOX - ), + render_template("422/invalid_cmip6_latlon.html", bbox=CMIP6_BBOX), 422, ) try: diff --git a/routes/indicators.py b/routes/indicators.py index 9b3de3e4..5558787b 100644 --- a/routes/indicators.py +++ b/routes/indicators.py @@ -29,7 +29,7 @@ from postprocessing import nullify_and_prune, postprocess from csv_functions import create_csv from . import routes -from config import WEST_BBOX, EAST_BBOX +from config import WEST_BBOX, EAST_BBOX, CMIP6_BBOX indicators_api = Blueprint("indicators_api", __name__) # Rasdaman targets @@ -329,14 +329,12 @@ def run_fetch_cmip6_indicators_point_data(lat, lon): """ # Validate the lat/lon values - validation = validate_latlon(lat, lon) + validation = validate_latlon(lat, lon, CMIP6_BBOX) if validation == 400: return render_template("400/bad_request.html"), 400 if validation == 422: return ( - render_template( - "422/invalid_latlon.html", west_bbox=WEST_BBOX, east_bbox=EAST_BBOX - ), + render_template("422/invalid_cmip6_latlon.html", bbox=CMIP6_BBOX), 422, ) try: diff --git a/templates/422/invalid_cmip6_latlon.html b/templates/422/invalid_cmip6_latlon.html new file mode 100644 index 00000000..fe9e63fd --- /dev/null +++ b/templates/422/invalid_cmip6_latlon.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} +{% block content %} +
+ Provided coordinates are outside of the valid range. Coordinates must be + within the following bounding box: +
+
+ Latitude: {{ bbox[1] }}
to {{ bbox[3] }}
+
+ Longitude: {{ bbox[0] }}
to {{ bbox[2] }}
+