# LocationIQ
#
# LocationIQ provides flexible enterprise-grade location based solutions. We work with developers, startups and enterprises worldwide serving billions of requests everyday. This page provides an overview of the technical aspects of our API and will help you get started.
#
# The version of the OpenAPI document: 1.1.0
#
# Generated by: https://openapi-generator.tech
#' @docType class
#' @title Matching operations
#' @description locationiq.Matching
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ Matching } \emph{ Matching Service }
#' Matching API matches or snaps given GPS points to the road network in the most plausible way. Please note the request might result multiple sub-traces. Large jumps in the timestamps (> 60s) or improbable transitions lead to trace splits if a complete matching could not be found. The algorithm might not be able to match all points. Outliers are removed if they can not be matched successfully.
#'
#' \itemize{
#' \item \emph{ @param } coordinates character
#' \item \emph{ @param } generate.hints character
#' \item \emph{ @param } approaches character
#' \item \emph{ @param } exclude character
#' \item \emph{ @param } bearings character
#' \item \emph{ @param } radiuses character
#' \item \emph{ @param } steps character
#' \item \emph{ @param } annotations character
#' \item \emph{ @param } geometries character
#' \item \emph{ @param } overview character
#' \item \emph{ @param } timestamps character
#' \item \emph{ @param } gaps character
#' \item \emph{ @param } tidy character
#' \item \emph{ @param } waypoints character
#' \item \emph{ @returnType } \link{DirectionsMatching} \cr
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : DirectionsMatching
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | The request has been made from an unauthorized domain.
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | No location or places were found for the given input
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 429 | Request exceeded the rate-limits set on your account
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Server Error
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \donttest{
#' #################### Matching ####################
#'
#' library(locationiq)
#' var.coordinates <- '-0.16102,51.523854;-0.15797,51.52326;-0.161593,51.522550' # character | String of format {longitude},{latitude};{longitude},{latitude}[;{longitude},{latitude} ...] or polyline({polyline}) or polyline6({polyline6}). polyline follows Google's polyline format with precision 5
#' var.generate.hints <- 'false' # character | Adds a Hint to the response which can be used in subsequent requests, see hints parameter. Input Value - true (default), false Format - Base64 String
#' var.approaches <- 'curb;curb;curb' # character | Keep waypoints on curb side. Input Value - {approach};{approach}[;{approach} ...] Format - curb or unrestricted (default)
#' var.exclude <- 'toll' # character | Additive list of classes to avoid, order does not matter. input Value - {class}[,{class}] Format - A class name determined by the profile or none.
#' var.bearings <- 'None' # character | Limits the search to segments with given bearing in degrees towards true north in clockwise direction. List of positive integer pairs separated by semi-colon and bearings array should be equal to length of coordinate array. Input Value :- {bearing};{bearing}[;{bearing} ...] Bearing follows the following format : bearing {value},{range} integer 0 .. 360,integer 0 .. 180
#' var.radiuses <- 'None' # character | Limits the search to given radius in meters Radiuses array length should be same as coordinates array, eaach value separated by semi-colon. Input Value - {radius};{radius}[;{radius} ...] Radius has following format :- double >= 0 or unlimited (default)
#' var.steps <- 'true' # character | Returned route steps for each route leg [ true, false (default) ]
#' var.annotations <- 'false' # character | Returns additional metadata for each coordinate along the route geometry. [ true, false (default), nodes, distance, duration, datasources, weight, speed ]
#' var.geometries <- 'polyline' # character | Returned route geometry format (influences overview and per step) [ polyline (default), polyline6, geojson ]
#' var.overview <- 'simplified' # character | Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all. [ simplified (default), full, false ]
#' var.timestamps <- '200;300;900' # character | Timestamps for the input locations in seconds since UNIX epoch. Timestamps need to be monotonically increasing. [ {timestamp};{timestamp}[;{timestamp} ...] integer seconds since UNIX epoch
#' var.gaps <- 'split' # character | Allows the input track splitting based on huge timestamp gaps between points. [ split (default), ignore ]
#' var.tidy <- 'false' # character | Allows the input track modification to obtain better matching quality for noisy tracks. [ true, false (default) ]
#' var.waypoints <- '0;1;2' # character | Treats input coordinates indicated by given indices as waypoints in returned Match object. Default is to treat all input coordinates as waypoints. [ {index};{index};{index}... ]
#'
#' #Matching Service
#' api.instance <- MatchingApi$new()
#'
#' #Configure API key authorization: key
#' api.instance$apiClient$apiKeys['key'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$Matching(var.coordinates, generate.hints=var.generate.hints, approaches=var.approaches, exclude=var.exclude, bearings=var.bearings, radiuses=var.radiuses, steps=var.steps, annotations=var.annotations, geometries=var.geometries, overview=var.overview, timestamps=var.timestamps, gaps=var.gaps, tidy=var.tidy, waypoints=var.waypoints)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom caTools base64encode
#' @export
MatchingApi <- R6::R6Class(
'MatchingApi',
public = list(
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
Matching = function(coordinates, generate.hints=NULL, approaches=NULL, exclude=NULL, bearings=NULL, radiuses=NULL, steps=NULL, annotations='"false"', geometries='"polyline"', overview='"simplified"', timestamps=NULL, gaps='"split"', tidy='"false"', waypoints=NULL, ...){
apiResponse <- self$MatchingWithHttpInfo(coordinates, generate.hints, approaches, exclude, bearings, radiuses, steps, annotations, geometries, overview, timestamps, gaps, tidy, waypoints, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
MatchingWithHttpInfo = function(coordinates, generate.hints=NULL, approaches=NULL, exclude=NULL, bearings=NULL, radiuses=NULL, steps=NULL, annotations='"false"', geometries='"polyline"', overview='"simplified"', timestamps=NULL, gaps='"split"', tidy='"false"', waypoints=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`coordinates`)) {
stop("Missing required parameter `coordinates`.")
}
queryParams['generate_hints'] <- generate.hints
queryParams['approaches'] <- approaches
queryParams['exclude'] <- exclude
queryParams['bearings'] <- bearings
queryParams['radiuses'] <- radiuses
queryParams['steps'] <- steps
queryParams['annotations'] <- annotations
queryParams['geometries'] <- geometries
queryParams['overview'] <- overview
queryParams['timestamps'] <- timestamps
queryParams['gaps'] <- gaps
queryParams['tidy'] <- tidy
queryParams['waypoints'] <- waypoints
urlPath <- "/matching/driving/{coordinates}"
if (!missing(`coordinates`)) {
urlPath <- gsub(paste0("\\{", "coordinates", "\\}"), URLencode(as.character(`coordinates`), reserved = TRUE), urlPath)
}
# API key authentication
if ("key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["key"]) > 0) {
queryParams['key'] <- paste(unlist(self$apiClient$apiKeys["key"]), collapse='')
}
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "DirectionsMatching", loadNamespace("locationiq")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.