[openstreetmap/openstreetmap-website] use JOSM/tag2link to linkify tag values (PR #6197)

mmd notifications at github.com
Tue Jul 15 18:42:26 UTC 2025


@mmd-osm commented on this pull request.



> +TAG2LINK = lambda {
+  # the JSON data is an array with duplicate entries, which is not efficient for lookups.
+  # So, convert it to a hash and only keep the item with the best rank.
+  array = JSON.parse(Rails.root.join("node_modules/tag2link/index.json").read)
+
+  ranks = %w[deprecated normal preferred].freeze
+
+  output = {}
+
+  all_keys = array.map { |item| item["key"] }.uniq
+
+  all_keys.each do |key|
+    # for each key, find the item with the best rank
+    best_definition = array
+                      .select { |item| item["key"] == key }
+                      .max_by { |item| ranks.index(item["rank"]) }

What would be required to mark some of the links as "primary" or "leading one"? 

`de:amtlicher_gemeindeschluessel` as an example defines nationwide municipality keys. However, due to the federal nature of the services, not every endpoint mentioned in the JSON file serves all numbers.

- https://www.statistikportal.de/de/gemeindeverzeichnis/12067137 (ok)
- https://www.statistik-bw.de/Service/Gemeindeverzeichnis/Gem.jsp?G=12067137 (not working)
- https://www.statistik.bayern.de/mam/produkte/statistik_kommunal/2018/12067137.pdf (not working)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6197#discussion_r2208341856
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6197/review/3021824013 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250715/e732d6b4/attachment.htm>


More information about the rails-dev mailing list