// We could do this when setting up the Spark handler, supplying writeValue as the response transformer
// But then you also have to handle the case where you are returning raw bytes.
public static void addJsonToGrid (
            OutputStream outputStream,
            AccessibilityResult accessibilityResult,
            List<TaskError> scenarioApplicationWarnings,
            List<TaskError> scenarioApplicationInfo,
            PathResult pathResult
    ) throws IOException {
        var jsonBlock = new GridJsonBlock();
        jsonBlock.scenarioApplicationInfo = scenarioApplicationInfo;
        jsonBlock.scenarioApplicationWarnings = scenarioApplicationWarnings;
        if (accessibilityResult != null) {
            // Due to the application of distance decay functions, we may want to make the shift to non-integer
            // accessibility values (especially for cases where there are relatively few opportunities across the whole
            // study area). But we'd need to control the number of decimal places serialized into the JSON.
            jsonBlock.accessibility = accessibilityResult.getIntValues();
        }
        jsonBlock.pathSummaries = pathResult == null ? Collections.EMPTY_LIST : pathResult.getPathIterationsForDestination();
        LOG.debug("Travel time surface written, appending {}.", jsonBlock);
        // We could do this when setting up the Spark handler, supplying writeValue as the response transformer
        // But then you also have to handle the case where you are returning raw bytes.
        JsonUtilities.objectMapper.writeValue(outputStream, jsonBlock);
        LOG.debug("Done writing");
    }
jsonBlock.pathSummaries = pathResult == null ? Collections.EMPTY_LIST : pathResult.getPathIterationsForDestination();
LOG.debug("Travel time surface written, appending {}.", jsonBlock);
// We could do this when setting up the Spark handler, supplying writeValue as the response transformer
// But then you also have to handle the case where you are returning raw bytes.
JsonUtilities.objectMapper.writeValue(outputStream, jsonBlock);
LOG.debug("Done writing");
jsonBlock.scenarioApplicationInfo = scenarioApplicationInfo;
jsonBlock.scenarioApplicationWarnings = scenarioApplicationWarnings;
if (accessibilityResult != null) {
// Due to the application of distance decay functions, we may want to make the shift to non-integer
// accessibility values (especially for cases where there are relatively few opportunities across the whole
// study area). But we'd need to control the number of decimal places serialized into the JSON.
jsonBlock.accessibility = accessibilityResult.getIntValues();
}
jsonBlock.pathSummaries = pathResult == null ? Collections.EMPTY_LIST : pathResult.getPathIterationsForDestination();
LOG.debug("Travel time surface written, appending {}.", jsonBlock);
// We could do this when setting up the Spark handler, supplying writeValue as the response transformer
// But then you also have to handle the case where you are returning raw bytes.
JsonUtilities.objectMapper.writeValue(outputStream, jsonBlock);
LOG.debug("Done writing");
}
public static void addJsonToGrid (
OutputStream outputStream,
AccessibilityResult accessibilityResult,
List<TaskError> scenarioApplicationWarnings,
List<TaskError> scenarioApplicationInfo,
PathResult pathResult
) throws IOException {
var jsonBlock = new GridJsonBlock();
jsonBlock.scenarioApplicationInfo = scenarioApplicationInfo;
jsonBlock.scenarioApplicationWarnings = scenarioApplicationWarnings;
if (accessibilityResult != null) {
// Due to the application of distance decay functions, we may want to make the shift to non-integer
// accessibility values (especially for cases where there are relatively few opportunities across the whole
// study area). But we'd need to control the number of decimal places serialized into the JSON.
jsonBlock.accessibility = accessibilityResult.getIntValues();
}
jsonBlock.pathSummaries = pathResult == null ? Collections.EMPTY_LIST : pathResult.getPathIterationsForDestination();
LOG.debug("Travel time surface written, appending {}.", jsonBlock);
// We could do this when setting up the Spark handler, supplying writeValue as the response transformer
// But then you also have to handle the case where you are returning raw bytes.
JsonUtilities.objectMapper.writeValue(outputStream, jsonBlock);
LOG.debug("Done writing");
}