Skip to content
Open
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 @@ -3,6 +3,7 @@
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -93,5 +94,8 @@ public static class SimPlaceDto {
private String intent;

private String title;

@JsonProperty("map_anchor")
private JsonNode mapAnchor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private void seedPlaces(JsonNode manifest, String runId) {
.category(textOrNull(node, "category"))
.intent(textOrNull(node, "intent"))
.title(textOrNull(node, "title"))
.mapAnchorJson(jsonOrNull(node, "map_anchor"))
.build());
}
placeRepository.saveAll(places);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ private int projectionTailTicks(SimulationRun run) {
}

private int maxProjectedTick(SimulationRun run) {
return run.getMaxProjectedTick() != null
int declaredMax = run.getMaxProjectedTick() != null
? run.getMaxProjectedTick()
: loopPeriodTicks(run) + projectionTailTicks(run) - 1;
int maxLifecycleTick = lifecycleEventRepository.findMaxTickByRunId(run.getRunId()).orElse(declaredMax);
int maxMovementTick = movementRepository.findMaxArriveTickByRunId(run.getRunId()).orElse(declaredMax);
return Math.max(declaredMax, Math.max(maxLifecycleTick, maxMovementTick));
}

private int projectionTailTicks(SimulationRun run, int maxProjectedTick) {
return Math.max(0, maxProjectedTick - loopPeriodTicks(run) + 1);
}

private void validateTickWindow(int fromTick, int toTick) {
Expand Down Expand Up @@ -89,8 +96,10 @@ public SimManifestResponse getManifest(String runId) {
.category(p.getCategory())
.intent(p.getIntent())
.title(p.getTitle())
.mapAnchor(readJsonNode("place.map_anchor", p.getMapAnchorJson()))
.build())
.toList();
int maxProjectedTick = maxProjectedTick(run);

return SimManifestResponse.builder()
.runId(run.getRunId())
Expand All @@ -101,8 +110,8 @@ public SimManifestResponse getManifest(String runId) {
.tickDurationMsDefault(run.getTickDurationMsDefault())
.chunkSizeTicks(run.getChunkSizeTicks())
.loopPeriodTicks(loopPeriodTicks(run))
.projectionTailTicks(projectionTailTicks(run))
.maxProjectedTick(maxProjectedTick(run))
.projectionTailTicks(projectionTailTicks(run, maxProjectedTick))
.maxProjectedTick(maxProjectedTick)
.agents(agents)
.places(places)
.build();
Expand Down
Loading