From a1a595135c6cec1426f7444fdf41816eae585ca8 Mon Sep 17 00:00:00 2001 From: Marcus Young Date: Tue, 2 Feb 2021 14:54:20 +0000 Subject: [PATCH] Check that evaluation of surface generates results before processing. --- R/otp_evaluate_surface.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/R/otp_evaluate_surface.R b/R/otp_evaluate_surface.R index d605b66..c503ff6 100644 --- a/R/otp_evaluate_surface.R +++ b/R/otp_evaluate_surface.R @@ -150,6 +150,17 @@ otp_evaluate_surface <- error.id <- "OK" } + # Check that there are some results + if (length(asjson$data[[1]]$sums) == 0) { + response <- + list( + "errorId" = 1001, + "errorMessage" = "No results - are the pointset destinations within the area covered by the surface?", + "query" = url + ) + return (response) + } + response <- list() response["errorId"] <- error.id response["surfaceId"] <- as.integer(surfaceId)