Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/router/FareZones.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file FareZones.h
15
/// @author Ricardo Euler
16
/// @date Thu, 17 August 2018
17
///
18
// Fare Modul for calculating prices during intermodal routing
19
/****************************************************************************/
20
21
#pragma once
22
#include <config.h>
23
24
#include <unordered_map>
25
#include <cstdint>
26
27
static std::unordered_map<long long int, int> repToFareZone = std::unordered_map<long long int, int> {
28
{1, 110},
29
{2, 121},
30
{4, 122},
31
{8, 123},
32
{16, 124},
33
{32, 125},
34
{64, 126},
35
{128, 127},
36
{256, 128},
37
{512, 129},
38
{1024, 131},
39
{2048, 132},
40
{4096, 133},
41
{8192, 134},
42
{16384, 141},
43
{32768, 142},
44
{65536, 143},
45
{131072, 144},
46
{262144, 145},
47
{524288, 146},
48
{1048576, 147},
49
{2097152, 151},
50
{4194304, 152},
51
{8388608, 153},
52
{16777216, 154},
53
{33554432, 155},
54
{67108864, 156},
55
{134217728, 162},
56
{268435456, 163},
57
{536870912, 164},
58
{1073741824, 165},
59
{2147483648, 166},
60
{4294967296, 167},
61
{8589934592, 168},
62
{17179869184, 210},
63
{34359738368, 221},
64
{68719476736, 222},
65
{137438953472, 223},
66
{274877906944, 224},
67
{549755813888, 225},
68
{1099511627776, 231},
69
{2199023255552, 232},
70
{4398046511104, 233},
71
{8796093022208, 234},
72
{17592186044416, 241},
73
{35184372088832, 242},
74
{70368744177664, 243},
75
{140737488355328, 251},
76
{281474976710656, 252},
77
{562949953421312, 253},
78
{1125899906842624, 254},
79
{2251799813685248, 255},
80
{4503599627370496, 256},
81
{9007199254740992, 257},
82
{18014398509481984, 258},
83
{36028797018963968, 259},
84
{72057594037927936, 261},
85
{144115188075855872, 299},
86
{288230376151711744, 321},
87
{576460752303423488, 322},
88
{1152921504606846976, 323},
89
{2305843009213693952, 324}
90
};
91
92
static std::unordered_map<int, long long int> fareZoneToRep = std::unordered_map<int, long long int > {
93
{110, 1 },
94
{121, 2 },
95
{122, 4 },
96
{123, 8 },
97
{124, 16 },
98
{125, 32 },
99
{126, 64 },
100
{127, 128 },
101
{128, 256 },
102
{129, 512 },
103
{131, 1024 },
104
{132, 2048 },
105
{133, 4096 },
106
{134, 8192 },
107
{141, 16384 },
108
{142, 32768 },
109
{143, 65536 },
110
{144, 131072 },
111
{145, 262144 },
112
{146, 524288 },
113
{147, 1048576 },
114
{151, 2097152 },
115
{152, 4194304 },
116
{153, 8388608 },
117
{154, 16777216 },
118
{155, 33554432 },
119
{156, 67108864 },
120
{162, 134217728 },
121
{163, 268435456 },
122
{164, 536870912 },
123
{165, 1073741824 },
124
{166, 2147483648 },
125
{167, 4294967296 },
126
{168, 8589934592 },
127
{210, 17179869184 },
128
{221, 34359738368 },
129
{222, 68719476736 },
130
{223, 137438953472 },
131
{224, 274877906944 },
132
{225, 549755813888 },
133
{231, 1099511627776 },
134
{232, 2199023255552 },
135
{233, 4398046511104 },
136
{234, 8796093022208 },
137
{241, 17592186044416 },
138
{242, 35184372088832 },
139
{243, 70368744177664 },
140
{251, 140737488355328 },
141
{252, 281474976710656 },
142
{253, 562949953421312 },
143
{254, 1125899906842624 },
144
{255, 2251799813685248 },
145
{256, 4503599627370496 },
146
{257, 9007199254740992 },
147
{258, 18014398509481984 },
148
{259, 36028797018963968 },
149
{261, 72057594037927936 },
150
{299, 144115188075855872 },
151
{321, 288230376151711744 },
152
{322, 576460752303423488 },
153
{323, 1152921504606846976 },
154
{324, 2305843009213693952 }
155
};
156
157
/**
158
* Returns the zone the specified lower rank zones is a part of
159
* @return
160
*/
161
162
inline int getOverlayZone(int zoneNumber) {
163
if (zoneNumber < 400) {
164
return zoneNumber; //real "zone" numbers, no city zones
165
}
166
167
switch (zoneNumber) {
168
case 511:
169
return 165;
170
case 512:
171
return 166;
172
case 513:
173
return 167;
174
case 514:
175
return 142;
176
case 515:
177
return 123;
178
case 516:
179
return 127;
180
case 518:
181
return 145;
182
case 519:
183
return 144;
184
case 521:
185
return 153;
186
case 551:
187
return 231;
188
case 552:
189
return 232;
190
case 553:
191
return 233;
192
case 554:
193
return 259;
194
case 555:
195
return 241;
196
case 556:
197
return 255;
198
case 571:
199
return 322;
200
case 572:
201
return 324;
202
default:
203
return zoneNumber;
204
}
205
}
206
207