GithubHelp home page GithubHelp logo

Comments (4)

rCarto avatar rCarto commented on June 27, 2024

Thank you.
I'm not sure about how to pass this option to curl::handle_setopt(). Do you have an example?

from osrm.

SebKrantz avatar SebKrantz commented on June 27, 2024
osrmTable <- function (src, dst = src, loc, exclude, measure = "duration", 
    osrm.server = getOption("osrm.server"), osrm.profile = getOption("osrm.profile"), ...) 
{
    opt <- options(error = NULL)
    on.exit(options(opt), add = TRUE)
    url <- base_url(osrm.server, osrm.profile, "table")
    if (!missing(loc)) {
        loc <- input_table(x = loc, id = "loc")
        dst_r <- src_r <- loc
        url <- paste0(url, encode_coords(x = loc, osrm.server = osrm.server), 
            "?")
    }
    else {
        src_r <- input_table(x = src, id = "src")
        dst_r <- input_table(x = dst, id = "dst")
        loc <- rbind(src_r, dst_r)
        url <- paste0(url, encode_coords(x = loc, osrm.server), 
            paste0("?sources=", paste(0:(nrow(src_r) - 1), collapse = ";"), 
                "&destinations=", paste(nrow(src_r):(nrow(loc) - 
                  1), collapse = ";")), "&")
    }
    if (!missing(exclude)) {
        url <- paste0(url, "exclude=", exclude, "&")
    }
    url <- paste0(url, "annotations=", paste0(measure, collapse = ","), 
        "&generate_hints=false")
    e <- try({
        req_handle <- curl::new_handle(verbose = FALSE)
        curl::handle_setopt(req_handle, useragent = "osrm_R_package", ...)
        r <- curl::curl_fetch_memory(utils::URLencode(url), handle = req_handle)
    }, silent = TRUE)
    if (inherits(e, "try-error")) {
        stop(e, call. = FALSE)
    }
    test_http_error(r)
    res <- RcppSimdJson::fparse(rawToChar(r$content))
    output <- list()
    if (!is.null(res$durations)) {
        output$durations <- tab_format(res = res, src = src_r, 
            dst = dst_r, type = "duration")
    }
    if (!is.null(res$distances)) {
        output$distances <- tab_format(res = res, src = src_r, 
            dst = dst_r, type = "distance")
    }
    coords <- coord_format(res = res, src = src_r, dst = dst_r)
    output$sources <- coords$sources
    output$destinations <- coords$destinations
    return(output)
}

from osrm.

rCarto avatar rCarto commented on June 27, 2024

Ah ah, no I know how to pass the ellipsis 😄 .
Sorry I wasn't clear, what I meant was that I don't know how to pass the "CURL_MAX_HTTP_HEADER" option to curl. I haven't seen an example of this and I'm not sure if this parameter is exposed through curl::handle_setopt().

from osrm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.