Using the environment agency river level API
As a keen rower in York, our river level can vary dramatically. Therefore I've developed a plugin which pulls the river level from the environment agency and gives the club information on the river level's impact on whether they can row. This is a walkthrough of how this was done step by step and links to see it in action and the end result.
- 4 minutes read time
As a keen rower in York, our river level can vary dramatically. Therefore I’ve developed a plugin which pulls the river level from the environment agency and gives the club information on the river level’s impact on whether they can row.
The issue
I created a small link to the environment API to gather river level data and display on the club’s website. You can read more about why here.
The key bits of code
You can see the full code [here][codepen] which also shows the how we formatted the information.
Calling the API
If you’re wondering which key I used, it was this one.
Checking if the river is rising or falling
Inside we can do our first check on whether the level is rising or not.
Then we can play back the results.
Checking the height against the rules
Here we use a long but simple if / else statement to set variables of where the river is in relation to the bank and also what crews can go out on the water. (Note only some of the if statement is copied here).
Outcome
Here’s a screenshot of it from the YCRC website.
So what’s next?
Now the concept has been proved by showing the codepen results on the site, the next steps are to create a wordpress plugin, so that not only can it be easily amended by the club going forward, but it can also be used by other clubs.
Expect future posts when I tackle that!
The Archives