8000 European toll fallback rules (#2450) · graphhopper/graphhopper@677b10a · GitHub
[go: up one dir, main page]

Skip to content

Commit 677b10a

Browse files
otbutzThomas Butz
and
Thomas Butz
authored
European toll fallback rules (#2450)
Co-authored-by: Thomas Butz <thomas.butz@optitool.de>
1 parent 8e8f21e commit 677b10a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1879
-9
lines changed

core/src/main/java/com/graphhopper/routing/util/countryrules/CountryRule.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ default RoadAccess getAccess(ReaderWay readerWay, TransportationMode transportat
3535
return currentRoadAccess;
3636
}
3737

38-
default Toll getToll(ReaderWay readerWay, TransportationMode transportationMode, Toll currentToll) {
38+
default Toll getToll(ReaderWay readerWay, Toll currentToll) {
3939
return currentToll;
4040
}
4141
}

core/src/main/java/com/graphhopper/routing/util/countryrules/CountryRuleFactory.java

+50
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,64 @@
2525
import java.util.Map;
2626

2727
import com.graphhopper.routing.ev.Country;
28+
import com.graphhopper.routing.util.countryrules.europe.*;
2829

2930
public class CountryRuleFactory {
3031

3132
private final Map<Country, CountryRule> rules = new EnumMap<>(Country.class);
3233

3334
public CountryRuleFactory() {
35+
36+
// Europe
37+
rules.put(ALB, new AlbaniaCountryRule());
38+
rules.put(AND, new AndorraCountryRule());
3439
rules.put(AUT, new AustriaCountryRule());
40+
rules.put(BEL, new BelgiumCountryRule());
41+
rules.put(BGR, new BulgariaCountryRule());
42+
rules.put(BIH, new BosniaHerzegovinaCountryRule());
43+
rules.put(BLR, new BelarusCountryRule());
44+
rules.put(CHE, new SwitzerlandCountryRule());
45+
rules.put(CZE, new CzechiaCountryRule());
3546
rules.put(DEU, new GermanyCountryRule());
47+
rules.put(DNK, new DenmarkCountryRule());
48+
rules.put(ESP, new SpainCountryRule());
49+
rules.put(EST, new EstoniaCountryRule());
50+
rules.put(FIN, new FinlandCountryRule());
51+
rules.put(FRA, new FranceCountryRule());
52+
rules.put(FRO, new FaroeIslandsCountryRule());
53+
rules.put(GGY, new GuernseyCountryRule());
54+
rules.put(GIB, new GibraltarCountryRule());
55+
rules.put(GBR, new UnitedKingdomCountryRule());
56+
rules.put(GRC, new GreeceCountryRule());
57+
rules.put(HRV, new CroatiaCountryRule());
58+
rules.put(HUN, new HungaryCountryRule());
59+
rules.put(IMN, new IsleOfManCountryRule());
60+
rules.put(IRL, new IrelandCountryRule());
61+
rules.put(ISL, new IcelandCountryRule());
62+
rules.put(ITA, new ItalyCountryRule());
63+
rules.put(JEY, new JerseyCountryRule());
64+
rules.put(LIE, new LiechtensteinCountryRule());
65+
rules.put(LTU, new LithuaniaCountryRule());
66+
rules.put(LUX, new LuxembourgCountryRule());
67+
rules.put(LVA, new LatviaCountryRule());
68+
rules.put(MCO, new MonacoCountryRule());
69+
rules.put(MDA, new MoldovaCountryRule());
70+
rules.put(MKD, new NorthMacedoniaCountryRule());
71+
rules.put(MLT, new MaltaCountryRule());
72+
rules.put(MNE, new MontenegroCountryRule());
73+
rules.put(NLD, new NetherlandsCountryRule());
74+
rules.put(NOR, new NorwayCountryRule());
75+
rules.put(POL, new PolandCountryRule());
76+
rules.put(PRT, new PortugalCountryRule());
77+
rules.put(ROU, new RomaniaCountryRule());
78+
rules.put(RUS, new RussiaCountryRule());
79+
rules.put(SMR, new SanMarinoCountryRule());
80+
rules.put(SRB, new SerbiaCountryRule());
81+
rules.put(SVK, new SlovakiaCountryRule());
82+
rules.put(SVN, new SloveniaCountryRule());
83+
rules.put(SWE, new SwedenCountryRule());
84+
rules.put(UKR, new UkraineCountryRule());
85+
rules.put(VAT, new VaticanCityCountryRule());
3686
}
3787

3888
public CountryRule getCountryRule(Country country) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package com.graphhopper.routing.util.countryrules.europe;
20+
21+
import com.graphhopper.reader.ReaderWay;
22+
import com.graphhopper.routing.ev.Toll;
23+
import com.graphhopper.routing.util.countryrules.CountryRule;
24+
25+
public class AlbaniaCountryRule implements CountryRule {
26+
27+
@Override
28+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
29+
if (currentToll != Toll.MISSING) {
30+
return currentToll;
31+
}
32+
33+
return Toll.NO;
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obt F438 ain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package com.graphhopper.routing.util.countryrules.europe;
20+
21+
import com.graphhopper.reader.ReaderWay;
22+
import com.graphhopper.routing.ev.Toll;
23+
import com.graphhopper.routing.util.countryrules.CountryRule;
24+
25+
public class AndorraCountryRule implements CountryRule {
26+
27+
@Override
28+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
29+
if (currentToll != Toll.MISSING) {
30+
return currentToll;
31+
}
32+
33+
return Toll.NO;
34+
}
35+
}

core/src/main/java/com/graphhopper/routing/util/countryrules/AustriaCountryRule.java core/src/main/java/com/graphhopper/routing/util/countryrules/europe/AustriaCountryRule.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
* limitations under the License.
1717
*/
1818

19-
package com.graphhopper.routing.util.countryrules;
19+
package com.graphhopper.routing.util.countryrules.europe;
2020

2121
import com.graphhopper.reader.ReaderWay;
2222
import com.graphhopper.routing.ev.RoadAccess;
2323
import com.graphhopper.routing.ev.RoadClass;
2424
import com.graphhopper.routing.ev.Toll;
2525
import com.graphhopper.routing.util.TransportationMode;
26+
import com.graphhopper.routing.util.countryrules.CountryRule;
2627

2728
public class AustriaCountryRule implements CountryRule {
2829

@@ -74,8 +75,8 @@ public RoadAccess getAccess(ReaderWay readerWay, TransportationMode transportati
7475
}
7576

7677
@Override
77-
public Toll getToll(ReaderWay readerWay, TransportationMode transportationMode, Toll currentToll) {
78-
if (!transportationMode.isMotorVehicle() || currentToll != Toll.MISSING) {
78+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
79+
if (currentToll != Toll.MISSING) {
7980
return currentToll;
8081
}
8182

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package com.graphhopper.routing.util.countryrules.europe;
20+
21+
import com.graphhopper.reader.ReaderWay;
22+
import com.graphhopper.routing.ev.RoadClass;
23+
import com.graphhopper.routing.ev.Toll;
24+
import com.graphhopper.routing.util.countryrules.CountryRule;
25+
26+
public class BelarusCountryRule implements CountryRule {
27+
28+
@Override
29+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
30+
if (currentToll != Toll.MISSING) {
31+
return currentToll;
32+
}
33+
34+
RoadClass roadClass = RoadClass.find(readerWay.getTag("highway", ""));
35+
if (roadClass == RoadClass.MOTORWAY) {
36+
return Toll.HGV;
37+
}
38+
39+
return currentToll;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.graphhopper.routing.util.countryrules.europe;
19+
20+
import com.graphhopper.reader.ReaderWay;
21+
import com.graphhopper.routing.ev.RoadClass;
22+
import com.graphhopper.routing.ev.Toll;
23+
import com.graphhopper.routing.util.countryrules.CountryRule;
24+
25+
/**
26+
* Defines the default rules for Belgian roads
27+
*
28+
* @author Thomas Butz
29+
*/
30+
public class BelgiumCountryRule implements CountryRule {
31+
32+
@Override
33+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
34+
if (currentToll != Toll.MISSING) {
35+
return currentToll;
36+
}
37+
38+
RoadClass roadClass = RoadClass.find(readerWay.getTag("highway", ""));
39+
if (RoadClass.MOTORWAY == roadClass)
40+
return Toll.HGV;
41+
return currentToll;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package com.graphhopper.routing.util.countryrules.europe;
20+
21+
import com.graphhopper.routing.util.countryrules.CountryRule;
22+
23+
public class BosniaHerzegovinaCountryRule implements CountryRule {
24+
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.graphhopper.routing.util.countryrules.europe;
19+
20+
import com.graphhopper.reader.ReaderWay;
21+
import com.graphhopper.routing.ev.RoadClass;
22+
import com.graphhopper.routing.ev.Toll;
23+
import com.graphhopper.routing.util.countryrules.CountryRule;
24+
25+
/**
26+
* Defines the default rules for Bulgarian roads
27+
*
28+
* @author Thomas Butz
29+
*/
30+
public class BulgariaCountryRule implements CountryRule {
31+
32+
@Override
33+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
34+
if (currentToll != Toll.MISSING) {
35+
return currentToll;
36+
}
37+
38+
RoadClass roadClass = RoadClass.find(readerWay.getTag("highway", ""));
39+
if (RoadClass.MOTORWAY == roadClass)
40+
return Toll.ALL;
41+
return currentToll;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to GraphHopper GmbH under one or more contributor
3+
* license agreements. See the NOTICE file distributed with this work for
4< 741A code class="diff-text syntax-highlighted-line addition">+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper GmbH licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except in
8+
* compliance with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package com.graphhopper.routing.util.countryrules.europe;
19+
20+
import com.graphhopper.reader.ReaderWay;
21+
import com.graphhopper.routing.ev.RoadClass;
22+
import com.graphhopper.routing.ev.Toll;
23+
import com.graphhopper.routing.util.countryrules.CountryRule;
24+
25+
/**
26+
* Defines the default rules for Croatian roads
27+
*
28+
* @author Thomas Butz
29+
*/
30+
public class CroatiaCountryRule implements CountryRule {
31+
32+
@Override
33+
public Toll getToll(ReaderWay readerWay, Toll currentToll) {
34+
if (currentToll != Toll.MISSING) {
35+
return currentToll;
36+
}
37+
38+
RoadClass roadClass = RoadClass.find(readerWay.getTag("highway", ""));
39+
if (RoadClass.MOTORWAY == roadClass)
40+
return Toll.ALL;
41+
return currentToll;
42+
}
43+
}

0 commit comments

Comments
 (0)
0