Git Product home page Git Product logo

Comments (10)

rCarto avatar rCarto commented on May 25, 2024

Hello,
Thank you for raising this issue.
Are you using your own OSRM server ? With the driving profile?
Also, it would be helpful to have the values of i, lngs, lats, breaks and res.

from osrm.

Christoph999 avatar Christoph999 commented on May 25, 2024

Hi, Thanks for your reply. Don't hestite to conatct me, in case you need further details:

the data (from RStudio)

structure(list(PLZ = NA, Stadt = "Erstfeld", Breite = 46.81236378, 
    Laenge = 8.599465297), class = "data.frame", row.names = c(NA, 
-1L))

The relevant code sequence:

library(osrm)
library(sf)
res_isochrones <- 50
breaks_isochrones <- seq(90, 120, 30)
path <- paste0(getwd(), "/rawdata/")
map_name = "switzerland-latest"
osrm_path = "C:/OSRM_API5"
filename <- paste0(path, "LagerErstfeld.csv")
datenLager <- read.csv(filename, sep = ";", stringsAsFactors = FALSE)
r <- calculate_isochones(names = datenLager$PLZ, lats = datenLager$Breite[1], 
                         lngs = datenLager$Laenge[1],
                         breaks = breaks_isochrones, 
                         res = res_isochrones, 
                         map_name = map_name,
                         osrm_path = osrm_path) 

calculate_isochones <- function(names, lats, lngs, breaks = seq(5,20,5), res = 50, 
                                map_name, osrm_path) {
  options(osrm.server = paste0(osrmr:::server_address(TRUE), "/"), osrm.profile = "driving")
  osrmr::run_server(paste0(map_name, ".osrm"), osrm_path)
  parameters <- list(Names = names, 
                     Lattitudes = lats, 
                     Longitudes = lngs,
                     Breaks = breaks, 
                     Resolution = res)
  isochrone_list <- list()
  for (i in 1:length(lats)) {
    isochrone_list[[i]] <- osrm::osrmIsochrone(c(lngs[i], lats[i]), breaks, res)
  }
  names(isochrone_list) <- names
  isochrone_list <- list(parameters, isochrone_list)
  osrmr::quit_server()
  return(isochrone_list)
}

We use R and a local version of OSRM running on Windows (API5).
The API seems find and I figured out, that in your function, everything seems to be ok until req <- tableLoc(loc = loc, gepaf = gepaf) in osrmTable().

from osrm.

rCarto avatar rCarto commented on May 25, 2024

Ok I see it.
Since v3.2.0, a new parameter has been added in osrmIsochrone() (exclude, between breaks and res) .
I you use explicitly named argument the function should work. Something like :

osrm::osrmIsochrone(loc = c(lngs[i], lats[i]), breaks = breaks, res = res)

Sorry for the breaking change, I should have added the new param at the end of the list...

from osrm.

Christoph999 avatar Christoph999 commented on May 25, 2024

Still the same issue in

isochrone_list[[i]] <- osrm::osrmIsochrone(loc = c(lngs[i], lats[i]),
                                           breaks = breaks, res = res)

results in

The OSRM server returned an error:
Error: InvalidQuery
Query string malformed close to position 6309

8x the same message...

Error in UseMethod("st_as_sf") : 
  no applicable method for 'st_as_sf' applied to an object of class "NULL"

from osrm.

Christoph999 avatar Christoph999 commented on May 25, 2024

from osrm.

rCarto avatar rCarto commented on May 25, 2024

Using the demo server and the coordinates you sent me I get:

library(osrm)
#> Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
#> Routing: OSRM - http://project-osrm.org/
library(sf)
#> Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks, 
                     res = res, returnclass = "sf")
plot(st_geometry(iso), col = c("lightblue1", "lightblue3"))
points(loc[1], loc[2], pch = 20, col = "red")

Created on 2019-10-04 by the reprex package (v0.3.0)

But I don't know what's in the "LagerErstfeld.csv" file...

from osrm.

Christoph999 avatar Christoph999 commented on May 25, 2024

Ok, so it is definitely related to the local OSRM:

library(osrm)
Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
Routing: OSRM - http://project-osrm.org/
library(sf)
Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks, 
                     res = res, returnclass = "sf")
plot(st_geometry(iso), col = c("lightblue1", "lightblue3"))
points(loc[1], loc[2], pch = 20, col = "red")

Everything works!
Then:

map_name = "switzerland-latest"
osrm_path = "C:/OSRM_API5"
options(osrm.server = paste0(osrmr:::server_address(TRUE), "/"), osrm.profile = "driving")
osrmr::run_server(paste0(map_name, ".osrm"), osrm_path)  # a wrapper for a shell command. See below...
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks, 
                     res = res, returnclass = "sf")
# The OSRM server returned an error:
# Error: InvalidQuery
# Query string malformed close to position 6285
...
Error in UseMethod("st_as_sf") : 
  no applicable method for 'st_as_sf' applied to an object of class "NULL"

From our local API (Which is working, this is the command from osrmr::run_server()):

C:\OSRM_API5>osrm-routed switzerland-latest
[info] starting up engines, v5.10.0[0m
[info] Threads: 8[0m
[info] IP address: 0.0.0.0[0m
[info] IP port: 5000[0m
[info] load names from: "switzerland-latest.osrm.names"[0m
[info] set checksum: 384967193[0m
[info] http 1.1 compression handled by zlib version 1.2.8[0m
[info] Listening on: 0.0.0.0:5000[0m
[info] running and waiting for requests[0m

I hope that helps! I already checked, whether the OSRM API interfaced changed since 5.10, but I couldn't find anything.

from osrm.

rCarto avatar rCarto commented on May 25, 2024

So that's it, I try to keep the osrm package in line with the latest version of OSRM served via Docker (name: latest in images on Docker Cloud, https://github.com/Project-OSRM/osrm-backend#using-docker). The version announced is currently 5.22.0.

In version 5.18.0 (https://github.com/Project-OSRM/osrm-backend/blob/master/CHANGELOG.md#5180) a new param annotation has been added to the table service.
Accordingly osrmTable() gained this new parameter. Changing things around here: https://github.com/rCarto/osrm/blame/master/R/osrmTable.R#L118 would probably solve your problem.

I do not plan to modify the package to work with older version of OSRM (v.5.18.0 is from 10 May 2018, v5.10.0 is from 7 Aug 2017).

The strategy with osrm is to follow the latest version and the demo version of OSRM.

My suggestion here would be to update OSRM to the latest version (and I guess it could be bothersome in Window$ OS...). Or to use an old version of osrm (but, notably, osrmIsochrone() has improved with the last 2-3 verisons).

from osrm.

Christoph999 avatar Christoph999 commented on May 25, 2024

Thanks again for your great support! I understand and I consider this issue as solved.

from osrm.

rCarto avatar rCarto commented on May 25, 2024

All right

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.