Categorygithub.com/qba73/rivers
modulepackage
0.1.1-alpha
Repository: https://github.com/qba73/rivers.git
Documentation: pkg.go.dev

# README

Go Go Report Card Maintainability Test Coverage

rivers

rivers is a Go library and a cli utility for reading water level and temperature data from stations located in rivers in Ireland. It allows to get data from more than 450 sensors located in 28 rivers.

Using the Go library

Import the library using:

import "github.com/qba73/rivers" 

Creating a client

Creat a new Client object by calling rivers.NewClient():

client := rivers.NewClient()

Retrieving latest water level redings

client.GetLatestWaterLevels()

or

rivers.GetLatestWaterLevels()

A complete example program

You can see an example programs which retrieves water level data in the examples/stations folder.

Bugs and feature requests

If you find a bug in the rivers client or library, please open an issue. Similarly, if you'd like a feature added or improved, let me know via an issue.

Not all the functionality of the water level is implemented yet.

Pull requests welcome!

Using the CLI utility for reading water levels

Get readings from stations (water level in millimeters):

$ waterlevel
[...]
time: 2022-07-04 00:15:00 +0000 UTC, station: Innisconnell Pier, id: 36084, level: 1152
time: 2022-07-04 09:30:00 +0000 UTC, station: Clonconwal, id: 38001, level: 619
time: 2022-07-04 09:30:00 +0000 UTC, station: Glenties, id: 38010, level: 810
time: 2022-07-03 11:30:00 +0000 UTC, station: New Mills, id: 39001, level: 210
time: 2022-07-04 09:30:00 +0000 UTC, station: Tullyarvan, id: 39003, level: 327
[...]

Save readings to a file:

$ waterlevel > levels.txt

Disclaimer

rivers project processes Irish Public Sector Information licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0), licence provided by the Office of Public Works. Data is licensed under the Creative Commons By Attribution (CC-BY) version 4.0 license - see summary. This is in line with Irish Government PER Circular 12 of 2016 and policy on Open Data data.gov.ie.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

GetLatestWaterLevels returns latests readings from all stations.
LoadWaterLevelCSV knows how to open and read given csv file.
NewClient knows how to construct a new default rivers client.
NewFileStore takes a path and creates a new file store.
No description provided by the author
NewSQLiteStore takes a path and creates a new SQLite store.
OpenReadingsRepo returns the repo reader with given implementation of the data store.
No description provided by the author
ReadWaterLevelCSV knows how to read a csv file containing readings from a gauge in a format: timestamp,level.
ReadWaterTemperatureCSV knows how to read a csv file containing readings from a gauge in a format: `timestamp,value`.
RunCLI executes program and prints out latest recorded water levels.
RunPuller holds all required machinery to run the water levels data puller.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

ErrNoReading is the error used for indicating that the given reading does not yet exist in the store.
ErrReadingExists is the error used for indicating attempt to enter a duplicated record to the store.

# Structs

Client holds data required to communicate with the web service.
FileStore represents a data store.
No description provided by the author
No description provided by the author
Sensor holds data from a station.
SensorReading represents data received from a sensor.
SQLiteStore represents a data store.
Station represents a station with multiple sensors.
No description provided by the author
StationWaterLevelReading represents data received from a water level sensor.
No description provided by the author
WaterLevel represents water level value recorded at the given time by the sensor installed in the station.
Reading represents water level recorded by a gauge at the particular time.
No description provided by the author

# Interfaces

Store is the interface that wraps Save, GetLastReadingForStationID and List methods.
WaterLevelProvider is the interface that wraps the GetLatestWaterLevels method.