mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
Add methods to get geojson from a point
This commit is contained in:
parent
c2e243e4ce
commit
5722c67011
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user