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

Ask "Is this inside a building" #5248

Closed
wants to merge 13 commits into from

Conversation

qugebert
Copy link
Contributor

Related Issue: #5175

I had no idea for a good quest icon, can someone else take care on this?

This quest should replace "AddIsDefibrillatorInside", but i noticed that the defibrillator quest is used in CONTRIBUTING_A_NEW_QUEST.md for explanation, so we should either adapt this documentation or keep the AddIsDefibrillatorIndoor file

@FloEdelmann FloEdelmann linked an issue Sep 13, 2023 that may be closed by this pull request
5 tasks
@westnordost
Copy link
Member

I had no idea for a good quest icon, can someone else take care on this?

Sure, I will

Copy link
Member

@westnordost westnordost left a comment

Choose a reason for hiding this comment

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

Yeah, definitely delete AddIsDefibrillatorIndoor, please. We can fix the documentation afterwards.

Also, since you replace/rename the quest, you should add an alias to typeAliases, i.e.
"AddIsDefibrillatorIndoor" to AddIsAmenityIndoor...

Copy link
Member

@westnordost westnordost left a comment

Choose a reason for hiding this comment

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

Another review, I found one bug and one "lint" error

}

override fun isApplicableTo(element: Element) =
nodesFilter.matches(element) && hasAnyName(element.tags)
Copy link
Member

@westnordost westnordost Sep 25, 2023

Choose a reason for hiding this comment

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

isApplicableTo is called also offline for any element that is updated due to the user changing it.

So for example when you solve the building quest, the app subsequently checks with this function whether for the new version of the building any new quests apply. In this case, the building levels quest will return true here, so a new quest is created.

Now, this means for your implementation here that if any e.g. amenity=atm is updated through any other quest (e.g. checking whether it is still there), the method here will always return true, ie.e. the AddIsAmenityIndoor quest is created. We do not want that.
In fact, as long as we do not have any information about the surrounding buildings, we cannot answer whether it applicable or not. Or well, if the given element does not match the nodesFilter or does not have any name, then we can say that it is not applicable, but otherwise, we can't tell. In this case, we want to return null.

Also have a look at for example the housenumber quest as it also depends on the surrounding building geometry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, i'm not sure if i understand this right.
Would it just be
override fun isApplicableTo(element: Element) { if (!nodesFilter.matches(element) || !hasAnyName(element.tags)) false else null }

or should i think of a more complex filtering?

Copy link
Member

Choose a reason for hiding this comment

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

For this function, yes. However, you use this function also in getApplicableElements, so there you should probably inline nodesFilter.matches(element) && hasAnyName(element.tags)

nodesPositions.insert(node.position)
}

buildings.removeAll { building ->
Copy link
Member

Choose a reason for hiding this comment

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

A further performance improvement would be possible here.

Currently for every node, you check if it is contained within any building that is near one of these nodes.

You could also reduce the nodes beforehand that are not near any building. (add all nodes near buildings to a set and then only iterate through these instead of all nodes)

However, probably not worth it because I guess there are not that many "small amenity nodes" looking at the filter you wrote, so not required for this PR to be merged. Just wanted to note this.

@FloEdelmann FloEdelmann changed the title Ask "Is this inside a bulding" Ask "Is this inside a building" Sep 26, 2023
@westnordost
Copy link
Member

Something went wrong with your merge, look at the changes on github now.

@qugebert
Copy link
Contributor Author

qugebert commented Sep 27, 2023

Yes,but i don't really know, what went wrong.
I wanted to adapt the functions hasAnyName etc. so that it works with the changes from yesterday (PR #5273), but of course I needed the current version for testing, so I to merged into my branch, but after that the build didn't work neither in AndroidStudio nor on Github actions (a java.lang.UnsupportedClassVersionError where i don't believe it can come from these changes), so I reversed it and now everything is completely botched.
I'll create a new/clean branch and PR with references to this one

@qugebert
Copy link
Contributor Author

Ok, sorry for the botched merge, i now created a new pull request
#5278

@qugebert qugebert closed this Sep 27, 2023
@qugebert qugebert deleted the AddIsInside branch October 13, 2023 18:31
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.

Ask "Is this inside a building?"
3 participants