Skip to content

PhoneRules

Matt Whilden edited this page Sep 21, 2023 · 1 revision

Using the phone= fixup rules

The phone= fixup rules are designed to help modify the most common ways put US phone numbers into OSM into +1-NNN-NNN-NNNN format. The goal is to clean up all the easy stuff so that we can focus on more complicated and broken things by hand. There are 2 phases of cleanup, the first runs until step 4. The steps after that require a bit more care and manual review. Feel free to upload after step 4 if that's all you have time for.

NOTE: It is very common for folks to add an entire address (ex: "123 South Main Street Unit 2, Denver, CO") in a field. These can be more easily managed using this text to tag splitter.

  1. Add the phone rules to your validator
  1. Download an area you want to do fixups to, here's an Overpass query for all of Iowa:
[out:json][timeout:150];
{{geocodeArea:Iowa, United States}}->.searchArea;
nwr["phone"](area.searchArea);
out body;
  1. Select all and run the validator
  2. The first set of fixups should have a 0% error rate and are considered Safe. You can look through the listed phone numbers and apply the fix
PhoneFixupDiary-1
  1. Rerun the validator to clean out any extraneous warnings.
  2. Find the warning about "Dangerous: phone number formatting". This rule strips out some non-digit characters so that the phone numbers may be fixed up by other rules. Select all elements in this group.
PhoneFixupDiary-2
  1. Create a new layer (Ctrl+N)
  2. Return to the old layer and merge the "dangerous" elements into the new layer.
  3. Run the validator. Review elements and apply the "dangerous" fixup.
  4. Run the validator. Apply any of the "safe" fixes to these elements.
  5. We need to move the newly cleaned up elements back to the main layer and leave any residual mangled elements in this layer. Open the find dialog and use this MapCSS selector then merge those elements to the original layer.
*["phone"=~/^\+1-[2-9][0-9]{2}-[0-9]{3}-[0-9]{4}$/] 

image

  1. Review and upload to OSM. If you add #josm-phone-rules it'll be easier for folks to know how the changes happened.

You should be left with a small number of tags to manually review. Some will have multiple numbers in them. Some the wrong number of digits. Some will have phone words (there's a rule for that!).

image

Clone this wiki locally