Skip to content

Instantly share code, notes, and snippets.

@mnalis
Created February 24, 2021 23:17
Show Gist options
  • Save mnalis/cecbd88d41be83f12801a34cdec734fb to your computer and use it in GitHub Desktop.
Save mnalis/cecbd88d41be83f12801a34cdec734fb to your computer and use it in GitHub Desktop.
compare StreetComplete and iD building tag presets
#!/bin/sh
# Matija Nalis 2021-02-25, MIT license
# Compares StreetComplete building descriptions to iD tag presets
# see https://github.com/streetcomplete/StreetComplete/issues/2588
wget -q -N https://github.com/streetcomplete/StreetComplete/raw/master/app/src/main/java/de/westnordost/streetcomplete/quests/building_type/BuildingType.kt
fgrep '"building' BuildingType.kt | cut -f4 -d\" | sort -u > sc.tags
curl -s https://raw.githubusercontent.com/openstreetmap/id-tagging-schema/main/dist/presets.json | grep '"building": "[a-z]' | cut -f4 -d\"| sort -u > id.tags
diff -U0 --color=always sc.tags id.tags | fgrep -v @@
sort -u id.tags sc.tags > all.tags
#wget -q -N -O sc-en.json https://github.com/streetcomplete/StreetComplete/raw/master/app/src/main/assets/osmfeatures/default/en.json
wget -q -N -O id-en.json https://raw.githubusercontent.com/openstreetmap/id-tagging-schema/main/dist/translations/en.json
#wget -q -N https://github.com/streetcomplete/StreetComplete/raw/master/app/src/main/res/values-hr/strings.xml
wget -q -N https://github.com/streetcomplete/StreetComplete/raw/master/app/src/main/res/values-en/strings.xml
#for b in `cat sc.tags`; do printf "$b\t\t`fgrep \\"quest_buildingType_$b\\" strings.xml | cut -d\\" -f4`\n"; done > sc.desc
for b in `cat all.tags`; do perl -MXML::Simple -E '$x=XMLin("strings.xml"); say $$x{string}{quest_buildingType_'$b'}{content}' ; done > sc.desc
for b in `cat all.tags`; do perl -MJSON -E "undef \$/; \$h=decode_json <>; say \$\$h{en}{presets}{presets}{\"building/$b\"}{name}" id-en.json; done > id.desc
echo "Tag | SC | iD"
echo "--- | --- | ---"
paste all.tags sc.desc id.desc | perl -nE 'chomp; ($tag, $sc, $id) = split("\t"); say "$tag|$sc|$id" if lc($sc) ne lc($id)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment