Skip to content

Commit ccec887

Browse files
authored
feat: increase precision and range of vehicle attributes encoded values (#111)
The change is necessary in order to match the original ORS behavior after the transition from extended storage to encoded values introduced by GIScience/openrouteservice#2146.
1 parent 968617c commit ccec887

7 files changed

Lines changed: 24 additions & 5 deletions

File tree

core/src/main/java/com/graphhopper/routing/ev/MaxAxleLoad.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class MaxAxleLoad {
2929
* it was done with the MappedDecimalEncodedValue still handling (or rounding) of unknown values is unclear.
3030
*/
3131
public static DecimalEncodedValue create() {
32-
return new UnsignedDecimalEncodedValue(KEY, 7, 0.5, Double.POSITIVE_INFINITY, false);
32+
// ORS-GH MOD START: increased precision and range to match former ORS behavior
33+
// 9 bits with factor 0.1 allows to store values from 0.1 to 51.1 tons
34+
return new UnsignedDecimalEncodedValue(KEY, 9, 0.1, Double.POSITIVE_INFINITY, false);
35+
// ORS-GH MOD END
3336
}
3437
}

core/src/main/java/com/graphhopper/routing/ev/MaxHeight.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class MaxHeight {
3232
* it is assumed to use the maximum value.
3333
*/
3434
public static DecimalEncodedValue create() {
35-
return new UnsignedDecimalEncodedValue(KEY, 7, 0.1, Double.POSITIVE_INFINITY, false);
35+
// ORS-GH MOD START: increased precision and range to match former ORS behavior
36+
// 11 bits with factor 0.01 allows to store values from 0.01 to 20.47 meters
37+
return new UnsignedDecimalEncodedValue(KEY, 11, 0.01, Double.POSITIVE_INFINITY, false);
38+
// ORS-GH MOD END
3639
}
3740
}

core/src/main/java/com/graphhopper/routing/ev/MaxLength.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class MaxLength {
3232
* between the maximum and infinity it is assumed to use the maximum value.
3333
*/
3434
public static DecimalEncodedValue create() {
35-
return new UnsignedDecimalEncodedValue(KEY, 7, 0.1, Double.POSITIVE_INFINITY, false);
35+
// ORS-GH MOD START: increased precision and range to match former ORS behavior
36+
// 9 bits with factor 0.1 allows to store values from 0.1 to 51.1 meters
37+
return new UnsignedDecimalEncodedValue(KEY, 9, 0.1, Double.POSITIVE_INFINITY, false);
38+
// ORS-GH MOD END
3639
}
3740
}

core/src/main/java/com/graphhopper/routing/ev/MaxWeight.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class MaxWeight {
3333
* it was done with the MappedDecimalEncodedValue still handling (or rounding) of unknown values is unclear.
3434
*/
3535
public static DecimalEncodedValue create() {
36-
return new UnsignedDecimalEncodedValue(KEY, 8, 0.1, Double.POSITIVE_INFINITY, false);
36+
// ORS-GH MOD START: increased precision and range to match former ORS behavior
37+
// 11 bits with factor 0.1 allows to store values from 0.1 to 204.7 tons
38+
return new UnsignedDecimalEncodedValue(KEY, 11, 0.1, Double.POSITIVE_INFINITY, false);
39+
// ORS-GH MOD END
3740
}
3841
}

core/src/main/java/com/graphhopper/routing/ev/MaxWidth.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public class MaxWidth {
3232
* it is assumed to use the maximum value.
3333
*/
3434
public static DecimalEncodedValue create() {
35-
return new UnsignedDecimalEncodedValue(KEY, 7, 0.1, Double.POSITIVE_INFINITY, false);
35+
// ORS-GH MOD START: increased precision to match former ORS behavior
36+
// 10 bits with factor 0.01 allows to store values from 0.01 to 10.23 meters
37+
return new UnsignedDecimalEncodedValue(KEY, 10, 0.01, Double.POSITIVE_INFINITY, false);
38+
// ORS-GH MOD END
3639
}
3740
}

core/src/test/java/com/graphhopper/routing/util/parsers/OSMMaxAxleLoadParserTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.graphhopper.routing.util.EncodingManager;
77
import com.graphhopper.storage.IntsRef;
88
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.Disabled;
910
import org.junit.jupiter.api.Test;
1011

1112
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -41,6 +42,7 @@ public void testSimpleTags() {
4142
}
4243

4344
@Test
45+
@Disabled("Behavior changed due to ORS-specific modifications, see MaxAxleLoad")
4446
public void testRounding() {
4547
ReaderWay readerWay = new ReaderWay(1);
4648
IntsRef intsRef = em.createEdgeFlags();

core/src/test/java/com/graphhopper/routing/util/parsers/OSMMaxWeightParserTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.graphhopper.routing.util.EncodingManager;
77
import com.graphhopper.storage.IntsRef;
88
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.Disabled;
910
import org.junit.jupiter.api.Test;
1011

1112
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -24,6 +25,7 @@ public void setUp() {
2425
}
2526

2627
@Test
28+
@Disabled("Behavior changed due to ORS-specific modifications, see MaxWeight")
2729
public void testSimpleTags() {
2830
ReaderWay readerWay = new ReaderWay(1);
2931
IntsRef intsRef = em.createEdgeFlags();

0 commit comments

Comments
 (0)