Class SimilarNamedWays

java.lang.Object
org.openstreetmap.josm.data.validation.Test
org.openstreetmap.josm.data.validation.tests.SimilarNamedWays
All Implemented Interfaces:
OsmPrimitiveVisitor

public class SimilarNamedWays extends Test
Checks for similar named ways, symptom of a possible typo. It uses the Levenshtein distance to check for similarity
  • Field Details

  • Constructor Details

  • Method Details

    • startTest

      public void startTest(ProgressMonitor monitor)
      Description copied from class: Test
      Start the test using a given progress monitor
      Overrides:
      startTest in class Test
      Parameters:
      monitor - the progress monitor
    • endTest

      public void endTest()
      Description copied from class: Test
      Notification of the end of the test. The tester may perform additional actions and destroy the used structures.

      If you override this method, don't forget to cleanup progressMonitor (most overrides call super.endTest() to do this).

      Overrides:
      endTest in class Test
    • visit

      public void visit(Way w)
      Description copied from interface: OsmPrimitiveVisitor
      Visiting call for lines.
      Specified by:
      visit in interface OsmPrimitiveVisitor
      Overrides:
      visit in class Test
      Parameters:
      w - The way to inspect.
    • addRegExprRule

      public void addRegExprRule(String regExpr, String replacement)
      Add a regular expression rule.
      Parameters:
      regExpr - the regular expression to search for
      replacement - a string to replace with, which should match the expression.
    • addSynonyms

      public void addSynonyms(String... words)
      Add a rule with synonym words.
      Parameters:
      words - words which are synonyms
    • similaryName

      public boolean similaryName(String name, String name2)
      Check if two names are similar, but not identical. First both names will be "normalized". Afterwards the Levenshtein distance will be calculated.
      Examples for normalization rules:
      replaceAll("\\d+", "0")
      would cause similaryName("track 1", "track 2") = false, but similaryName("Track 1", "track 2") = true
      Parameters:
      name - first name to compare
      name2 - second name to compare
      Returns:
      true if the normalized names are different but only a "little bit"