Class Addresses
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.tests.Addresses
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
public class Addresses extends Test
Performs validation tests on addresses (addr:housenumber) and associatedStreet relations.- Since:
- 5644
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
ADDR_CITY
protected static java.lang.String
ADDR_FLATS
protected static java.lang.String
ADDR_HOUSE_NAME
protected static java.lang.String
ADDR_HOUSE_NUMBER
protected static java.lang.String
ADDR_INTERPOLATION
protected static java.lang.String
ADDR_NEIGHBOURHOOD
protected static java.lang.String
ADDR_PLACE
protected static java.lang.String
ADDR_POSTCODE
protected static java.lang.String
ADDR_STREET
protected static java.lang.String
ADDR_SUBURB
protected static java.lang.String
ADDR_UNIT
protected static java.lang.String
ASSOCIATED_STREET
private javax.swing.JCheckBox
checkboxIncludeBldgPOI
protected static int
DUPLICATE_HOUSE_NUMBER
private static java.lang.String
HOUSE
protected static int
HOUSE_NUMBER_TOO_FAR
protected static int
HOUSE_NUMBER_WITHOUT_STREET
private java.util.Set<java.lang.String>
ignoredAddresses
private boolean
includeBldgAndPOI
private java.util.Map<java.lang.String,java.util.Collection<OsmPrimitive>>
knownAddresses
protected static DoubleProperty
MAX_DUPLICATE_DISTANCE
protected static DoubleProperty
MAX_STREET_DISTANCE
protected static int
MULTIPLE_STREET_NAMES
protected static int
MULTIPLE_STREET_RELATIONS
protected static java.lang.String
NAME_TAG
protected static int
OBSOLETE_RELATION
private static BooleanProperty
PREF_INCLUDE_BLDG_POI
private static java.lang.String
STREET
-
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, stopwatch, testBeforeUpload
-
-
Constructor Summary
Constructors Constructor Description Addresses()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGui(javax.swing.JPanel testPanel)
Allow the tester to manage its own preferencesprotected void
checkDistance(OsmPrimitive house, java.util.Collection<Way> street)
protected java.util.List<TestError>
checkForDuplicate(OsmPrimitive p)
protected TestError
checkHouseNumbersWithoutStreet(OsmPrimitive p)
Checks for house numbers for which the street is unknown.private void
checkIfObsolete(Relation r)
Check if an associatedStreet Relation is obsolete.private void
collectAddress(OsmPrimitive p)
adds the OsmPrimitive to the address map if it complies to the restrictionsvoid
endTest()
Notification of the end of the test.(package private) static java.util.List<java.lang.String>
expandHouseNumber(java.lang.String houseNumber)
Split addr:housenumber on , and ; (common separators)Command
fixError(TestError testError)
remove obsolete relation.protected java.util.List<Relation>
getAndCheckAssociatedStreets(OsmPrimitive p)
(package private) static double
getDistance(OsmPrimitive a, OsmPrimitive b)
returns rough distance between two OsmPrimitives(package private) static java.util.List<java.lang.String>
getSimplifiedAddresses(OsmPrimitive p)
(package private) static boolean
hasAddress(OsmPrimitive p)
protected void
initAddressMap(OsmPrimitive primitive)
boolean
isFixable(TestError testError)
Returns true if the given error can be fixed automaticallyprivate static boolean
isInWarnCountry(RelationMember m, java.lang.String[] countryCodes)
(package private) static boolean
isPOI(OsmPrimitive p)
boolean
ok()
Called when the used submits the preferencesvoid
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitorvoid
visit(Node n)
Visiting call for points.void
visit(Relation r)
Visiting call for relations.void
visit(Way w)
Visiting call for lines.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
clear, deletePrimitivesIfNeeded, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isPrimitiveUsable, isResidentialArea, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit
-
-
-
-
Field Detail
-
HOUSE_NUMBER_WITHOUT_STREET
protected static final int HOUSE_NUMBER_WITHOUT_STREET
- See Also:
- Constant Field Values
-
DUPLICATE_HOUSE_NUMBER
protected static final int DUPLICATE_HOUSE_NUMBER
- See Also:
- Constant Field Values
-
MULTIPLE_STREET_NAMES
protected static final int MULTIPLE_STREET_NAMES
- See Also:
- Constant Field Values
-
MULTIPLE_STREET_RELATIONS
protected static final int MULTIPLE_STREET_RELATIONS
- See Also:
- Constant Field Values
-
HOUSE_NUMBER_TOO_FAR
protected static final int HOUSE_NUMBER_TOO_FAR
- See Also:
- Constant Field Values
-
OBSOLETE_RELATION
protected static final int OBSOLETE_RELATION
- See Also:
- Constant Field Values
-
MAX_DUPLICATE_DISTANCE
protected static final DoubleProperty MAX_DUPLICATE_DISTANCE
-
MAX_STREET_DISTANCE
protected static final DoubleProperty MAX_STREET_DISTANCE
-
ADDR_HOUSE_NUMBER
protected static final java.lang.String ADDR_HOUSE_NUMBER
- See Also:
- Constant Field Values
-
ADDR_INTERPOLATION
protected static final java.lang.String ADDR_INTERPOLATION
- See Also:
- Constant Field Values
-
ADDR_NEIGHBOURHOOD
protected static final java.lang.String ADDR_NEIGHBOURHOOD
- See Also:
- Constant Field Values
-
ADDR_PLACE
protected static final java.lang.String ADDR_PLACE
- See Also:
- Constant Field Values
-
ADDR_STREET
protected static final java.lang.String ADDR_STREET
- See Also:
- Constant Field Values
-
ADDR_SUBURB
protected static final java.lang.String ADDR_SUBURB
- See Also:
- Constant Field Values
-
ADDR_CITY
protected static final java.lang.String ADDR_CITY
- See Also:
- Constant Field Values
-
ADDR_UNIT
protected static final java.lang.String ADDR_UNIT
- See Also:
- Constant Field Values
-
ADDR_FLATS
protected static final java.lang.String ADDR_FLATS
- See Also:
- Constant Field Values
-
ADDR_HOUSE_NAME
protected static final java.lang.String ADDR_HOUSE_NAME
- See Also:
- Constant Field Values
-
ADDR_POSTCODE
protected static final java.lang.String ADDR_POSTCODE
- See Also:
- Constant Field Values
-
ASSOCIATED_STREET
protected static final java.lang.String ASSOCIATED_STREET
- See Also:
- Constant Field Values
-
NAME_TAG
protected static final java.lang.String NAME_TAG
- See Also:
- Constant Field Values
-
HOUSE
private static final java.lang.String HOUSE
- See Also:
- Constant Field Values
-
STREET
private static final java.lang.String STREET
- See Also:
- Constant Field Values
-
PREF_INCLUDE_BLDG_POI
private static final BooleanProperty PREF_INCLUDE_BLDG_POI
-
checkboxIncludeBldgPOI
private final javax.swing.JCheckBox checkboxIncludeBldgPOI
-
includeBldgAndPOI
private boolean includeBldgAndPOI
-
knownAddresses
private java.util.Map<java.lang.String,java.util.Collection<OsmPrimitive>> knownAddresses
-
ignoredAddresses
private java.util.Set<java.lang.String> ignoredAddresses
-
-
Constructor Detail
-
Addresses
public Addresses()
Constructor
-
-
Method Detail
-
getAndCheckAssociatedStreets
protected java.util.List<Relation> getAndCheckAssociatedStreets(OsmPrimitive p)
-
checkHouseNumbersWithoutStreet
protected TestError checkHouseNumbersWithoutStreet(OsmPrimitive p)
Checks for house numbers for which the street is unknown.- Parameters:
p
- primitive to test- Returns:
- error found, or null
-
isPOI
static boolean isPOI(OsmPrimitive p)
-
hasAddress
static boolean hasAddress(OsmPrimitive p)
-
collectAddress
private void collectAddress(OsmPrimitive p)
adds the OsmPrimitive to the address map if it complies to the restrictions- Parameters:
p
- OsmPrimitive that has an address
-
initAddressMap
protected void initAddressMap(OsmPrimitive primitive)
-
startTest
public void startTest(ProgressMonitor progressMonitor)
Description copied from class:Test
Start the test using a given 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 callsuper.endTest()
to do this).
-
checkForDuplicate
protected java.util.List<TestError> checkForDuplicate(OsmPrimitive p)
-
getSimplifiedAddresses
static java.util.List<java.lang.String> getSimplifiedAddresses(OsmPrimitive p)
-
expandHouseNumber
static java.util.List<java.lang.String> expandHouseNumber(java.lang.String houseNumber)
Split addr:housenumber on , and ; (common separators)- Parameters:
houseNumber
- The housenumber to be split- Returns:
- A list of addr:housenumber equivalents
-
visit
public void visit(Node n)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for points.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- Parameters:
n
- The node to inspect.
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for lines.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- Parameters:
w
- The way to inspect.
-
visit
public void visit(Relation r)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for relations.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- Parameters:
r
- The relation to inspect.
-
getDistance
static double getDistance(OsmPrimitive a, OsmPrimitive b)
returns rough distance between two OsmPrimitives- Parameters:
a
- primitive ab
- primitive b- Returns:
- distance of center of bounding boxes in meters
-
checkDistance
protected void checkDistance(OsmPrimitive house, java.util.Collection<Way> street)
-
checkIfObsolete
private void checkIfObsolete(Relation r)
Check if an associatedStreet Relation is obsolete. This test marks only those relations which are complete and don't contain any information which isn't also tagged on the members. The strategy is to avoid any false positive.- Parameters:
r
- the relation
-
isInWarnCountry
private static boolean isInWarnCountry(RelationMember m, java.lang.String[] countryCodes)
-
isFixable
public boolean isFixable(TestError testError)
Description copied from class:Test
Returns true if the given error can be fixed automatically
-
addGui
public void addGui(javax.swing.JPanel testPanel)
Description copied from class:Test
Allow the tester to manage its own preferences
-
-