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

Define order of returned routed centreline links #1127

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

Nate-Wessel
Copy link
Contributor

What this pull request accomplishes:

  • Defines an order for the results returned by the centreline routing function.
  • Orders aggregated results by sequence in the routed path

Issue(s) this solves:

What, in particular, needs to reviewed:

  • That this works and nothing breaks. I'm not used to working on SQL within functions.

Since the order was previously undefined, it shouldn't break anything to specify it now.

What needs to be done by a sysadmin after this PR is merged

  • replace function with the new definition

ordered by sequence in the routed path, as returned by pgrouting
@Nate-Wessel Nate-Wessel added the gis label Jan 6, 2025
@gabrielwol gabrielwol self-requested a review January 6, 2025 19:17
Copy link
Collaborator

@gabrielwol gabrielwol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggesting! One issue to resolve.

array_agg(routing_centreline_directional.centreline_id),
st_union(st_linemerge(routing_centreline_directional.geom)) AS geom
array_agg(routing_centreline_directional.centreline_id ORDER BY path_seq),
st_union(st_linemerge(routing_centreline_directional.geom ORDER BY path_seq)) AS geom
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this error while testing:
ERROR: ORDER BY specified, but st_linemerge is not an aggregate function
Need to remove the order by in this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! That should be one parenthesis out, within ST_Union.

Though now that I think about it, I'm not certain that multigeometries actually preserve order. It would be preferable to order the sub-geometries too if possible.

@Nate-Wessel
Copy link
Contributor Author

Fixed! From a quick test, it does appear that order is preserved within the multi-geometries, making the link IDs and geometries accessible as pairs with an unnest/st_dump combo.

@gabrielwol gabrielwol merged commit e46d2f2 into master Jan 6, 2025
6 checks passed
@Nate-Wessel Nate-Wessel requested a review from gabrielwol January 6, 2025 19:40
@gabrielwol gabrielwol deleted the i1126-centreline-routing-order branch January 6, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gis_core.get_centreline_btwn_intersections should return links in routed order
2 participants