Skip to content

Commit

Permalink
Merge pull request #763 from CanalTP/object-properties-btreemap
Browse files Browse the repository at this point in the history
[features] object_properties are a BTreeMap instead of BTreeSet
  • Loading branch information
patochectp committed May 7, 2021
2 parents c61f997 + 6eaa42e commit 0c37fe3
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Kisio Digital <team.coretools@kisio.com>", "Guillaume Pinot <texitoi@texitoi.eu>"]
name = "transit_model"
version = "0.35.1"
version = "0.36.0"
license = "AGPL-3.0-only"
description = "Transit data management"
repository = "https://github.com/CanalTP/transit_model"
Expand Down
2 changes: 1 addition & 1 deletion gtfs2netexfr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../", features = ["proj"] }
transit_model = { version = "0.36", path = "../", features = ["proj"] }
lazy_static = "1"
2 changes: 1 addition & 1 deletion gtfs2ntfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../" }
transit_model = { version = "0.36", path = "../" }
lazy_static = "1"
2 changes: 1 addition & 1 deletion ntfs2gtfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../" }
transit_model = { version = "0.36", path = "../" }
lazy_static = "1"
2 changes: 1 addition & 1 deletion ntfs2netexfr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../", features = ["proj"] }
transit_model = { version = "0.36", path = "../", features = ["proj"] }
lazy_static = "1"
2 changes: 1 addition & 1 deletion ntfs2ntfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../" }
transit_model = { version = "0.36", path = "../" }
lazy_static = "1"
2 changes: 1 addition & 1 deletion restrict-validity-period/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.35", path = "../" }
transit_model = { version = "0.36", path = "../" }
13 changes: 7 additions & 6 deletions src/gtfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use super::{
use crate::{
model::Collections,
objects::{
self, Availability, CommentLinksT, Coord, KeysValues, Pathway, StopLocation, StopPoint,
StopTime as NtfsStopTime, StopTimePrecision, StopType, Time, TransportType, VehicleJourney,
self, Availability, CommentLinksT, Coord, KeysValues, Pathway, PropertiesMap, StopLocation,
StopPoint, StopTime as NtfsStopTime, StopTimePrecision, StopType, Time, TransportType,
VehicleJourney,
},
read_utils::{read_collection, read_objects, read_objects_loose, FileHandler},
utils::*,
Expand Down Expand Up @@ -104,7 +105,7 @@ impl TryFrom<Stop> for objects::StopArea {
id: stop.id,
name: stop.name,
codes,
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: objects::CommentLinksT::default(),
coord,
timezone: stop.timezone,
Expand Down Expand Up @@ -309,7 +310,7 @@ impl Trip {
Ok(objects::VehicleJourney {
id: self.id.clone(),
codes,
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: route.get_id_by_direction(self.direction),
physical_mode_id: physical_mode.id,
Expand Down Expand Up @@ -993,7 +994,7 @@ fn make_lines(
id: r.id.clone(),
code: line_code(r),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
name: r.long_name.to_string(),
forward_name: None,
Expand Down Expand Up @@ -1049,7 +1050,7 @@ fn make_routes(gtfs_trips: &[Trip], map_line_routes: &MapLineRoutes<'_>) -> Vec<
},
direction_type: Some(get_direction_name(d)),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
line_id: sr.id.clone(),
geometry_id: None,
Expand Down
19 changes: 8 additions & 11 deletions src/gtfs/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,7 @@ mod tests {
calendars::write_calendar_dates,
gtfs::{Route, RouteType, StopLocationType, Transfer, TransferType},
model::Collections,
objects::{
Calendar, CommentLinksT, Coord, KeysValues, StopPoint, StopTime,
Transfer as NtfsTransfer,
},
objects::{Calendar, CommentLinksT, Coord, StopPoint, StopTime, Transfer as NtfsTransfer},
};
use geo::{line_string, point};
use pretty_assertions::assert_eq;
Expand Down Expand Up @@ -768,7 +765,7 @@ mod tests {
]
.into_iter()
.collect(),
object_properties: BTreeSet::default(),
object_properties: PropertiesMap::default(),
comment_links,
visible: true,
coord: objects::Coord {
Expand Down Expand Up @@ -914,7 +911,7 @@ mod tests {
let vj = objects::VehicleJourney {
id: "OIF:87604986-1_11595-1".to_string(),
codes: BTreeSet::default(),
object_properties: BTreeSet::default(),
object_properties: PropertiesMap::default(),
comment_links: BTreeSet::default(),
route_id: "OIF:078078001:1".to_string(),
physical_mode_id: "Bus".to_string(),
Expand Down Expand Up @@ -959,7 +956,7 @@ mod tests {
let vj_coach = objects::VehicleJourney {
id: "OIF:87604986-1_11595-1:Coach".to_string(),
codes: BTreeSet::default(),
object_properties: BTreeSet::default(),
object_properties: PropertiesMap::default(),
comment_links: BTreeSet::default(),
route_id: "OIF:078078001:1".to_string(),
physical_mode_id: "Coach".to_string(),
Expand Down Expand Up @@ -1031,7 +1028,7 @@ mod tests {
id: "sa:01".to_string(),
name: "sa:01".to_string(),
codes: sa_codes,
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
visible: true,
coord: Coord {
Expand Down Expand Up @@ -1231,7 +1228,7 @@ mod tests {
let vehicle_journeys = CollectionWithId::from(VehicleJourney {
id: "vj:01".to_string(),
codes: BTreeSet::new(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: "r:01".to_string(),
physical_mode_id: "pm:01".to_string(),
Expand Down Expand Up @@ -1305,7 +1302,7 @@ mod tests {
name: "3".to_string(),
code: None,
codes: BTreeSet::default(),
object_properties: BTreeSet::default(),
object_properties: PropertiesMap::default(),
comment_links: BTreeSet::default(),
forward_name: None,
forward_direction: None,
Expand Down Expand Up @@ -1353,7 +1350,7 @@ mod tests {
name: "DEF".to_string(),
code: Some("DEF".to_string()),
codes: BTreeSet::default(),
object_properties: BTreeSet::default(),
object_properties: PropertiesMap::default(),
comment_links: BTreeSet::default(),
forward_name: Some("Hôtels - Hôtels".to_string()),
forward_direction: Some("OIF:SA:4:126".to_string()),
Expand Down
2 changes: 1 addition & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ mod tests {
VehicleJourney {
id: String::from(trip_id),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: String::from("route_id"),
physical_mode_id: String::new(),
Expand Down
4 changes: 2 additions & 2 deletions src/netex_france/route_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ mod tests {

mod build_route_points {
use super::*;
use crate::objects::{CommentLinksT, KeysValues, StopTime, Time};
use crate::objects::{CommentLinksT, KeysValues, PropertiesMap, StopTime, Time};
use pretty_assertions::assert_eq;

fn stop_time(
Expand All @@ -126,7 +126,7 @@ mod tests {
VehicleJourney {
id,
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: String::from("route_id"),
physical_mode_id: String::from("Bus"),
Expand Down
46 changes: 23 additions & 23 deletions src/ntfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ mod tests {
name: "DEF".to_string(),
code: Some("DEF".to_string()),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
forward_name: Some("Hôtels - Hôtels".to_string()),
forward_direction: None,
Expand Down Expand Up @@ -575,7 +575,7 @@ mod tests {
name: "3".to_string(),
code: None,
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
forward_name: None,
forward_direction: None,
Expand Down Expand Up @@ -622,7 +622,7 @@ mod tests {
name: "Hôtels - Hôtels".to_string(),
direction_type: Some("forward".to_string()),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
line_id: "OIF:002002002:BDEOIF829".to_string(),
geometry_id: Some("Geometry:Line:Relation:6883353".to_string()),
Expand All @@ -633,7 +633,7 @@ mod tests {
name: "Hôtels - Hôtels".to_string(),
direction_type: None,
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
line_id: "OIF:002002002:BDEOIF829".to_string(),
geometry_id: None,
Expand Down Expand Up @@ -678,7 +678,7 @@ mod tests {
VehicleJourney {
id: "OIF:87604986-1_11595-1".to_string(),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: "OIF:078078001:1".to_string(),
physical_mode_id: "Bus".to_string(),
Expand Down Expand Up @@ -723,7 +723,7 @@ mod tests {
VehicleJourney {
id: "OIF:90014407-1_425283-1".to_string(),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
route_id: "OIF:800:TER".to_string(),
physical_mode_id: "Bus".to_string(),
Expand Down Expand Up @@ -953,7 +953,7 @@ mod tests {
id: "Navitia:sa_2".to_string(),
name: "sa_name_2".to_string(),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
visible: true,
coord: Coord {
Expand All @@ -969,7 +969,7 @@ mod tests {
id: "sa_1".to_string(),
name: "sa_name_1".to_string(),
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
visible: true,
coord: Coord {
Expand Down Expand Up @@ -1033,10 +1033,10 @@ mod tests {
"object_system:1".to_string(),
"object_code:1".to_string(),
)]),
object_properties: btree_set_from_vec(vec![(
object_properties: properties_map![(
"prop_name:1".to_string(),
"prop_value:1".to_string(),
)]),
"prop_value:1".to_string()
)],
comment_links: btree_set_from_vec(vec!["c:1".to_string()]),
visible: true,
coord: Coord {
Expand All @@ -1055,10 +1055,10 @@ mod tests {
"object_system:2".to_string(),
"object_code:2".to_string(),
)]),
object_properties: btree_set_from_vec(vec![(
object_properties: properties_map![(
"prop_name:2".to_string(),
"prop_value:2".to_string(),
)]),
"prop_value:2".to_string()
)],
comment_links: btree_set_from_vec(vec!["c:2".to_string()]),
visible: true,
coord: Coord {
Expand All @@ -1081,10 +1081,10 @@ mod tests {
"object_system:3".to_string(),
"object_code:3".to_string(),
)]),
object_properties: btree_set_from_vec(vec![(
object_properties: properties_map![(
"prop_name:3".to_string(),
"prop_value:3".to_string(),
)]),
"prop_value:3".to_string()
)],
comment_links: btree_set_from_vec(vec!["c:1".to_string(), "c:2".to_string()]),
forward_name: None,
forward_direction: None,
Expand All @@ -1108,10 +1108,10 @@ mod tests {
("object_system:4".to_string(), "object_code:4".to_string()),
("object_system:5".to_string(), "object_code:5".to_string()),
]),
object_properties: btree_set_from_vec(vec![(
object_properties: properties_map![(
"prop_name:4".to_string(),
"prop_value:4".to_string(),
)]),
"prop_value:4".to_string()
)],
comment_links: btree_set_from_vec(vec!["c:3".to_string()]),
line_id: "OIF:002002002:BDEOIF829".to_string(),
geometry_id: None,
Expand All @@ -1124,10 +1124,10 @@ mod tests {
"object_system:6".to_string(),
"object_code:6".to_string(),
)]),
object_properties: btree_set_from_vec(vec![(
object_properties: properties_map![(
"prop_name:6".to_string(),
"prop_value:6".to_string(),
)]),
"prop_value:6".to_string()
)],
comment_links: CommentLinksT::default(),
route_id: "OIF:800:TER".to_string(),
physical_mode_id: "Bus".to_string(),
Expand Down
6 changes: 3 additions & 3 deletions src/ntfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl TryFrom<Stop> for StopArea {
id: stop.id,
name: stop.name,
codes: KeysValues::default(),
object_properties: KeysValues::default(),
object_properties: PropertiesMap::default(),
comment_links: CommentLinksT::default(),
visible: stop.visible,
coord,
Expand Down Expand Up @@ -556,10 +556,10 @@ where
return;
}
};
collection.index_mut(idx).properties_mut().insert((
collection.index_mut(idx).properties_mut().insert(
obj_prop.object_property_name,
obj_prop.object_property_value,
));
);
}

pub(crate) fn manage_object_properties<H>(
Expand Down
Loading

0 comments on commit 0c37fe3

Please sign in to comment.