map_model/objects/
parking_lot.rs1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5use abstutil::{deserialize_usize, serialize_usize};
6use geom::{Angle, Line, PolyLine, Polygon, Pt2D};
7
8use crate::{osm, Position};
9
10#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
14pub struct ParkingLotID(
15 #[serde(
16 serialize_with = "serialize_usize",
17 deserialize_with = "deserialize_usize"
18 )]
19 pub usize,
20);
21
22impl fmt::Display for ParkingLotID {
23 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24 write!(f, "Parking lot #{}", self.0)
25 }
26}
27
28#[derive(Clone, Serialize, Deserialize)]
30pub struct ParkingLot {
31 pub id: ParkingLotID,
32 pub polygon: Polygon,
33 pub aisles: Vec<Vec<Pt2D>>,
34 pub osm_id: osm::OsmID,
35 pub spots: Vec<(Pt2D, Angle)>,
37 pub extra_spots: usize,
40
41 pub driveway_line: PolyLine,
43 pub driving_pos: Position,
46
47 pub sidewalk_line: Line,
49 pub sidewalk_pos: Position,
50}
51
52impl ParkingLot {
53 pub fn capacity(&self) -> usize {
54 self.spots.len() + self.extra_spots
55 }
56}