#12885 closed enhancement (fixed)
[patch] Modify OsmValidator class to add new tests
Reported by: | darya | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 16.05 |
Component: | Core validator | Version: | |
Keywords: | OsmValidator, GSoC | Cc: | darya |
Description (last modified by )
I'm creating a JOSM plugin to validate public transport routes. I want the results to appear in the existing Validator window. To do that, I need the possibility to add additional Test classes to the org.openstreetmap.josm.data.validation.OsmValidator
class.
A possible fix for my needs would be:
1) Change the class attribute private static final allAvailableTests
to private static allAvailableTests
2) Add method:
public static void addTest(Class newTestClass) { Class<Test>[] newTestArray = new Class[allAvailableTests.length+1]; for (int i=0; i<allAvailableTests.length; i++) { newTestArray[i] = allAvailableTests[i]; } newTestArray[newTestArray.length-1] = newTestClass; allAvailableTests = newTestArray; try { allTestsMap.put(newTestClass.getName(), (Test)newTestClass.getConstructor().newInstance()); } catch(ReflectiveOperationException e) { Main.error(e); } }
An alternative solution would be to change the method OsmValidator.getAllTestsMap()
from
public static SortedMap<String, Test> getAllTestsMap() { applyPrefs(allTestsMap, false); return new TreeMap<>(allTestsMap); }
to
public static SortedMap<String, Test> getAllTestsMap() { applyPrefs(allTestsMap, false); TreeMap<String, Test> sortedMap = new TreeMap<>(allTestsMap); allTestsMap = sortedMap; return sortedMap; }
Thank you in advance!
Attachments (0)
Change History (8)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
Summary: | Modify OsmValidator class to add new tests → [patch] Modify OsmValidator class to add new tests |
---|
follow-up: 5 comment:3 by , 9 years ago
comment:5 by , 9 years ago
Keywords: | GSoC added |
---|
Replying to Don-vip:
Does your plugin only add validator tests?
This part of the GSoC project, so there is probably more.
In general, I think this is (was) a valid request.
comment:6 by , 9 years ago
No, the plugin will also have the functionality to fix problems, e.g. if the public transport route has a gap. Yes, it is within the GSoC, summary here: https://summerofcode.withgoogle.com/projects/#4678354603081728
I think it would imply too many modifications to the core if I were to put it there. Besides, not every JOSM user will need to validate public transport routes, so it belongs into a plugin.
Does your plugin only add validator tests? If so, you can simply write a new test in JOSM core and propose it as a patch. There are already too many plugins for public transport.