Skip to content

Instantly share code, notes, and snippets.

@gileri
Created March 20, 2015 23:49
Show Gist options
  • Save gileri/3df89cc2811d16549e45 to your computer and use it in GitHub Desktop.
Save gileri/3df89cc2811d16549e45 to your computer and use it in GitHub Desktop.
OSM phone number normalisation
#!/bin/bash
osmosis \
--fast-read-xml file="out.xml" \
--buffer \
--sort \
--read-pbf-fast file="lyon_france.osm.pbf" \
--sort \
--buffer \
--derive-change \
--log-progress-change \
--write-xml-change file="change.osc"
#!/bin/bash
osmosis \
--read-pbf-fast file="lyon_france.osm.pbf" \
--buffer \
--tag-transform file="transform.xml" \
--log-progress \
--buffer \
--write-xml file="out.xml"
<?xml version="1.0"?>
<translations>
<translation>
<name>French phone numbers normalisation</name>
<description>French phone numbers normalisation</description>
<match>
<tag k="phone|contact:phone" match_id="phone1" v=".*(\d).*?(\d).*?(\d).*?(\d).*?(\d).*?(\d).*?(\d).*?(\d).*?(\d)"/>
</match>
<output>
<copy-all/>
<tag from_match="phone1" v="+33 {1} {2}{3} {4}{5} {6}{7} {8}{9}"/>
</output>
</translation>
</translations>
# Allow to quickly see defects post-transformation, before deriving the osc file
sed -ne 's/.*k=\"\(contact:\)*phone\" v=\"\(.*\)\".*/\2/p' out.xml | sort | uniq | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment