Skip to content
Draft
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class AgriculturalAccess {
public static final String KEY = "agricultural_access";

private AgriculturalAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
13 changes: 13 additions & 0 deletions ors-engine/src/main/java/com/graphhopper/routing/ev/BusAccess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class BusAccess {
public static final String KEY = "bus_access";

private BusAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class DeliveryAccess {
public static final String KEY = "delivery_access";

private DeliveryAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class ForestryAccess {
public static final String KEY = "forestry_access";

private ForestryAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class GoodsAccess {
public static final String KEY = "goods_access";

private GoodsAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class HazmatAccess {
public static final String KEY = "hazmat_access";

private HazmatAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
13 changes: 13 additions & 0 deletions ors-engine/src/main/java/com/graphhopper/routing/ev/HgvAccess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.graphhopper.routing.ev;

public class HgvAccess {
public static final String KEY = "hgv_access";

private HgvAccess() {
// do not instantiate
}

public static BooleanEncodedValue create() {
return new SimpleBooleanEncodedValue(KEY, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public void initExtStorages() {
if (storage != null) {
ExtendedStorageName extendedStorageName = ExtendedStorageName.getEnum(key);
switch (extendedStorageName) {
case HEAVY_VEHICLE:
handleVehicleAccess();
if (Boolean.TRUE.equals(storage.getRestrictions())) {
handleVehicleRestrictions();
}
break;
case OSM_ID:
if (encodedValues.getOsmWayId() == null) {
encodedValues.setOsmWayId(true);
Expand All @@ -114,6 +120,48 @@ public void initExtStorages() {
}
}

private void handleVehicleAccess() {
if (encodedValues.getAgriculturalAccess() == null) {
encodedValues.setAgriculturalAccess(true);
}
if (encodedValues.getBusAccess() == null) {
encodedValues.setBusAccess(true);
}
if (encodedValues.getDeliveryAccess() == null) {
encodedValues.setDeliveryAccess(true);
}
if (encodedValues.getForestryAccess() == null) {
encodedValues.setForestryAccess(true);
}
if (encodedValues.getGoodsAccess() == null) {
encodedValues.setGoodsAccess(true);
}
if (encodedValues.getHgvAccess() == null) {
encodedValues.setHgvAccess(true);
}
if (encodedValues.getHazmatAccess() == null) {
encodedValues.setHazmatAccess(true);
}
}

private void handleVehicleRestrictions() {
if (encodedValues.getMaxAxleLoad() == null) {
encodedValues.setMaxAxleLoad(true);
}
if (encodedValues.getMaxHeight() == null) {
encodedValues.setMaxHeight(true);
}
if (encodedValues.getMaxLength() == null) {
encodedValues.setMaxLength(true);
}
if (encodedValues.getMaxWeight() == null) {
encodedValues.setMaxWeight(true);
}
if (encodedValues.getMaxWidth() == null) {
encodedValues.setMaxWidth(true);
}
}

private void handleWayCategory() {
if (encodedValues.getHighway() == null) {
encodedValues.setHighway(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,51 @@
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import static java.util.Optional.ofNullable;

@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EncodedValuesProperties {
@JsonProperty("ford")
@JsonProperty(Ford.KEY)
private Boolean ford;
@JsonProperty("highway")
@JsonProperty(Highway.KEY)
private Boolean highway;
@JsonProperty("osm_way_id")
@JsonProperty(OsmWayId.KEY)
private Boolean osmWayId;
@JsonProperty("way_surface")
@JsonProperty(WaySurface.KEY)
private Boolean waySurface;
@JsonProperty("way_type")
@JsonProperty(WayType.KEY)
private Boolean wayType;
@JsonProperty(AgriculturalAccess.KEY)
private Boolean agriculturalAccess;
@JsonProperty(BusAccess.KEY)
private Boolean busAccess;
@JsonProperty(DeliveryAccess.KEY)
private Boolean deliveryAccess;
@JsonProperty(ForestryAccess.KEY)
private Boolean forestryAccess;
@JsonProperty(GoodsAccess.KEY)
private Boolean goodsAccess;
@JsonProperty(HgvAccess.KEY)
private Boolean hgvAccess;
@JsonProperty(HazmatAccess.KEY)
private Boolean hazmatAccess;
@JsonProperty(MaxAxleLoad.KEY)
private Boolean maxAxleLoad;
@JsonProperty(MaxHeight.KEY)
private Boolean maxHeight;
@JsonProperty(MaxLength.KEY)
private Boolean maxLength;
@JsonProperty(MaxWeight.KEY)
private Boolean maxWeight;
@JsonProperty(MaxWidth.KEY)
private Boolean maxWidth;

public EncodedValuesProperties() {
}
Expand All @@ -35,30 +61,42 @@ public EncodedValuesProperties(String ignored) {
// This constructor is used to create an empty object for the purpose of ignoring it in the JSON serialization.
}

@JsonIgnore
private Map<String, Boolean> getProperties() {
Map<String, Boolean> properties = new HashMap<>();

properties.put(Ford.KEY, ford);
properties.put(Highway.KEY, highway);
properties.put(OsmWayId.KEY, osmWayId);
properties.put(WaySurface.KEY, waySurface);
properties.put(WayType.KEY, wayType);
properties.put(AgriculturalAccess.KEY, agriculturalAccess);
properties.put(BusAccess.KEY, busAccess);
properties.put(DeliveryAccess.KEY, deliveryAccess);
properties.put(ForestryAccess.KEY, forestryAccess);
properties.put(GoodsAccess.KEY, goodsAccess);
properties.put(HgvAccess.KEY, hgvAccess);
properties.put(HazmatAccess.KEY, hazmatAccess);
properties.put(MaxAxleLoad.KEY, maxAxleLoad);
properties.put(MaxHeight.KEY, maxHeight);
properties.put(MaxLength.KEY, maxLength);
properties.put(MaxWeight.KEY, maxWeight);
properties.put(MaxWidth.KEY, maxWidth);

return properties;
}

@JsonIgnore
public boolean isEmpty() {
return osmWayId == null && ford == null && highway == null && waySurface == null && wayType == null;
return getProperties().values().stream().allMatch(Objects::isNull);
}

@JsonIgnore
public String toString() {
List<String> out = new ArrayList<>();
if (Boolean.TRUE.equals(ford)) {
out.add(Ford.KEY);
}
if (Boolean.TRUE.equals(highway)) {
out.add(Highway.KEY);
}
if (Boolean.TRUE.equals(osmWayId)) {
out.add(OsmWayId.KEY);
}
if (Boolean.TRUE.equals(waySurface)) {
out.add(WaySurface.KEY);
}
if (Boolean.TRUE.equals(wayType)) {
out.add(WayType.KEY);
}
return String.join(",", out);
return getProperties().entrySet().stream()
.filter(e -> Boolean.TRUE.equals(e.getValue()))
.map(Map.Entry::getKey)
.collect(Collectors.joining(","));
}

public void merge(EncodedValuesProperties other) {
Expand All @@ -67,7 +105,17 @@ public void merge(EncodedValuesProperties other) {
osmWayId = ofNullable(this.osmWayId).orElse(other.osmWayId);
waySurface = ofNullable(this.waySurface).orElse(other.waySurface);
wayType = ofNullable(this.wayType).orElse(other.wayType);
agriculturalAccess = ofNullable(this.agriculturalAccess).orElse(other.agriculturalAccess);
busAccess = ofNullable(this.busAccess).orElse(other.busAccess);
deliveryAccess = ofNullable(this.deliveryAccess).orElse(other.deliveryAccess);
forestryAccess = ofNullable(this.forestryAccess).orElse(other.forestryAccess);
goodsAccess = ofNullable(this.goodsAccess).orElse(other.goodsAccess);
hgvAccess = ofNullable(this.hgvAccess).orElse(other.hgvAccess);
hazmatAccess = ofNullable(this.hazmatAccess).orElse(other.hazmatAccess);
maxAxleLoad = ofNullable(this.maxAxleLoad).orElse(other.maxAxleLoad);
maxHeight = ofNullable(this.maxHeight).orElse(other.maxHeight);
maxLength = ofNullable(this.maxLength).orElse(other.maxLength);
maxWeight = ofNullable(this.maxWeight).orElse(other.maxWeight);
maxWidth = ofNullable(this.maxWidth).orElse(other.maxWidth);
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public List<T> createInstances(Map<String, ExtendedStorageProperties> parameters
return result;
}
private boolean storageTransferredToEncodedValues(String storageName) {
return of("OsmId", "WayCategory", "WaySurfaceType")
return of("HeavyVehicle", "OsmId", "WayCategory", "WaySurfaceType")
.anyMatch(s -> s.equalsIgnoreCase(storageName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.heigit.ors.routing.graphhopper.extensions.flagencoders.FlagEncoderNames;
import org.heigit.ors.routing.graphhopper.extensions.manage.ORSGraphManager;
import org.heigit.ors.routing.graphhopper.extensions.storages.GraphStorageUtils;
import org.heigit.ors.routing.graphhopper.extensions.storages.HeavyVehicleAttributesGraphStorage;
import org.heigit.ors.routing.graphhopper.extensions.storages.TrafficGraphStorage;
import org.heigit.ors.routing.graphhopper.extensions.storages.builders.GraphStorageBuilder;
import org.heigit.ors.routing.graphhopper.extensions.storages.builders.HereTrafficGraphStorageBuilder;
Expand Down Expand Up @@ -447,8 +446,7 @@ protected void initCHPreparationHandler() {
Weighting weighting = createWeighting(profile, new PMap());

if (profile.getVehicle().equals(FlagEncoderNames.HEAVYVEHICLE)) {
HeavyVehicleAttributesGraphStorage hgvStorage = GraphStorageUtils.getGraphExtension(getGraphHopperStorage(), HeavyVehicleAttributesGraphStorage.class);
EdgeFilter hgvEdgeFilter = new HeavyVehicleEdgeFilter(HeavyVehicleAttributes.HGV, null, hgvStorage);
EdgeFilter hgvEdgeFilter = new HeavyVehicleEdgeFilter(HeavyVehicleAttributes.HGV, null, getGraphHopperStorage());
weighting = new HgvAccessWeighting(weighting, hgvEdgeFilter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public TagParser create(String name, PMap configuration) {
case OsmWayId.KEY -> new OsmWayIdParser();
case WaySurface.KEY -> new WaySurfaceParser();
case WayType.KEY -> new WayTypeParser();
case AgriculturalAccess.KEY -> new VehicleAccessParser(AgriculturalAccess.create(), HeavyVehicleAttributes.AGRICULTURE);
case BusAccess.KEY -> new VehicleAccessParser(BusAccess.create(), HeavyVehicleAttributes.BUS);
case DeliveryAccess.KEY -> new VehicleAccessParser(DeliveryAccess.create(), HeavyVehicleAttributes.DELIVERY);
case ForestryAccess.KEY -> new VehicleAccessParser(ForestryAccess.create(), HeavyVehicleAttributes.FORESTRY);
case GoodsAccess.KEY -> new VehicleAccessParser(GoodsAccess.create(), HeavyVehicleAttributes.GOODS);
case HgvAccess.KEY -> new VehicleAccessParser(HgvAccess.create(), HeavyVehicleAttributes.HGV);
case HazmatAccess.KEY -> new HazmatAccessParser();
default -> throw e;
};
}
Expand Down

This file was deleted.

Loading
Loading