Struct map_model::edits::MapEdits

source ·
pub struct MapEdits {
    pub edits_name: String,
    pub commands: Vec<EditCmd>,
    pub original_roads: BTreeMap<RoadID, EditRoad>,
    pub original_intersections: BTreeMap<IntersectionID, EditIntersection>,
    pub changed_routes: BTreeSet<TransitRouteID>,
    pub proposal_description: Vec<String>,
    pub proposal_link: Option<String>,
}
Expand description

Represents changes to a map. Note this isn’t serializable – that’s what PermanentMapEdits does.

Fields§

§edits_name: String§commands: Vec<EditCmd>

A stack, oldest edit is first. The same object may be edited multiple times in this stack, until compress() happens.

§original_roads: BTreeMap<RoadID, EditRoad>

Derived from commands, kept up to date by update_derived

§original_intersections: BTreeMap<IntersectionID, EditIntersection>§changed_routes: BTreeSet<TransitRouteID>§proposal_description: Vec<String>

Some edits are included in the game by default, in data/system/proposals, as “community proposals.” They require a description and may have a link to a write-up.

§proposal_link: Option<String>

Implementations§

source§

impl MapEdits

source

pub fn to_permanent(&self, map: &Map) -> PermanentMapEdits

Encode the edits in a permanent format, referring to more-stable OSM IDs.

source§

impl MapEdits

source

pub(crate) fn new() -> MapEdits

source

pub fn load_from_file( map: &Map, path: String, timer: &mut Timer<'_> ) -> Result<MapEdits>

Load map edits from a JSON file. Strip out any commands that’re broken because they don’t match the current map. If the resulting edits are totally empty, consider that a failure – the edits likely don’t cover this map at all.

source

pub fn load_from_bytes(map: &Map, bytes: Vec<u8>) -> Result<MapEdits>

Load map edits from the given JSON bytes. Strip out any commands that’re broken because they don’t match the current map. If the resulting edits are totally empty, consider that a failure – the edits likely don’t cover this map at all.

source

fn save(&self, map: &Map)

source

fn update_derived(&mut self, map: &Map)

source

pub fn compress(&mut self, map: &Map)

Assumes update_derived has been called.

source

pub fn changed_lanes(&self, map: &Map) -> (BTreeSet<LaneID>, BTreeSet<RoadID>)

Pick apart changed_roads and figure out if an entire road was edited, or just a few lanes. Doesn’t return deleted lanes.

source

pub fn get_checksum(&self, map: &Map) -> String

Produces an md5sum of the contents of the edits.

source

pub fn get_title(&self) -> &str

Get the human-friendly of these edits. If they have a description, the first line is the title. Otherwise we use the filename.

source

pub fn is_crossing_modified(&self, r: RoadID, crossing: &Crossing) -> bool

source

pub fn is_filter_modified(&self, r: RoadID, filter: &RoadFilter) -> bool

source

pub fn is_diagonal_filter_modified( &self, i: IntersectionID, filter: &DiagonalFilter ) -> bool

Trait Implementations§

source§

impl Clone for MapEdits

source§

fn clone(&self) -> MapEdits

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MapEdits

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MapEdits

source§

fn default() -> MapEdits

Returns the “default value” for a type. Read more
source§

impl PartialEq for MapEdits

source§

fn eq(&self, other: &MapEdits) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for MapEdits

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

§

fn is_within(&self, b: &G2) -> bool