Class DuplicateRelation
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.tests.DuplicateRelation
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
public class DuplicateRelation extends Test
Tests if there are duplicate relations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDuplicateRelation.RelationMembersClass to store relation membersprivate static classDuplicateRelation.RelationPairClass to store relation data (keys are usually cleanup and may not be equal to original relation)static classDuplicateRelation.RelMemberClass to store one relation members and information about it-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDUPLICATE_RELATIONCode number of completely duplicated relation errorprivate static java.lang.StringDUPLICATED_RELATIONSprotected static intIDENTICAL_MEMBERLISTCode number of relation with same members errorprotected static intSAME_RELATIONCode number of relation with same members error(package private) java.util.List<Relation>visitedList of all initially visited testable relations-
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 DuplicateRelation()Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidaddToRelations(MultiMap<DuplicateRelation.RelationPair,Relation> relations, Relation r, boolean forceAdd)private voidcheckOrderAndTags(java.util.Set<Relation> sameMembers)Check a list of relations which are guaranteed to have the same members, possibly in different order and possibly different tags.private static java.util.Map<java.lang.String,java.lang.String>cleanedKeys(OsmPrimitive p)return tags of a primitive after removing all discardable tagsvoidendTest()Notification of the end of the test.CommandfixError(TestError testError)Fix the error by removing all but one instance of duplicate relationsprivate static java.util.List<RelationMember>getSortedMembers(Relation r)Order members of given relation by type, unique id, and role.private static booleanignoredType(Relation r)booleanisFixable(TestError testError)Returns true if the given error can be fixed automaticallyprivate static booleanmemberOrderMatters(Relation r)private voidperformChecks()private voidperformGeometryTest(MultiMap<DuplicateRelation.RelationPair,Relation> relations)private voidreportDuplicateKeys(java.util.Collection<Relation> duplicated)Check collection of relations with the same keys and members, possibly in different orderprivate voidreportDuplicateMembers(java.util.Set<Relation> duplicated)Report relations with the same member(s) in the same order, keys may be differentvoidstartTest(ProgressMonitor monitor)Start the test using a given progress monitorvoidvisit(Relation r)Visiting call for relations.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, clear, deletePrimitivesIfNeeded, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isPrimitiveUsable, isResidentialArea, ok, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit, visit, visit
-
-
-
-
Field Detail
-
DUPLICATED_RELATIONS
private static final java.lang.String DUPLICATED_RELATIONS
-
DUPLICATE_RELATION
protected static final int DUPLICATE_RELATION
Code number of completely duplicated relation error- See Also:
- Constant Field Values
-
SAME_RELATION
protected static final int SAME_RELATION
Code number of relation with same members error- See Also:
- Constant Field Values
-
IDENTICAL_MEMBERLIST
protected static final int IDENTICAL_MEMBERLIST
Code number of relation with same members error- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DuplicateRelation
public DuplicateRelation()
Default constructor
-
-
Method Detail
-
startTest
public void startTest(ProgressMonitor monitor)
Description copied from class:TestStart the test using a given progress monitor
-
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).
-
performChecks
private void performChecks()
-
performGeometryTest
private void performGeometryTest(MultiMap<DuplicateRelation.RelationPair,Relation> relations)
-
addToRelations
private static void addToRelations(MultiMap<DuplicateRelation.RelationPair,Relation> relations, Relation r, boolean forceAdd)
-
visit
public void visit(Relation r)
Description copied from interface:OsmPrimitiveVisitorVisiting call for relations.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
r- The relation to inspect.
-
checkOrderAndTags
private void checkOrderAndTags(java.util.Set<Relation> sameMembers)
Check a list of relations which are guaranteed to have the same members, possibly in different order and possibly different tags.- Parameters:
sameMembers- the list of relations
-
reportDuplicateKeys
private void reportDuplicateKeys(java.util.Collection<Relation> duplicated)
Check collection of relations with the same keys and members, possibly in different order- Parameters:
duplicated- collection of relations, caller must make sure that they have the same keys and members
-
reportDuplicateMembers
private void reportDuplicateMembers(java.util.Set<Relation> duplicated)
Report relations with the same member(s) in the same order, keys may be different- Parameters:
duplicated- collection of relations with identical member list
-
memberOrderMatters
private static boolean memberOrderMatters(Relation r)
-
ignoredType
private static boolean ignoredType(Relation r)
-
cleanedKeys
private static java.util.Map<java.lang.String,java.lang.String> cleanedKeys(OsmPrimitive p)
return tags of a primitive after removing all discardable tags- Parameters:
p- the primitive- Returns:
- map with cleaned tags
-
getSortedMembers
private static java.util.List<RelationMember> getSortedMembers(Relation r)
Order members of given relation by type, unique id, and role.- Parameters:
r- the relation- Returns:
- sorted list of members
-
fixError
public Command fixError(TestError testError)
Fix the error by removing all but one instance of duplicate relations- Overrides:
fixErrorin classTest- Parameters:
testError- The error to fix, must be of typeDUPLICATE_RELATION- Returns:
- The command to fix the error
-
-