Skip to content

Commit

Permalink
replace protobuf polygon type with local definition
Browse files Browse the repository at this point in the history
this is necessary so it can be documented, as it is in the public api
  • Loading branch information
intarga committed Oct 12, 2023
1 parent c20766d commit b333106
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/data_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,17 @@ pub struct Timerange {
}

/// Specifier of geographic position, by latitude and longitude
pub use crate::pb::GeoPoint;
pub struct GeoPoint {
/// latitude, in degrees
pub lat: f32,
/// longitude, in degrees
pub lon: f32,
}

/// A geospatial polygon
///
/// represented by its vertices as a sequence of lat-lon points
pub type Polygon = Vec<GeoPoint>;

/// Container of series data
pub struct SeriesCache {
Expand Down
13 changes: 11 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
dag::Dag,
data_switch::{DataSwitch, Timerange, Timestamp},
data_switch::{DataSwitch, GeoPoint, Polygon, Timerange, Timestamp},
pb::{
rove_server::{Rove, RoveServer},
ValidateSeriesRequest, ValidateSeriesResponse, ValidateSpatialRequest,
Expand Down Expand Up @@ -110,11 +110,20 @@ impl Rove for Scheduler<'static> {
let req = request.into_inner();
let req_len = req.tests.len();

let polygon: Polygon = req
.polygon
.into_iter()
.map(|point| GeoPoint {
lat: point.lat,
lon: point.lon,
})
.collect();

let mut rx = self
.validate_spatial_direct(
req.spatial_id,
req.tests,
req.polygon,
polygon,
Timestamp(
req.time
.as_ref()
Expand Down

0 comments on commit b333106

Please sign in to comment.