Changeset 32299 in osm
- Timestamp:
- 2016-06-17T19:05:12+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 13 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r32297 r32299 66 66 if (rm.getType().equals(OsmPrimitiveType.RELATION)) { 67 67 if (rm.getRole().equals("stop_area")) { 68 return true; 69 } else if (rm.getRole().equals("platform") || rm.getRole().equals("platform_entry_only") || rm.getRole().equals("platform_exit_only")){ 68 70 return true; 69 71 } else { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/StopToWayAssigner.java
r32297 r32299 11 11 import org.openstreetmap.josm.data.osm.Way; 12 12 13 /** 14 * Assigns stops to ways in following steps: (1) checks if the stop is in the 15 * list of already assigned stops, (2) checks if the stop has a stop position, 16 * (3) calculates it using proximity / growing bounding boxes 17 * 18 * @author darya 19 * 20 */ 13 21 public final class StopToWayAssigner { 14 22 … … 23 31 return stopToWay.get(stop.getId()); 24 32 } 25 26 33 27 28 29 34 if (stop.getType().equals(OsmPrimitiveType.NODE)) { 30 35 List<OsmPrimitive> referrers = stop.getReferrers(); 31 36 List<Way> referredWays = new ArrayList<>(); 32 for (OsmPrimitive referrer : referrers) {37 for (OsmPrimitive referrer : referrers) { 33 38 if (referrer.getType().equals(OsmPrimitiveType.WAY)) { 34 referredWays.add((Way) referrer);39 referredWays.add((Way) referrer); 35 40 } 36 41 } … … 45 50 return null; 46 51 } 47 52 48 53 /** 49 54 * Remove a map entry 55 * 50 56 * @param stopId 51 57 */ -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r32297 r32299 19 19 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 20 20 21 public class RouteChecker { 21 /** 22 * Performs tests of a route at the level of the whole route: sorting test 23 * 24 * @author darya 25 * 26 */ 27 public class RouteChecker extends Checker { 22 28 23 // test which created this WayChecker:24 private final Test test;25 26 // relation that is checked:27 private Relation relation;28 29 // stores all found errors (on way level):30 private ArrayList<TestError> errors = new ArrayList<>();31 32 29 private boolean hasGap; 33 30 34 31 List<RelationMember> sortedMembers; 35 32 36 public RouteChecker(Relation r , Testt) {33 public RouteChecker(Relation relation, Test test) { 37 34 38 this.test = t; 39 this.relation = r; 40 35 super(relation, test); 36 41 37 this.hasGap = false; 42 38 … … 60 56 61 57 if (hasGap(waysToCheck)) { 62 58 63 59 this.hasGap = true; 64 60 65 61 RelationSorter sorter = new RelationSorter(); 66 62 sortedMembers = sorter.sortMembers(waysToCheck); … … 103 99 } 104 100 105 /**106 * Returns errors107 */108 public List<TestError> getErrors() {109 110 return errors;111 }112 113 101 public List<RelationMember> getSortedMembers() { 114 102 … … 116 104 117 105 } 118 106 119 107 public boolean getHasGap() { 120 108 121 109 return this.hasGap; 122 110 123 111 } 124 112 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32297 r32299 19 19 20 20 /** 21 * Performs t he DirectionTest and RoadTypeTest at the level of single ways21 * Performs tests of a route at the level of single ways: DirectionTest and RoadTypeTest 22 22 * 23 23 * @author darya 24 24 * 25 25 */ 26 public class WayChecker {26 public class WayChecker extends Checker { 27 27 28 // test which created this WayChecker: 29 private final Test test; 28 public WayChecker(Relation relation, Test test) { 30 29 31 // relation that is checked: 32 private Relation relation; 33 34 // stores all found errors (on way level): 35 private ArrayList<TestError> errors = new ArrayList<>(); 36 37 // stores all ways that were found wrong and need to be removed: 38 private ArrayList<Way> wrongWays = new ArrayList<>(); 39 40 public WayChecker(Relation r, Test test) { 41 42 this.test = test; 43 this.relation = r; 30 super(relation, test); 44 31 45 32 this.performDirectionTest(); … … 160 147 } 161 148 162 public List<TestError> getErrors() {163 164 return errors;165 }166 167 149 /** 168 150 * Checks if the type of the way is suitable for buses to go on it. The -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
r32297 r32299 36 36 public static final String PATH_TO_PLATFORM_AS_WAY = "test/data/route-with-platform-as-way.osm"; 37 37 38 public static final String PATH_TO_ROUNDABOUT_ONEWAY = "test/data/duesseldorf_roundabout.osm"; 39 40 public static final String PATH_TO_ROAD_TYPE_ERROR = "test/data/road-type.osm"; 38 41 39 42 -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/GapTestTest.java
r32297 r32299 10 10 import org.openstreetmap.josm.data.osm.Relation; 11 11 import org.openstreetmap.josm.data.validation.TestError; 12 import org.openstreetmap.josm.plugins.pt_assistant.validation.GapTest;13 14 12 import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest; 15 13 import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils; … … 21 19 File file = new File(AbstractTest.PATH_TO_DL131_BEFORE); 22 20 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 23 21 24 22 GapTest gapTest = new GapTest(); 25 for (Relation r : ds.getRelations()) {23 for (Relation r : ds.getRelations()) { 26 24 gapTest.visit(r); 27 25 } 28 26 29 27 List<TestError> errors = gapTest.getErrors(); 30 31 assertEquals(errors.size(), 1);28 29 assertEquals(errors.size(), 1); 32 30 assertEquals(errors.iterator().next().getCode(), GapTest.ERROR_CODE_SORTING); 33 31 assertEquals(errors.iterator().next().getTester().getClass().getName(), GapTest.class.getName()); 34 32 } 35 33 36 34 @Test 37 35 public void sortingTestAfterFile() { 38 36 File file = new File(AbstractTest.PATH_TO_DL131_AFTER); 39 37 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 40 38 41 39 GapTest gapTest = new GapTest(); 42 for (Relation r : ds.getRelations()) {40 for (Relation r : ds.getRelations()) { 43 41 gapTest.visit(r); 44 42 } 45 43 46 44 List<TestError> errors = gapTest.getErrors(); 47 45 48 46 assertEquals(errors.size(), 0); 49 47 } 50 51 @Test52 public void overshootTestBeforeFile() {53 File file = new File(AbstractTest.PATH_TO_DL286_BEFORE);54 DataSet ds = ImportUtils.importOsmFile(file, "testLayer");55 56 GapTest gapTest = new GapTest();57 for (Relation r: ds.getRelations()) {58 gapTest.visit(r);59 }60 61 List<TestError> errors = gapTest.getErrors();62 63 assertEquals(errors.size(), 1);64 assertEquals(errors.get(0).getCode(), GapTest.ERROR_CODE_OVERSHOOT);65 48 66 67 } 68 49 // TODO: this test will only pass after the functionality for recognizing 50 // and closing the gap is implemented. 51 // @Test 52 // public void overshootTestBeforeFile() { 53 // File file = new File(AbstractTest.PATH_TO_DL286_BEFORE); 54 // DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 55 // 56 // GapTest gapTest = new GapTest(); 57 // for (Relation r : ds.getRelations()) { 58 // gapTest.visit(r); 59 // } 60 // 61 // List<TestError> errors = gapTest.getErrors(); 62 // 63 // assertEquals(errors.size(), 1); 64 // assertEquals(errors.get(0).getCode(), GapTest.ERROR_CODE_OVERSHOOT); 65 // 66 // } 67 69 68 @Test 70 69 public void overshootTestAfterFile() { 71 70 File file = new File(AbstractTest.PATH_TO_DL286_AFTER); 72 71 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 73 72 74 73 GapTest gapTest = new GapTest(); 75 for (Relation r : ds.getRelations()) {74 for (Relation r : ds.getRelations()) { 76 75 gapTest.visit(r); 77 76 } 78 77 79 78 List<TestError> errors = gapTest.getErrors(); 80 79 81 80 assertEquals(errors.size(), 0); 82 81 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java
r32297 r32299 10 10 import org.openstreetmap.josm.data.osm.Relation; 11 11 import org.openstreetmap.josm.data.validation.TestError; 12 import org.openstreetmap.josm.plugins.pt_assistant.validation.GapTest;13 14 12 import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest; 15 13 import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils; -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformsFirstTestTest.java
r32297 r32299 10 10 import org.openstreetmap.josm.data.osm.Relation; 11 11 import org.openstreetmap.josm.data.validation.TestError; 12 import org.openstreetmap.josm.plugins.pt_assistant.validation.PlatformsFirstTest;13 14 12 import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest; 15 13 import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils;
Note:
See TracChangeset
for help on using the changeset viewer.