Class MapCSSTagChecker
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.Test.TagTest
-
- org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker
-
- All Implemented Interfaces:
OsmPrimitiveVisitor
- Direct Known Subclasses:
MapCSSTagChecker.MapCSSTagCheckerAndRule
public class MapCSSTagChecker extends Test.TagTest
MapCSS-based tag checker/fixer.- Since:
- 6506
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
MapCSSTagChecker.AssertionConsumer
A handler for assertion error messages (for not fulfilled "assertMatch", "assertNoMatch").(package private) static class
MapCSSTagChecker.MapCSSTagCheckerAndRule
static class
MapCSSTagChecker.ParseResult
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static boolean
ALL_TESTS
(package private) MultiMap<String,MapCSSTagCheckerRule>
checks
static String
ENTRIES_PREF_KEY
The preference key for tag checker source entries.private MapCSSStyleIndex
indexData
private static Map<IPrimitive,Area>
mpAreaCache
(package private) static boolean
ONLY_SELECTED_TESTS
private static CachingProperty<Boolean>
PREF_OTHER
Cached version ofValidatorPrefHelper.PREF_OTHER
, see #20745.private Map<MapCSSRule,MapCSSTagChecker.MapCSSTagCheckerAndRule>
ruleToCheckMap
private static Set<IPrimitive>
toMatchForSurrounding
private Map<String,String>
urlTitles
maps the source URL for a test to the title shown in the dialog where known-
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 MapCSSTagChecker()
Constructs a newMapCSSTagChecker
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
addIfNotSimilar(TestError toAdd, List<TestError> errors)
See #12627 Add error to given list if list doesn't already contain a similar error.MapCSSTagChecker.ParseResult
addMapCSS(String url)
Adds a new MapCSS config file from the given URL.(package private) MapCSSTagChecker.ParseResult
addMapCSS(String url, MapCSSTagChecker.AssertionConsumer assertionConsumer)
void
check(OsmPrimitive p)
Visiting call for primitives.(package private) static MapCSSStyleIndex
createMapCSSTagCheckerIndex(MultiMap<String,MapCSSTagCheckerRule> checks, boolean includeOtherSeverity, boolean allTests)
void
endTest()
Notification of the end of the test.private static String
findURLTitle(String url)
Find a user friendly string for the url.Collection<TestError>
getErrorsForPrimitive(OsmPrimitive p, boolean includeOtherSeverity)
(package private) static Collection<TestError>
getErrorsForPrimitive(OsmPrimitive p, boolean includeOtherSeverity, Collection<Set<MapCSSTagCheckerRule>> checksCol)
private String
getTitle(String url)
void
initialize()
Initializes any global data used this tester.static void
reloadRule(SourceEntry rule)
Reload tagchecker rule.void
startTest(ProgressMonitor progressMonitor)
Start the test using a given progress monitorprivate void
testPartial(MultiMap<String,MapCSSTagCheckerRule> currentCheck, Set<OsmPrimitive> tested, Set<OsmPrimitive> surrounding)
private void
visit(String url, Set<MapCSSTagCheckerRule> checksForUrl, Collection<OsmPrimitive> selection, Set<OsmPrimitive> surrounding)
Perform the checks for one check urlvoid
visit(Collection<OsmPrimitive> selection)
Visits all primitives to be tested.(package private) void
visit(Collection<OsmPrimitive> selection, Predicate<String> urlPredicate)
Execute the rules from the URLs matching the given predicate.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test.TagTest
includeOtherSeverityChecks, visit, visit, visit
-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, clear, deletePrimitivesIfNeeded, fixError, getErrors, getName, getSource, isBuilding, isCanceled, isFixable, isPrimitiveUsable, isResidentialArea, ok, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload
-
-
-
-
Field Detail
-
indexData
private MapCSSStyleIndex indexData
-
ruleToCheckMap
private final Map<MapCSSRule,MapCSSTagChecker.MapCSSTagCheckerAndRule> ruleToCheckMap
-
mpAreaCache
private static final Map<IPrimitive,Area> mpAreaCache
-
toMatchForSurrounding
private static final Set<IPrimitive> toMatchForSurrounding
-
ALL_TESTS
static final boolean ALL_TESTS
- See Also:
- Constant Field Values
-
ONLY_SELECTED_TESTS
static final boolean ONLY_SELECTED_TESTS
- See Also:
- Constant Field Values
-
PREF_OTHER
private static final CachingProperty<Boolean> PREF_OTHER
Cached version ofValidatorPrefHelper.PREF_OTHER
, see #20745.
-
ENTRIES_PREF_KEY
public static final String ENTRIES_PREF_KEY
The preference key for tag checker source entries.- Since:
- 6670
-
checks
final MultiMap<String,MapCSSTagCheckerRule> checks
-
-
Constructor Detail
-
MapCSSTagChecker
public MapCSSTagChecker()
Constructs a newMapCSSTagChecker
.
-
-
Method Detail
-
createMapCSSTagCheckerIndex
static MapCSSStyleIndex createMapCSSTagCheckerIndex(MultiMap<String,MapCSSTagCheckerRule> checks, boolean includeOtherSeverity, boolean allTests)
-
getErrorsForPrimitive
public Collection<TestError> getErrorsForPrimitive(OsmPrimitive p, boolean includeOtherSeverity)
- Parameters:
p
- The OSM primitiveincludeOtherSeverity
- iftrue
, errors of severitySeverity.OTHER
(info) will also be returned- Returns:
- all errors for the given primitive, with or without those of "info" severity
-
addIfNotSimilar
private static void addIfNotSimilar(TestError toAdd, List<TestError> errors)
See #12627 Add error to given list if list doesn't already contain a similar error. Similar means same code and description and same combination of primitives and same combination of highlighted objects, but maybe with different orders.- Parameters:
toAdd
- the error to adderrors
- the list of errors
-
getErrorsForPrimitive
static Collection<TestError> getErrorsForPrimitive(OsmPrimitive p, boolean includeOtherSeverity, Collection<Set<MapCSSTagCheckerRule>> checksCol)
-
check
public void check(OsmPrimitive p)
Visiting call for primitives.- Specified by:
check
in classTest.TagTest
- Parameters:
p
- The primitive to inspect.
-
addMapCSS
public MapCSSTagChecker.ParseResult addMapCSS(String url) throws org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException, IOException
Adds a new MapCSS config file from the given URL.- Parameters:
url
- The unique URL of the MapCSS config file- Returns:
- List of tag checks and parsing errors, or null
- Throws:
org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
- if the config file does not match MapCSS syntaxIOException
- if any I/O error occurs- Since:
- 7275
-
addMapCSS
MapCSSTagChecker.ParseResult addMapCSS(String url, MapCSSTagChecker.AssertionConsumer assertionConsumer) throws org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException, IOException
- Throws:
org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException
IOException
-
findURLTitle
private static String findURLTitle(String url)
Find a user friendly string for the url.- Parameters:
url
- the source for the set of rules- Returns:
- a value that can be used in tool tip or progress bar.
-
initialize
public void initialize() throws Exception
Description copied from class:Test
Initializes any global data used this tester.- Overrides:
initialize
in classTest
- Throws:
Exception
- When cannot initialize the test
-
reloadRule
public static void reloadRule(SourceEntry rule)
Reload tagchecker rule.- Parameters:
rule
- tagchecker rule to reload- Since:
- 12825
-
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).
-
visit
public void visit(Collection<OsmPrimitive> selection)
Description copied from class:Test
Visits all primitives to be tested. These primitives are always visited in the same order: nodes first, then ways.
-
visit
void visit(Collection<OsmPrimitive> selection, Predicate<String> urlPredicate)
Execute the rules from the URLs matching the given predicate.- Parameters:
selection
- collection of primitivesurlPredicate
- a predicate deciding whether the rules from the given URL shall be executed
-
visit
private void visit(String url, Set<MapCSSTagCheckerRule> checksForUrl, Collection<OsmPrimitive> selection, Set<OsmPrimitive> surrounding)
Perform the checks for one check url- Parameters:
url
- the url for the checkschecksForUrl
- the checks to performselection
- collection primitivessurrounding
- surrounding primitives, evtl. filled by this routine
-
testPartial
private void testPartial(MultiMap<String,MapCSSTagCheckerRule> currentCheck, Set<OsmPrimitive> tested, Set<OsmPrimitive> surrounding)
-
-