Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adapt value range of CsvGraphStorage #1840

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class CsvGraphStorageBuilder extends AbstractGraphStorageBuilder {
private CsvGraphStorage storage;
private final Map<Long, Integer[]> id2Value = new HashMap<>();
private static final int MAX_VALUE = 100;
private static final int MIN_VALUE = -100;
private final byte defaultValue = 50; // TODO: make configurable
private String[] columnNames;

Expand Down Expand Up @@ -94,9 +95,9 @@ private byte[] getValues(long id) {
} else {
int index = 0;
for (Integer i : gi) {
if (i > MAX_VALUE) {
throw new AssertionError("Value too large (way id " + id
+ " at index " + index + "):" + i + " > " + MAX_VALUE);
if (i > MAX_VALUE || i < MIN_VALUE) {
throw new AssertionError("Value out of range (way id " + id
+ " at index " + index + "):" + i + " not in [" + MIN_VALUE + "," + MAX_VALUE + "]");
}
byteValues[index] = i.byteValue();
index++;
Expand All @@ -109,4 +110,4 @@ private byte[] getValues(long id) {
public String getName() {
return "csv";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public HeatStressWeighting(FlagEncoder encoder, PMap map, GraphHopperStorage gra

@Override
public double calcEdgeWeight(EdgeIteratorState edgeState, boolean reverse) {
// TODO: this is a short term solution to be adapted when
// AdditionWeighting will be replaced
if (heatStressStorage != null) {
int stressLevel = heatStressStorage.getEdgeValue(EdgeIteratorStateHelper.getOriginalEdge(edgeState), columnIndex, buffer);
// Convert value range from [0,100] to [1,2] to avoid large detours and multiply by user weighting in API request
Expand Down
Loading