transit_model/lib.rs
1// Copyright (C) 2017 Hove and/or its affiliates.
2//
3// This program is free software: you can redistribute it and/or modify it
4// under the terms of the GNU Affero General Public License as published by the
5// Free Software Foundation, version 3.
6
7// This program is distributed in the hope that it will be useful, but WITHOUT
8// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10// details.
11
12// You should have received a copy of the GNU Affero General Public License
13// along with this program. If not, see <https://www.gnu.org/licenses/>
14
15//! The `transit_model` crate proposes a model to manage transit data.
16//! It can import and export data from
17//! [GTFS](https://gtfs.org/reference/static) and
18//! [NTFS](https://github.com/hove-io/ntfs-specification/blob/master/ntfs_fr.md).
19//!
20//! # Features
21//! `transit_model` has 2 possible features: `proj` and `xmllint`.
22//!
23//! ## `proj`
24//! `proj` feature is used for geolocation conversion (see
25//! [Proj]). `proj` feature is used, for example, to export NeTEx France format.
26//!
27//! [Proj]: https://proj.org
28//!
29//! ## `xmllint`
30//! Most likely, you don't need this feature as it's only used for additional
31//! tests. It doesn't add any functionality to `transit_model`. If you're a
32//! contributor to the project, you might be interested to run these tests. In
33//! this case, take a look at the [`CONTRIBUTING.md`] for more information on
34//! this feature.
35//!
36//! ## `gtfs`
37//! This is an experimental feature that exposes some gtfs functions for use
38//! in external projects
39//!
40//! ## `parser`
41//! Some utilities to turn csv files into vector of objects or CollectionWithId (See
42//! https://github.com/hove-io/typed_index_collection/)
43//!
44//! [`CONTRIBUTING.md`]: https://github.com/hove-io/transit_model/blob/master/CONTRIBUTING.md
45
46#![deny(missing_docs)]
47
48#[macro_use]
49mod utils;
50mod add_prefix;
51pub mod serde_utils;
52pub use add_prefix::{AddPrefix, PrefixConfiguration};
53pub mod calendars;
54#[macro_use]
55pub mod objects;
56pub mod configuration;
57mod enhancers;
58#[cfg(not(feature = "parser"))]
59pub(crate) mod file_handler;
60#[cfg(feature = "parser")]
61pub mod file_handler;
62pub mod gtfs;
63pub mod model;
64#[cfg(feature = "proj")]
65pub mod netex_france;
66pub mod netex_utils;
67pub mod ntfs;
68#[cfg(not(feature = "parser"))]
69pub(crate) mod parser;
70#[cfg(feature = "parser")]
71pub mod parser;
72#[doc(hidden)]
73pub mod test_utils;
74pub mod transfers;
75pub mod validity_period;
76mod version_utils;
77pub mod vptranslator;
78
79// Good average size for initialization of the `StopTime` collection in `VehicleJourney`
80// Note: they are shrinked down in `Model::new()` to fit the real size
81pub(crate) const STOP_TIMES_INIT_CAPACITY: usize = 50;
82
83/// Current version of the NTFS format
84pub const NTFS_VERSION: &str = "0.13.0";
85
86/// The max distance in meters to compute the transfer
87pub const TRANSFER_MAX_DISTANCE: &str = "300";
88
89/// The walking speed in meters per second
90pub const TRANSFER_WALKING_SPEED: &str = "0.785";
91
92/// Waiting time at stop in second
93pub const TRANSFER_WAITING_TIME: &str = "60";
94
95lazy_static::lazy_static! {
96 /// Current datetime
97 pub static ref CURRENT_DATETIME: String = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
98}
99
100/// The error type used by the crate.
101pub type Error = anyhow::Error;
102
103/// The corresponding result type used by the crate.
104pub type Result<T, E = Error> = std::result::Result<T, E>;
105
106pub use crate::model::Model;
107
108pub use crate::version_utils::{binary_full_version, GIT_VERSION};