street_engine/transport/
rules.rs

1/// Rules to construct a path.
2#[derive(Debug, Clone, PartialEq)]
3pub struct TransportRules {
4    /// Priority to construct a path to this site.
5    pub path_priority: f64,
6
7    /// Elevation.
8    pub elevation: f64,
9    /// Population density.
10    pub population_density: f64,
11
12    /// Normal length of the path.
13    pub path_normal_length: f64,
14    /// Extra length of the path to search intersections.
15    pub path_extra_length_for_intersection: f64,
16
17    /// Probability of branching. If 1.0, the path will always create branch.
18    pub branch_rules: BranchRules,
19
20    /// Rules to determine the direction of the path.
21    pub path_direction_rules: PathDirectionRules,
22}
23
24/// Rules to create branches.
25///
26/// With `Default` values, the path will never create a branch.
27#[derive(Debug, Clone, PartialEq)]
28pub struct BranchRules {
29    /// Density of intersections (probability of branching). If 1.0, the path will always create intersection.
30    pub branch_density: f64,
31
32    /// Probability of staging.
33    pub staging_probability: f64,
34}
35
36impl Default for BranchRules {
37    fn default() -> Self {
38        Self {
39            branch_density: 0.0,
40            staging_probability: 0.0,
41        }
42    }
43}
44
45/// Rules to determine the direction of a path.
46///
47/// With `Default` values, the path is always constructed as a straight line.
48#[derive(Debug, Clone, PartialEq)]
49pub struct PathDirectionRules {
50    /// Maximum angle of curves.
51    pub max_radian: f64,
52    /// Number of candidates of the next site to create a path.
53    /// This parameter should be an odd number to evaluate the straight path.
54    pub comparison_step: usize,
55}
56
57impl Default for PathDirectionRules {
58    fn default() -> Self {
59        Self {
60            max_radian: 0.0,
61            comparison_step: 1,
62        }
63    }
64}