Add methods to get geojson from a point

This commit is contained in:
Dustin Carlino 2022-08-01 14:43:20 +01:00
parent c2e243e4ce
commit 5722c67011
2 changed files with 12 additions and 0 deletions

View File

@ -181,6 +181,10 @@ impl LonLat {
}
Ok(polygons)
}
pub fn to_geojson(self) -> geojson::Geometry {
geojson::Geometry::new(geojson::Value::Point(vec![self.x(), self.y()]))
}
}
impl fmt::Display for LonLat {

View File

@ -142,6 +142,14 @@ impl Pt2D {
.map(|pt| pt.into())
.collect()
}
pub fn to_geojson(self, gps: Option<&GPSBounds>) -> geojson::Geometry {
if let Some(gps) = gps {
self.to_gps(gps).to_geojson()
} else {
geojson::Geometry::new(geojson::Value::Point(vec![self.x(), self.y()]))
}
}
}
impl fmt::Display for Pt2D {