Skip to content

Commit

Permalink
custom model bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Nov 19, 2024
1 parent e83332e commit b5edf20
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static void findMinMaxForGroup(final MinMax minMax, List<Statement> grou
MinMax tmp;
if(s.isBlock()) {
tmp = new MinMax(minMax.min, minMax.max);
for (List<Statement> subGroup : CustomModelParser.splitIntoGroup(first.doBlock())) findMinMaxForGroup(tmp, subGroup, lookup);
for (List<Statement> subGroup : CustomModelParser.splitIntoGroup(s.doBlock())) findMinMaxForGroup(tmp, subGroup, lookup);
} else {
tmp = s.operation().apply(minMax, ValueExpressionVisitor.findMinMax(s.value(), lookup));
if (tmp.max < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,30 @@ public void testBlock() {
" ]" +
"}}";
JsonNode path = getPath(body);
assertEquals(path.get("distance").asDouble(), 660, 10);
assertEquals(path.get("time").asLong(), 22_680, 1_000);
assertEquals(660, path.get("distance").asDouble(), 10);
assertEquals(22_680, path.get("time").asLong(), 1_000);

body = "{\"points\": [[11.58199, 50.0141], [11.5865, 50.0095]], \"profile\": \"roads\", \"ch.disable\": true, " +
"\"custom_model\": {\n" +
" \"speed\": [\n" +
" {\n" +
" \"if\": \"false\",\n" +
" \"limit_to\": \"20\"\n" +
" },\n" +
" {\n" +
" \"else\": \"\",\n" +
" \"do\": [\n" +
" {\n" +
" \"if\": \"true\",\n" +
" \"limit_to\": 255\n" +
" }\n" +
" ]\n" +
" }\n" +
" ]\n" +
"}\n}";
path = getPath(body);
assertEquals(660, path.get("distance").asDouble(), 10);
assertEquals(19800, path.get("time").asLong(), 1_000);
}

@Test
Expand Down

0 comments on commit b5edf20

Please sign in to comment.