Class RelationChecker
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.tests.RelationChecker
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
,TaggingPresetListener
public class RelationChecker extends Test implements TaggingPresetListener
Check for wrong relations.- Since:
- 3669
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RelationChecker.RoleInfo
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description private static BooleanProperty
ALLOW_COMPLEX_LOOP
static int
HIGH_COUNT
Number of ''{0}'' roles too high ({1})private boolean
ignoreMultiPolygons
private boolean
ignoreTurnRestrictions
private java.util.List<java.util.List<Relation>>
loops
static int
LOW_COUNT
Number of ''{0}'' roles too low ({1})static int
RELATION_EMPTY
Relation is emptystatic int
RELATION_LOOP
Relations build circular dependenciesstatic int
RELATION_UNKNOWN
Relation type is unknownprivate static java.util.Collection<TaggingPreset>
relationpresets
static int
ROLE_EMPTY
Empty role found when expecting one of ''{0}''static int
ROLE_MISSING
Role ''{0}'' missingstatic int
ROLE_UNKNOWN
Role ''{0}'' is not among expected values ''{1}''static java.lang.String
ROLE_VERIF_PROBLEM_MSG
Error message used to group errors related to role problems.static int
WRONG_ROLE
Role of relation member does not match template expression ''{0}'' in preset {1}static int
WRONG_TYPE
Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3}-
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 RelationChecker()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.Map<Roles.Role,java.lang.String>
buildAllRoles(Relation n)
private static java.util.Map<java.lang.String,RelationChecker.RoleInfo>
buildRoleInfoMap(Relation n)
static java.util.List<Relation>
checkAddMember(Relation parent, Relation child)
Check if adding one relation to another would produce a circular dependency.private void
checkLoop(Relation r)
Check if a given relation is part of a circular dependency loop.private void
checkLoop(Relation parent, java.util.List<Relation> path)
private boolean
checkMemberExpressionAndType(java.util.Map<Roles.Role,java.lang.String> allroles, RelationMember member, Relation n)
get all role definition for specified key and check, if some definition matchesprivate static boolean
checkMemberType(Roles.Role r, RelationMember member)
private void
checkRoleCounts(Relation n, Roles.Role r, java.lang.String keyname, RelationChecker.RoleInfo ri)
private void
checkRoles(Relation n, java.util.Map<Roles.Role,java.lang.String> allroles, java.util.Map<java.lang.String,RelationChecker.RoleInfo> map)
void
endTest()
Notification of the end of the test.Command
fixError(TestError testError)
Fixes the error with the appropriate commandvoid
initialize()
Initializes any global data used this tester.static void
initializePresets()
Reads the presets data.boolean
isFixable(TestError testError)
Returns true if the given error can be fixed automaticallyvoid
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitorvoid
taggingPresetsModified()
Called after list of tagging presets has been modified.void
visit(Relation n)
Visiting call for relations.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, clear, deletePrimitivesIfNeeded, getErrors, getName, getSource, isBuilding, isCanceled, isPrimitiveUsable, isResidentialArea, ok, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit, visit, visit
-
-
-
-
Field Detail
-
ROLE_UNKNOWN
public static final int ROLE_UNKNOWN
Role ''{0}'' is not among expected values ''{1}''- See Also:
- Constant Field Values
-
ROLE_EMPTY
public static final int ROLE_EMPTY
Empty role found when expecting one of ''{0}''- See Also:
- Constant Field Values
-
HIGH_COUNT
public static final int HIGH_COUNT
Number of ''{0}'' roles too high ({1})- See Also:
- Constant Field Values
-
LOW_COUNT
public static final int LOW_COUNT
Number of ''{0}'' roles too low ({1})- See Also:
- Constant Field Values
-
ROLE_MISSING
public static final int ROLE_MISSING
Role ''{0}'' missing- See Also:
- Constant Field Values
-
RELATION_UNKNOWN
public static final int RELATION_UNKNOWN
Relation type is unknown- See Also:
- Constant Field Values
-
WRONG_ROLE
public static final int WRONG_ROLE
Role of relation member does not match template expression ''{0}'' in preset {1}- See Also:
- Constant Field Values
-
WRONG_TYPE
public static final int WRONG_TYPE
Type ''{0}'' of relation member with role ''{1}'' does not match accepted types ''{2}'' in preset {3}- See Also:
- Constant Field Values
-
RELATION_LOOP
public static final int RELATION_LOOP
Relations build circular dependencies- See Also:
- Constant Field Values
-
RELATION_EMPTY
public static final int RELATION_EMPTY
Relation is empty- See Also:
- Constant Field Values
-
ALLOW_COMPLEX_LOOP
private static final BooleanProperty ALLOW_COMPLEX_LOOP
-
ROLE_VERIF_PROBLEM_MSG
public static final java.lang.String ROLE_VERIF_PROBLEM_MSG
Error message used to group errors related to role problems.- Since:
- 6731
-
ignoreMultiPolygons
private boolean ignoreMultiPolygons
-
ignoreTurnRestrictions
private boolean ignoreTurnRestrictions
-
relationpresets
private static final java.util.Collection<TaggingPreset> relationpresets
-
-
Constructor Detail
-
RelationChecker
public RelationChecker()
Constructor
-
-
Method Detail
-
initialize
public void initialize()
Description copied from class:Test
Initializes any global data used this tester.- Overrides:
initialize
in classTest
-
initializePresets
public static void initializePresets()
Reads the presets data.
-
startTest
public void startTest(ProgressMonitor progressMonitor)
Description copied from class:Test
Start the test using a given progress monitor
-
visit
public void visit(Relation n)
Description copied from interface:OsmPrimitiveVisitor
Visiting call for relations.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in classTest
- Parameters:
n
- The relation to inspect.
-
buildRoleInfoMap
private static java.util.Map<java.lang.String,RelationChecker.RoleInfo> buildRoleInfoMap(Relation n)
-
buildAllRoles
private static java.util.Map<Roles.Role,java.lang.String> buildAllRoles(Relation n)
-
checkMemberType
private static boolean checkMemberType(Roles.Role r, RelationMember member)
-
checkMemberExpressionAndType
private boolean checkMemberExpressionAndType(java.util.Map<Roles.Role,java.lang.String> allroles, RelationMember member, Relation n)
get all role definition for specified key and check, if some definition matches- Parameters:
allroles
- containing list of possible role presets of the membermember
- to be verifiedn
- relation to be verified- Returns:
true
if member passed any of definition within preset
-
checkRoles
private void checkRoles(Relation n, java.util.Map<Roles.Role,java.lang.String> allroles, java.util.Map<java.lang.String,RelationChecker.RoleInfo> map)
- Parameters:
n
- relation to validateallroles
- contains presets for specified relationmap
- contains statistics of occurrences of specified role in relation
-
checkRoleCounts
private void checkRoleCounts(Relation n, Roles.Role r, java.lang.String keyname, RelationChecker.RoleInfo ri)
-
fixError
public Command fixError(TestError testError)
Description copied from class:Test
Fixes the error with the appropriate command
-
isFixable
public boolean isFixable(TestError testError)
Description copied from class:Test
Returns true if the given error can be fixed automatically
-
taggingPresetsModified
public void taggingPresetsModified()
Description copied from interface:TaggingPresetListener
Called after list of tagging presets has been modified.- Specified by:
taggingPresetsModified
in interfaceTaggingPresetListener
-
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).
-
checkLoop
private void checkLoop(Relation r)
Check if a given relation is part of a circular dependency loop.- Parameters:
r
- the relation
-
checkAddMember
public static java.util.List<Relation> checkAddMember(Relation parent, Relation child)
Check if adding one relation to another would produce a circular dependency.- Parameters:
parent
- the relation which would be changedchild
- the child relation which should be added to parent- Returns:
- An unmodifiable list of relations which is empty when no circular dependency was found,
else it contains the relations that form circular dependencies.
The list then contains at least two items. Normally first and last item are both
parent
, but if child is already part of a circular dependency the returned list may not end withparent
.
-
-