use std::fmt;
use serde::{Deserialize, Serialize};
use abstutil::{deserialize_usize, serialize_usize};
use geom::{Angle, Line, PolyLine, Polygon, Pt2D};
use crate::{osm, Position};
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub struct ParkingLotID(
#[serde(
serialize_with = "serialize_usize",
deserialize_with = "deserialize_usize"
)]
pub usize,
);
impl fmt::Display for ParkingLotID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Parking lot #{}", self.0)
}
}
#[derive(Clone, Serialize, Deserialize)]
pub struct ParkingLot {
pub id: ParkingLotID,
pub polygon: Polygon,
pub aisles: Vec<Vec<Pt2D>>,
pub osm_id: osm::OsmID,
pub spots: Vec<(Pt2D, Angle)>,
pub extra_spots: usize,
pub driveway_line: PolyLine,
pub driving_pos: Position,
pub sidewalk_line: Line,
pub sidewalk_pos: Position,
}
impl ParkingLot {
pub fn capacity(&self) -> usize {
self.spots.len() + self.extra_spots
}
}