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 classRelationChecker.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 BooleanPropertyALLOW_COMPLEX_LOOPstatic intHIGH_COUNTNumber of ''{0}'' roles too high ({1})private booleanignoreMultiPolygonsprivate booleanignoreTurnRestrictionsprivate java.util.List<java.util.List<Relation>>loopsstatic intLOW_COUNTNumber of ''{0}'' roles too low ({1})static intRELATION_EMPTYRelation is emptystatic intRELATION_LOOPRelations build circular dependenciesstatic intRELATION_UNKNOWNRelation type is unknownprivate static java.util.Collection<TaggingPreset>relationpresetsstatic intROLE_EMPTYEmpty role found when expecting one of ''{0}''static intROLE_MISSINGRole ''{0}'' missingstatic intROLE_UNKNOWNRole ''{0}'' is not among expected values ''{1}''static java.lang.StringROLE_VERIF_PROBLEM_MSGError message used to group errors related to role problems.static intWRONG_ROLERole of relation member does not match template expression ''{0}'' in preset {1}static intWRONG_TYPEType ''{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 voidcheckLoop(Relation r)Check if a given relation is part of a circular dependency loop.private voidcheckLoop(Relation parent, java.util.List<Relation> path)private booleancheckMemberExpressionAndType(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 booleancheckMemberType(Roles.Role r, RelationMember member)private voidcheckRoleCounts(Relation n, Roles.Role r, java.lang.String keyname, RelationChecker.RoleInfo ri)private voidcheckRoles(Relation n, java.util.Map<Roles.Role,java.lang.String> allroles, java.util.Map<java.lang.String,RelationChecker.RoleInfo> map)voidendTest()Notification of the end of the test.CommandfixError(TestError testError)Fixes the error with the appropriate commandvoidinitialize()Initializes any global data used this tester.static voidinitializePresets()Reads the presets data.booleanisFixable(TestError testError)Returns true if the given error can be fixed automaticallyvoidstartTest(ProgressMonitor progressMonitor)Start the test using a given progress monitorvoidtaggingPresetsModified()Called after list of tagging presets has been modified.voidvisit(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:TestInitializes any global data used this tester.- Overrides:
initializein classTest
-
initializePresets
public static void initializePresets()
Reads the presets data.
-
startTest
public void startTest(ProgressMonitor progressMonitor)
Description copied from class:TestStart the test using a given progress monitor
-
visit
public void visit(Relation n)
Description copied from interface:OsmPrimitiveVisitorVisiting call for relations.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin 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:
trueif 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:TestFixes the error with the appropriate command
-
isFixable
public boolean isFixable(TestError testError)
Description copied from class:TestReturns true if the given error can be fixed automatically
-
taggingPresetsModified
public void taggingPresetsModified()
Description copied from interface:TaggingPresetListenerCalled after list of tagging presets has been modified.- Specified by:
taggingPresetsModifiedin interfaceTaggingPresetListener
-
endTest
public void endTest()
Description copied from class:TestNotification 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.
-
-