JOSM/Plugins/TextTransform

From OpenStreetMap Wiki
< JOSM‎ | Plugins
Jump to navigation Jump to search

These are some notes about the creation of a JOSM plugin which can perform text transformations on tags. A possible name is TextTransformer or TagTransformer.

Use cases

Un-abbreviating

The motivating idea for this plugin is to un-abbreviate street types, such as "St" -> "Street", "Rd" -> "Road". As abbreviations vary from region to region, there needs to be a way to choose between different abbreviation dictionaries and logic (street type at beginning, at end, etc.). By default (or by design) this should not apply to objects that have tiger:reviewed=no.

JOSMTextTransformer.png

Fixing spelling

Changing key name

Perhaps a key was used incorrectly or changed name.

JOSMTextTransformer2Keys.png

Normalizing phone numbers

This example is obviously just for North America.

JOSMTextTransformerRegex.png

Implementation

The GUI mockups above give an indication of what the dialog would look like. The plugin will only consider selected objects, so we can take advantage of all the powers of JOSM's built-in search tool. "Transformers" will themselves be plugin-like, or at the very least implement a common base class. A simple signature might be OsmObject transform(OsmObject input), as it could then perhaps automatically filter by region, or ignore objects with a certain ID number, last author, version, etc.