6 releases
0.5.2 | May 20, 2024 |
---|---|
0.5.1 | May 18, 2024 |
0.4.0 | May 12, 2024 |
0.3.3 | May 8, 2024 |
#134 in Geospatial
312 downloads per month
135KB
374 lines
ralertsinua-geo
Rust async API wrapper (reqwest) & TUI (ratatui) for alerts.in.ua
Introduction
The Alerts.in.ua API Client is a Rust library that simplifies access to the alerts.in.ua API service. It provides real-time information about air raid alerts and other potential threats.
Installation
To install the Alerts.in.ua API Client, run the following command in your terminal:
cargo add ralertsinua-geo
Usage
⚠️ Before you can use this library, you need to obtain an API token by submitting an API request form.
Here's an basic example of how to use the library to get a list of active alerts:
Async:
use ralertsinua_geo::AlertsInUaGeo;
// Initialize the client
geo_client = AlertsInUaGeo();
/// The API for the AlertsInUaClient
pub trait AlertsInUaGeo: WithBoundingRect + Sync + Send + core::fmt::Debug {
fn boundary(&self) -> CountryBoundary;
fn locations(&self) -> [Location; 27];
fn get_location_by_uid(&self, uid: i32) -> Option<Location>;
fn get_location_by_name(&self, name: &str) -> Option<Location>;
}
Location
The Location
struct represents a Ukraine's administrative unit lv4
/// Ukraine's administrative unit lv4 - *oblast*
#[derive(Debug, Deserialize, Clone, PartialEq, Serialize)]
pub struct Location {
/// OSM Relation Id
pub relation_id: String,
/// Alerts.in.ua "uid"
pub location_uid: i32,
/// "state" or "city" or "special"
pub location_type: String,
/// Geometry for boundary (Polygon or MultiPolygon)
pub geometry: Geometry,
/// Name in uk
pub name: String,
/// Name in en
pub name_en: String,
/// And some functions from traits
fn geometry(&self) -> &Geometry;
fn boundary(&self) -> &Polygon;
fn center(&self) -> (f64, f64);
/// To be used in TUI when , implements `Shape`
fn draw(&self, painter: &mut Painter);
License
MIT 2024
*[TUI]: Terminal User Interface
Dependencies
~12–19MB
~221K SLoC