Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function to insert new vertices #40

Closed
mpadge opened this issue Feb 5, 2018 · 6 comments
Closed

function to insert new vertices #40

mpadge opened this issue Feb 5, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@mpadge
Copy link
Member

mpadge commented Feb 5, 2018

Following on from @rafapereirabr's SO question, it would be very useful for dodgr to incorporate the ability to insert new points in a network. Current routing can accept arbitrary points, but these are simply mapped to nearest network points and then forgotten. Incorporation of new points would involve modification of the underlying network, so a network with an edge between A and B would be modified through calling

insert_point (network, x, y)

to

A -> (new point with hashed id) -> B

or,

> insert_point (network, x, y, "C")
# A -> C -> B

The points A and B could be automatically identified as the nearest two points, yet this may not necessarily be what is desired. It will likely be necessary to have an option to override this default behaviour that would then graphically show the default, yet enable other options to be specified.

@rafapereirabr: this might take a while to implement, because it will be more appropriately incorporated within the soon-to-appear-on-cran silicate, and associated sc, rather than sf or sp representations. This whole issue is therefore likely to first be shifted to silicate and ultimately resolved there. cc @mdsumner

@rafapereirabr
Copy link

rafapereirabr commented Feb 5, 2018

The idea is to add a new node somewhere along an existing edge. One element to consider in this task is the location of the new node, whether it should be placed halfway the edge or whether it should be placed at a specific location set by the user. In the case of my SO question, it's the second case, where the user sets a pair of lat long of the new node.

Thanks for taking this task on board !

@JimShady
Copy link
Contributor

JimShady commented Aug 28, 2019

For reference, the answer to this stack exchange question provides code which seems to be useful for this extra functionality:

https://gis.stackexchange.com/questions/288445/split-polyline-by-point-using-sf-package-in-r

@JimShady
Copy link
Contributor

The idea is to add a new node somewhere along an existing edge. One element to consider in this task is the location of the new node, whether it should be placed halfway the edge or whether it should be placed at a specific location set by the user. In the case of my SO question, it's the second case, where the user sets a pair of lat long of the new node.

Thanks for taking this task on board !

Just reading this ... the new node should be created at the closest point to the lat long specified by the user I would think. That's what I'd expect anyway. Process would be something like this I think:

  1. take the origin latitude and longitudes supplied by a user
  2. If requested, start the node insertion process
    a. snap origins to nearest edges
    b. snap destinations to nearest edges
    c. split lines and create new lines
    d. rebuild the graph
  3. Perform routing

Maybe the insert_point enhancement would be an option within the routing functions? Something like route_dodgr(start_point,end_point, net, create_nodes = TRUE)

@mpadge mpadge closed this as completed in b32dcdd Apr 15, 2020
@mpadge
Copy link
Member Author

mpadge commented Apr 15, 2020

That commit adds a new function dodgr_insert_vertex(), which does most of what was discussed above. The one thing is does not do is enable a vertex to be inserted at the intersection of two existing lines, because the new vertices are always assumed to be genuinely new, and bear no relation with pre-existing network structures. But at least it's a good start - Please feel free to give it a try, and comment here.

@rafapereirabr
Copy link

thanks for the follow up !

@mpadge
Copy link
Member Author

mpadge commented Apr 16, 2020

Yeah, sorry it took sooooo long! It's still not ideal, but there are a number of alternative paths from here on, so I think it's just best to first spin out this initial version and see what kind of feedback it might generate before moving further with it. Thanks for the impetus! Please give any feedback, insight, suggestions you might have either here, or in new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
version 0.2-0.3
  
TODO v0.3.0
Development

No branches or pull requests

3 participants