Skip to content

#6373 Ask for ferry relationships and ferry ways not part of a ferry relationship#6375

Merged
westnordost merged 9 commits into
streetcomplete:masterfrom
paulklie:#6373
Jul 13, 2025
Merged

#6373 Ask for ferry relationships and ferry ways not part of a ferry relationship#6375
westnordost merged 9 commits into
streetcomplete:masterfrom
paulklie:#6373

Conversation

@paulklie

@paulklie paulklie commented Jun 26, 2025

Copy link
Copy Markdown
Collaborator

resolve #6373
I don't have much experience in kotlin, or this repo so am unsure if I conforms to coding guidelines, so some feedback would be good. But it seems to work with my testing.
Since we might be adding many ferry quests I think it might make sence to move some duplicate code to a single place, but not sure where that should be.

@paulklie paulklie marked this pull request as draft June 26, 2025 21:19
@paulklie paulklie changed the title #6373 #6373 Ask for ferry relationships and ferry ways not part of a ferry relationship Jun 26, 2025
@paulklie paulklie marked this pull request as ready for review June 28, 2025 10:29
@paulklie

paulklie commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator Author

For testing, I can recommend this place:

https://www.openstreetmap.org/?mlat=47.72750&mlon=13.43909#map=16/47.72750/13.43909

It has all combinations: a simple ferry route that is just a way, and a way that is part of a relation right next to eachother.

@westnordost westnordost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@matkoniecz is correct, this is the wrong point at which to make the ignored relation types more dynamic/flexible because which relations are ignored is already relevant for the Uploader.

The correct point would be to replace val IGNORED_RELATION_TYPES: Set<String> in ApplicationConstants.kt with a function like

fun isRelationIgnored(tags: Map<String, String>): Boolean

This function is then passed as a parameter to all places where currently IGNORED_RELATION_TYPES is passed to and those places need to be refactored to accept a function. (For example, maybe there are other solutions, too)

This part, by the way, should ideally be a separate PR, enabling this PR.


Regarding FerryUtils.kt, it looks fine. More consistent with the rest of the code and probably more performant however would be a more functional style, e.g. something like

val ferryRouteWays: Collection<Way> = ...
val ferryRouteRelations: Collection<Relation> = ...
val wayIdsInFerryRouteRelations: Set<Long> = ... 
return ferryRouteRelations + ferryRouteWays.filter { it.id !in wayIdsInFerryRouteRelations }

(More performant because currently you have to iterate through all relations for every single ferry route way)

This is pretty compact and straightforward, little duplicated code, so maybe FerryUtils is not even necessary anymore.

@paulklie

paulklie commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator Author

Regarding FerryUtils.kt, it looks fine. More consistent with the rest of the code and probably more performant however would be a more functional style, e.g. something like
(More performant because currently you have to iterate through all relations for every single ferry route way)

I am afraid this exceeds my limited kotlin knowledge, and I dont know how todo this.

This is pretty compact and straightforward, little duplicated code, so maybe FerryUtils is not even necessary anymore.

Hmm I think we can also reuse it for other ferry quests (MaxWeight, Fee) as well as further ones that might be useful (Opening Hours, Maxweight?) to.

@westnordost

westnordost commented Jul 13, 2025

Copy link
Copy Markdown
Member

Well, for the record, I don't like it, but it seems to be common tagging practice, so it unfortunately makes sense for StreetComplete to take this into account.

In my last commit, I implemented what I noted in my last comment. I kept your utils file and changed the tests to test exactly only that helper function.

@westnordost westnordost merged commit 3c48c13 into streetcomplete:master Jul 13, 2025
@paulklie

Copy link
Copy Markdown
Collaborator Author

In my last commit, I implemented what I noted in my last comment. I kept your utils file and changed the tests to test exactly only that helper function.

Ok great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ferry access quests misshandle ways in relations

3 participants