[openstreetmap/openstreetmap-website] Take entrances into account for routing start and end points (PR #7017)
Pablo Brasero
notifications at github.com
Wed Apr 22 09:47:24 UTC 2026
@pablobm commented on this pull request.
> + let ll = null;
+ // if the place has entrances, use their location in preference
+ if (json[0].entrances) {
+ for (const e of json[0].entrances) {
+ if (e.type === "main") {
+ ll = e;
+ break;
+ }
+ if (!ll && e.type === "yes") {
+ ll = e;
+ }
+ }
+ }
+ if (!ll) {
+ ll = json[0];
+ }
I think this is a bit better, but the line `if (matchId === 0) return e;` is unnecessary. In theory it saves time, but it'll be negligible (if existing at all) and adds complication. (Of course removing it would require replacing `matchId > 0` with `matchId >= 0`).
Which leads me to: in my opinion it's ok to traverse a list twice. The algorithm is O(n) anyway. Technically there's twice the overheads and all, but you never know what the interpreter is doing behind the scenes; these things have been very smart for a long time. Unless there's a good, measurable reason not to traverse a list twice, it's preferable to do it in service of maintainability.
However! I'm not blocking anything because I'm not even a maintainer :smile: Perhaps we can summon @hlfan, who has been working on frontend code lately, and humbly request the election of a victor and the swift merge of this pretty cool feature.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7017?email_source=notifications&email_token=AAK2OLMXTKV4ZKJXISNDOK34XCIKZA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJVGM3DOOJVGEYKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOS6XA4S7OJSXM2LFO5PW433UNFTGSY3BORUW63TTL5RWY2LDNM#discussion_r3123045887
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7017/review/4153679510 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260422/e9d93044/attachment.htm>
More information about the rails-dev
mailing list