@@ -215,22 +215,6 @@ check_limit_for_batch <- function(limit, return_input, reverse) {
215215 }
216216}
217217
218-
219- # check for HERE method batch queries --- for use in geo() and reverse_geo()
220- check_here_return_input <- function (here_request_id , return_input , reverse ) {
221- input_terms <- get_coord_address_terms(reverse )
222-
223- # If a previous job is requested return_addresses should be FALSE
224- # This is because the job won't send the addresses, but would recover the
225- # results of a previous request
226- if (is.character(here_request_id ) && return_input == TRUE ) {
227- stop(" HERE: When requesting a previous job via here_request_id, set " , input_terms $ return_arg ,
228- " to FALSE. See ?" , input_terms $ base_func_name , " for details." ,
229- call. = FALSE
230- )
231- }
232- }
233-
234218# Misc -----------------------------------------------------------------------------------------
235219
236220# # function for extracting everything except the single line
@@ -366,6 +350,21 @@ initialize_init <- function(api_options) {
366350 return (api_options )
367351}
368352
353+ # check for HERE method batch queries --- for use in geo() and reverse_geo()
354+ check_here_return_input <- function (here_request_id , return_input , reverse ) {
355+ input_terms <- get_coord_address_terms(reverse )
356+
357+ # If a previous job is requested return_addresses should be FALSE
358+ # This is because the job won't send the addresses, but would recover the
359+ # results of a previous request
360+ if (is.character(here_request_id ) && return_input == TRUE ) {
361+ stop(" HERE: When requesting a previous job via here_request_id, set " , input_terms $ return_arg ,
362+ " to FALSE. See ?" , input_terms $ base_func_name , " for details." ,
363+ call. = FALSE
364+ )
365+ }
366+ }
367+
369368# apply api options defaults for options not specified by the user
370369# that are relevant for the specified method
371370# called by geo() and reverse_geo()
@@ -396,49 +395,49 @@ check_api_options <- function(method, api_options, reverse, return_inputs) {
396395
397396
398397 # cycle through the api options specified (except for init)
399- if (api_options $ init == TRUE ) {
400- api_method_mismatch_args <- c() # store mismatch api_options here
401- api_bad_args <- c() # store invalid api_options here
402- error_message <- c() # store error message here (if any)
403-
404- for (api_opt in names(api_options )[! names(api_options ) %in% pkg.globals $ special_api_options ]) {
405- # extract method name from api_option
406- api_opt_method <- strsplit(api_opt , " _" )[[1 ]][[1 ]]
407-
408- # check if api parameter is valid
409- if (! api_opt %in% names(pkg.globals $ default_api_options )) {
410- api_bad_args <- c(api_bad_args , api_opt )
411- }
412- # if api parameter is valid but there is a mismatch with selected method
413- # then add offending arg to vector
414- else if (api_opt_method != method ) {
415- api_method_mismatch_args <- c(api_method_mismatch_args , api_opt )
416- }
417- } # end loop
418-
419- # error message for bad api arguments
420- if (length(api_bad_args ) != 0 ) {
421- error_message <- c(error_message ,
422- paste0(
423- " Invalid api_options parameter(s) used:\n\n " ,
424- paste0(api_bad_args , sep = " " ), " \n\n "
425- ))
426- }
398+ # if (api_options$init == TRUE) {
399+ api_method_mismatch_args <- c() # store mismatch api_options here
400+ api_bad_args <- c() # store invalid api_options here
401+ error_message <- c() # store error message here (if any)
402+
403+ for (api_opt in names(api_options )[! names(api_options ) %in% pkg.globals $ special_api_options ]) {
404+ # extract method name from api_option
405+ api_opt_method <- strsplit(api_opt , " _" )[[1 ]][[1 ]]
427406
428- # error message for api arguments that mismatch with the method argument
429- if (length(api_method_mismatch_args ) != 0 ) {
430- error_message <- c(error_message ,
431- ' method = "' , method , ' " is not compatible with the specified api_options parameter(s):\n\n ' ,
432- paste0(api_method_mismatch_args , sep = " " ), " \n\n "
433- )
407+ # check if api parameter is valid
408+ if (! api_opt %in% names(pkg.globals $ default_api_options )) {
409+ api_bad_args <- c(api_bad_args , api_opt )
434410 }
435-
436- # show error (if applicable)
437- if (length(error_message ) != 0 ) {
438- stop(error_message ,
439- ' See ?' , if (reverse == TRUE ) " reverse_geo" else " geo" ,
440- call. = FALSE
441- )
411+ # if api parameter is valid but there is a mismatch with selected method
412+ # then add offending arg to vector
413+ else if (api_opt_method != method ) {
414+ api_method_mismatch_args <- c(api_method_mismatch_args , api_opt )
442415 }
416+ } # end loop
417+
418+ # error message for bad api arguments
419+ if (length(api_bad_args ) != 0 ) {
420+ error_message <- c(error_message ,
421+ paste0(
422+ " Invalid api_options parameter(s) used:\n\n " ,
423+ paste0(api_bad_args , sep = " " ), " \n\n "
424+ ))
425+ }
426+
427+ # error message for api arguments that mismatch with the method argument
428+ if (length(api_method_mismatch_args ) != 0 ) {
429+ error_message <- c(error_message ,
430+ ' method = "' , method , ' " is not compatible with the specified api_options parameter(s):\n\n ' ,
431+ paste0(api_method_mismatch_args , sep = " " ), " \n\n "
432+ )
433+ }
434+
435+ # show error (if applicable)
436+ if (length(error_message ) != 0 ) {
437+ stop(error_message ,
438+ ' See ?' , if (reverse == TRUE ) " reverse_geo" else " geo" ,
439+ call. = FALSE
440+ )
443441 }
442+ # }
444443}
0 commit comments