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 class
DuplicateRelation.RelationMembers
Class to store relation membersprivate static class
DuplicateRelation.RelationPair
Class to store relation data (keys are usually cleanup and may not be equal to original relation)static class
DuplicateRelation.RelMember
Class 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 int
DUPLICATE_RELATION
Code number of completely duplicated relation errorprivate static java.lang.String
DUPLICATED_RELATIONS
protected static int
IDENTICAL_MEMBERLIST
Code number of relation with same members errorprotected static int
SAME_RELATION
Code number of relation with same members error(package private) java.util.List<Relation>
visited
List 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 void
addToRelations(MultiMap<DuplicateRelation.RelationPair,Relation> relations, Relation r, boolean forceAdd)
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.private static java.util.Map<java.lang.String,java.lang.String>
cleanedKeys(OsmPrimitive p)
return tags of a primitive after removing all discardable tagsvoid
endTest()
Notification of the end of the test.Command
fixError(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 boolean
ignoredType(Relation r)
boolean
isFixable(TestError testError)
Returns true if the given error can be fixed automaticallyprivate static boolean
memberOrderMatters(Relation r)
private void
performChecks()
private void
performGeometryTest(MultiMap<DuplicateRelation.RelationPair,Relation> relations)
private void
reportDuplicateKeys(java.util.Collection<Relation> duplicated)
Check collection of relations with the same keys and members, possibly in different orderprivate void
reportDuplicateMembers(java.util.Set<Relation> duplicated)
Report relations with the same member(s) in the same order, keys may be differentvoid
startTest(ProgressMonitor monitor)
Start the test using a given progress monitorvoid
visit(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: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).
-
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:OsmPrimitiveVisitor
Visiting call for relations.- Specified by:
visit
in interfaceOsmPrimitiveVisitor
- Overrides:
visit
in 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:
fixError
in classTest
- Parameters:
testError
- The error to fix, must be of typeDUPLICATE_RELATION
- Returns:
- The command to fix the error
-
-