Coder Social home page Coder Social logo

Issue with viaroute example about stplanr HOT 8 CLOSED

ropensci avatar ropensci commented on July 28, 2024
Issue with viaroute example

from stplanr.

Comments (8)

richardellison avatar richardellison commented on July 28, 2024

I'll have a look, the error implies that the number of routes doesn't match the summary information which seems rather odd (and I'm sure this example worked when I tried it a few weeks ago).

from stplanr.

Robinlovelace avatar Robinlovelace commented on July 28, 2024

Thanks for the fix - no longer errors but I get some strange warnings and the output looks strange:

> exroutes <- viaroute(viapoints=list(data.frame(x=c(-33.5,-33.6,-33.7),y=c(150,150.1,150.2))))
> r <- viaroute2sldf(exroutes)
Warning messages:
1: In bind_rows_(x, .id) : Unequal factor levels: coercing to character
2: In bind_rows_(x, .id) : Unequal factor levels: coercing to character
3: In bind_rows_(x, .id) : Unequal factor levels: coercing to character
4: In bind_rows_(x, .id) : Unequal factor levels: coercing to character
plot(r)

screenshot from 2016-11-20 18-44-23

from stplanr.

Robinlovelace avatar Robinlovelace commented on July 28, 2024

Compared with this from the osrm package:

install.packages("osrm")
library(osrm)
r_osrm <- osrmTrip(data.frame(i = 1:3,x=c(150,150.1,150.2),y=c(-33.5,-33.6,-33.7)))
plot(r_osrm[[1]]$trip)

screenshot from 2016-11-20 18-54-45

from stplanr.

Robinlovelace avatar Robinlovelace commented on July 28, 2024

Also this seems to generate an error with the stplanr implementation:

origin = tmap::geocode_OSM("London")
destination = tmap::geocode_OSM("Leeds")
od_df = rbind(origin$coords, destination$coords)
exroutes <- viaroute(viapoints = list(od_df))
r <- viaroute2sldf(exroutes)
Error in data.frame(routenum = i, legnum = j, routedesc = rep(x$routes$legs[[i]]$summary[j],  : 
  arguments imply differing number of rows: 1, 2, 0

Interestingly this also seems to fail with osrm:

ro = osrmRoute(origin, destination)
osrmRoute function returns an error: 
Error: URL string malformed close to position 31: "73, 51"

from stplanr.

Robinlovelace avatar Robinlovelace commented on July 28, 2024

Update: it works with osrm: riatelab/osrm#17

from stplanr.

richardellison avatar richardellison commented on July 28, 2024

Reopening, seeing the same thing. I'll have another look.

from stplanr.

Robinlovelace avatar Robinlovelace commented on July 28, 2024

Any update on this @richardellison? Thinking better to fix bugs before adding new features and improving performance.

from stplanr.

richardellison avatar richardellison commented on July 28, 2024

This has been fixed in #161. The following now returns the correct geometries.

exroutes <- viaroute(viapoints=list(data.frame(x=c(-33.5,-33.6,-33.7),y=c(150,150.1,150.2))))
r <- viaroute2sldf(exroutes)

image

You will notice that this is different from the result returned by the osrm package. This is because the "osrm" package calculates the individual routes between each pair of coordinates while this implementation uses the coordinates as waypoints on a single route. To return the same result as the "osrm" package you can run the following:

exroutes2 <- viaroute(viapoints=list(
    data.frame(x=c(-33.5,-33.7),y=c(150,150.2)),
    data.frame(x=c(-33.6,-33.7),y=c(150.1,150.2))
))
r2 <- viaroute2sldf(exroutes2)

image

from stplanr.

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.