Changeset 33413 in osm for applications
- Timestamp:
- 2017-06-23T22:52:03+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutAction.java
r33411 r33413 7 7 import java.util.ArrayList; 8 8 import java.util.Collection; 9 import java.util.Collections; 9 10 import java.util.HashMap; 10 11 import java.util.HashSet; … … 21 22 import org.openstreetmap.josm.actions.JosmAction; 22 23 import org.openstreetmap.josm.actions.SplitWayAction; 24 import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult; 23 25 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 24 26 import org.openstreetmap.josm.data.Bounds; … … 31 33 import org.openstreetmap.josm.data.osm.Way; 32 34 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 35 import org.openstreetmap.josm.tools.Pair; 33 36 34 37 /** … … 94 97 95 98 //save the position of the roundabout inside each relation 96 Map<Relation, Integer> savedPositions = getSavedPositions(roundabout);99 Map<Relation, List<Integer>> savedPositions = getSavedPositions(roundabout); 97 100 98 101 //split the roundabout on the designed nodes 99 102 List<Node> splitNodes = getSplitNodes(roundabout); 100 getLayerManager().getEditDataSet().setSelected(splitNodes); 101 new SplitWayAction().actionPerformed(null); 102 Collection<Way> splitWays = getLayerManager().getEditDataSet().getSelectedWays(); 103 SplitWayResult result = SplitWayAction.split(getLayerManager().getEditLayer(), 104 roundabout, splitNodes, Collections.emptyList()); 105 result.getCommand().executeCommand(); 106 Collection<Way> splitWays = result.getNewWays(); 107 splitWays.add(result.getOriginalWay()); 103 108 104 109 //update the relations. … … 106 111 } 107 112 108 public void updateRelations(Map<Relation, Integer> savedPositions,113 public void updateRelations(Map<Relation, List<Integer>> savedPositions, 109 114 List<Node> splitNodes, Collection<Way> splitWays) { 110 savedPositions.forEach((r, i) -> { 111 Way previous = r.getMember(i-1).getWay(); 112 Way subsequent = r.getMember(i).getWay(); 113 Node entryNode; 114 Node exitNode; 115 116 //checking if the previous way enters the roundabout and the 117 //subsequent exits it 118 if(splitNodes.contains(previous.lastNode())) 119 entryNode = previous.lastNode(); 120 else if(splitNodes.contains(previous.firstNode())) 121 entryNode = previous.firstNode(); 122 else 123 entryNode = null; 124 125 if(splitNodes.contains(subsequent.firstNode())) 126 exitNode = subsequent.firstNode(); 127 else if (splitNodes.contains(subsequent.lastNode())) 128 exitNode = subsequent.lastNode(); 129 else 130 exitNode = null; 131 132 //if not, exit 133 if(entryNode == null || exitNode == null) 134 return; 135 136 //starting from the entry node, add split ways until the 137 //exit node is reached 138 List<Way> parents = entryNode.getParentWays(); 139 parents.removeIf(w -> !w.firstNode().equals(entryNode)); 140 parents.removeIf(w -> w.equals(previous)); 141 142 Way curr = parents.get(0); 143 int j = 0; 144 145 while(!curr.lastNode().equals(exitNode)) { 146 r.addMember(i + j++, new RelationMember(null, curr)); 147 parents = curr.lastNode().getParentWays(); 148 parents.remove(curr); 149 parents.removeIf(w -> !splitWays.contains(w)); 150 curr = parents.get(0); 151 } 152 r.addMember(i + j++, new RelationMember(null, curr)); 153 }); 115 Map<Relation, Integer> memberOffset = new HashMap<>(); 116 savedPositions.forEach((r, positions) -> 117 positions.forEach(i -> { 118 119 if(!memberOffset.containsKey(r)) 120 memberOffset.put(r, 0); 121 int offset = memberOffset.get(r); 122 123 Pair<Way, Way> entryExitWays= getEntryExitWays(r, i + offset); 124 Way entryWay = entryExitWays.a; 125 Way exitWay = entryExitWays.b; 126 127 //get the entry and exit nodes, exit if not found 128 Node entryNode = getNodeInCommon(splitNodes, entryWay); 129 Node exitNode = getNodeInCommon(splitNodes, exitWay); 130 131 if(entryNode == null || exitNode == null) 132 return; 133 134 //starting from the entry node, add split ways until the 135 //exit node is reached 136 List<Way> parents = entryNode.getParentWays(); 137 parents.removeIf(w -> !w.firstNode().equals(entryNode)); 138 parents.removeIf(w -> w.equals(entryWay)); 139 140 Way curr = parents.get(0); 141 142 while(!curr.lastNode().equals(exitNode)) { 143 r.addMember(i + offset++, new RelationMember(null, curr)); 144 parents = curr.lastNode().getParentWays(); 145 parents.remove(curr); 146 parents.removeIf(w -> !splitWays.contains(w)); 147 curr = parents.get(0); 148 } 149 r.addMember(i + offset++, new RelationMember(null, curr)); 150 memberOffset.put(r, offset); 151 })); 152 } 153 154 private Node getNodeInCommon(List<Node> nodes, Way way) { 155 if(nodes.contains(way.lastNode())) 156 return way.lastNode(); 157 else if(nodes.contains(way.firstNode())) 158 return way.firstNode(); 159 160 return null; 161 } 162 163 //given a relation and the position where the roundabout was, it returns 164 //the entry and exit ways of that occurrence of the roundabout 165 private Pair<Way, Way> getEntryExitWays(Relation r, Integer position) { 166 167 //the ways returned are the one exactly before and after the roundabout 168 Pair<Way, Way> ret = new Pair<>(null, null); 169 ret.a = r.getMember(position-1).getWay(); 170 ret.b = r.getMember(position).getWay(); 171 return ret; 154 172 } 155 173 … … 180 198 //save the position of the roundabout inside each public transport route 181 199 //it is contained in 182 public Map<Relation, Integer> getSavedPositions(Way roundabout) {183 184 Map<Relation, Integer> savedPositions = new HashMap<>();200 public Map<Relation, List<Integer>> getSavedPositions(Way roundabout) { 201 202 Map<Relation, List<Integer>> savedPositions = new HashMap<>(); 185 203 List <OsmPrimitive> referrers = roundabout.getReferrers(); 186 204 referrers.removeIf(r -> r.getType() != OsmPrimitiveType.RELATION 187 205 || !RouteUtils.isTwoDirectionRoute((Relation) r)); 206 188 207 for(OsmPrimitive currPrim : referrers) { 189 208 Relation curr = (Relation) currPrim; 190 209 for(int j = 0; j < curr.getMembersCount(); j++) { 191 210 if(curr.getMember(j).getUniqueId() == roundabout.getUniqueId()) { 192 savedPositions.put(curr, j); 193 curr.removeMember(j); 194 break; 211 if(!savedPositions.containsKey(curr)) 212 savedPositions.put(curr, new ArrayList<>()); 213 List<Integer> positions = savedPositions.get(curr); 214 positions.add(j - positions.size()); 195 215 } 196 216 } 217 218 if(savedPositions.containsKey(curr)) 219 curr.removeMembersFor(roundabout); 197 220 } 198 221 -
applications/editors/josm/plugins/pt_assistant/test/data/roundabout.osm
r33404 r33413 4 4 <bounds minlat='44.5332306' minlon='11.304646' maxlat='44.5340627' maxlon='11.3062432' origin='CGImap 0.6.0 (6173 thorn-01.openstreetmap.org)' /> 5 5 <bounds minlat='44.5163899' minlon='11.292683' maxlat='44.5170618' maxlon='11.2939724' origin='CGImap 0.6.0 (17818 thorn-01.openstreetmap.org)' /> 6 <node id='-33366' action='modify' lat='44.51580482382' lon='11.27400520274' /> 7 <node id='-33368' action='modify' lat='44.51585348183' lon='11.27400834786' /> 8 <node id='-33370' action='modify' lat='44.51591488142' lon='11.2740106863' /> 9 <node id='-33372' action='modify' lat='44.51597269638' lon='11.27400613888'> 10 <tag k='name' v='nentry1-1' /> 11 </node> 12 <node id='-33374' action='modify' lat='44.51617596609' lon='11.27394915048'> 13 <tag k='name' v='nentry1-2' /> 14 </node> 15 <node id='-33376' action='modify' lat='44.51616580606' lon='11.27390429158' /> 16 <node id='-33378' action='modify' lat='44.51614596976' lon='11.27386632505'> 17 <tag k='name' v='nentry3' /> 18 </node> 19 <node id='-33380' action='modify' lat='44.51611853145' lon='11.27383922098'> 20 <tag k='name' v='nexit2-1' /> 21 </node> 22 <node id='-33382' action='modify' lat='44.51607263223' lon='11.27382465414'> 23 <tag k='name' v='nentry2-2' /> 24 </node> 25 <node id='-33384' action='modify' lat='44.51602707289' lon='11.27383986598' /> 26 <node id='-33386' action='modify' lat='44.51599092016' lon='11.27388161688'> 27 <tag k='name' v='nexit3' /> 28 </node> 29 <node id='-33388' action='modify' lat='44.5159715354' lon='11.27394140565'> 30 <tag k='name' v='nexit1-2' /> 31 </node> 32 <node id='-33390' action='modify' lat='44.51599342131' lon='11.27406318588' /> 33 <node id='-33392' action='modify' lat='44.51602959601' lon='11.27410224215'> 34 <tag k='name' v='nexit2-2' /> 35 </node> 36 <node id='-33394' action='modify' lat='44.51607390916' lon='11.2741157542'> 37 <tag k='name' v='nentry2-1' /> 38 </node> 39 <node id='-33396' action='modify' lat='44.5161182879' lon='11.27410135232' /> 40 <node id='-33398' action='modify' lat='44.51615399505' lon='11.27406168769' /> 41 <node id='-33400' action='modify' lat='44.51617415248' lon='11.27400440082'> 42 <tag k='name' v='nexit1-1' /> 43 </node> 44 <node id='-33402' action='modify' lat='44.51622919031' lon='11.2740126815' /> 45 <node id='-33404' action='modify' lat='44.51628734499' lon='11.27401289328' /> 46 <node id='-33406' action='modify' lat='44.51628728362' lon='11.27395396983' /> 47 <node id='-33408' action='modify' lat='44.51623145663' lon='11.27395084803' /> 48 <node id='-33410' action='modify' lat='44.51591151791' lon='11.27392804314' /> 49 <node id='-33412' action='modify' lat='44.51584593388' lon='11.27392714153' /> 50 <node id='-33414' action='modify' lat='44.51580633132' lon='11.27392468203' /> 51 <node id='-33416' action='modify' lat='44.51607563657' lon='11.27430684936' /> 52 <node id='-33418' action='modify' lat='44.51607884646' lon='11.2742138158' /> 53 <node id='-33420' action='modify' lat='44.51611629528' lon='11.2737711561' /> 54 <node id='-33422' action='modify' lat='44.51611308539' lon='11.27366911929' /> 55 <node id='-33424' action='modify' lat='44.51604674746' lon='11.27367812253' /> 56 <node id='-33426' action='modify' lat='44.51604995736' lon='11.27375465014' /> 57 <node id='-33428' action='modify' lat='44.516028558' lon='11.27420481255' /> 58 <node id='-33430' action='modify' lat='44.51602427815' lon='11.27430234774' /> 59 <node id='-33432' action='modify' lat='44.51628204393' lon='11.273706037' /> 60 <node id='-33434' action='modify' lat='44.51619129335' lon='11.27379781873' /> 61 <node id='-33436' action='modify' lat='44.51595481762' lon='11.27382229386' /> 62 <node id='-33438' action='modify' lat='44.5159234038' lon='11.27377701487' /> 63 <node id='-33440' action='modify' lat='44.51586842956' lon='11.27368400938' /> 6 64 <node id='254635775' timestamp='2008-03-29T14:34:19Z' uid='20229' user='spezzi64' version='1' changeset='418502' lat='44.5106507' lon='11.2743674' /> 7 65 <node id='254636492' timestamp='2012-04-08T19:15:05Z' uid='188477' user='lerks' version='2' changeset='11229572' lat='44.5111921' lon='11.2745685' /> … … 1281 1339 <node id='4869942890' action='delete' timestamp='2017-05-22T13:55:39Z' uid='2457192' user='Loppi' version='1' changeset='48889488' lat='44.51458745388' lon='11.28100313851' /> 1282 1340 <node id='4869942891' action='modify' timestamp='2017-05-22T13:55:39Z' uid='2457192' user='Loppi' version='1' changeset='48889488' lat='44.51477561602' lon='11.28100523851' /> 1341 <way id='-34580' action='modify'> 1342 <nd ref='-33366' /> 1343 <nd ref='-33368' /> 1344 <tag k='highway' v='primary' /> 1345 </way> 1346 <way id='-34582' action='modify'> 1347 <nd ref='-33368' /> 1348 <nd ref='-33370' /> 1349 <nd ref='-33372' /> 1350 <tag k='highway' v='primary' /> 1351 <tag k='name' v='entry1-1' /> 1352 </way> 1353 <way id='-34584' action='modify'> 1354 <nd ref='-33374' /> 1355 <nd ref='-33376' /> 1356 <nd ref='-33378' /> 1357 <nd ref='-33380' /> 1358 <nd ref='-33382' /> 1359 <nd ref='-33384' /> 1360 <nd ref='-33386' /> 1361 <nd ref='-33388' /> 1362 <nd ref='-33372' /> 1363 <nd ref='-33390' /> 1364 <nd ref='-33392' /> 1365 <nd ref='-33394' /> 1366 <nd ref='-33396' /> 1367 <nd ref='-33398' /> 1368 <nd ref='-33400' /> 1369 <nd ref='-33374' /> 1370 <tag k='highway' v='primary' /> 1371 <tag k='junction' v='roundabout' /> 1372 <tag k='name' v='r4' /> 1373 </way> 1374 <way id='-34586' action='modify'> 1375 <nd ref='-33400' /> 1376 <nd ref='-33402' /> 1377 <nd ref='-33404' /> 1378 <tag k='highway' v='primary' /> 1379 <tag k='name' v='exit1-1' /> 1380 </way> 1381 <way id='-34588' action='modify'> 1382 <nd ref='-33404' /> 1383 <nd ref='-33406' /> 1384 <tag k='highway' v='primary' /> 1385 </way> 1386 <way id='-34590' action='modify'> 1387 <nd ref='-33406' /> 1388 <nd ref='-33408' /> 1389 <nd ref='-33374' /> 1390 <tag k='highway' v='primary' /> 1391 <tag k='name' v='entry1-2' /> 1392 </way> 1393 <way id='-34592' action='modify'> 1394 <nd ref='-33388' /> 1395 <nd ref='-33410' /> 1396 <tag k='highway' v='primary' /> 1397 <tag k='name' v='exit1-2' /> 1398 </way> 1399 <way id='-34594' action='modify'> 1400 <nd ref='-33410' /> 1401 <nd ref='-33412' /> 1402 <nd ref='-33414' /> 1403 <tag k='highway' v='primary' /> 1404 </way> 1405 <way id='-34596' action='modify'> 1406 <nd ref='-33416' /> 1407 <nd ref='-33418' /> 1408 <tag k='highway' v='primary' /> 1409 </way> 1410 <way id='-34598' action='modify'> 1411 <nd ref='-33418' /> 1412 <nd ref='-33394' /> 1413 <tag k='highway' v='primary' /> 1414 <tag k='name' v='entry2-1' /> 1415 </way> 1416 <way id='-34600' action='modify'> 1417 <nd ref='-33380' /> 1418 <nd ref='-33420' /> 1419 <nd ref='-33422' /> 1420 <tag k='highway' v='primary' /> 1421 <tag k='name' v='exit2-1' /> 1422 </way> 1423 <way id='-34602' action='modify'> 1424 <nd ref='-33422' /> 1425 <nd ref='-33424' /> 1426 <tag k='highway' v='primary' /> 1427 </way> 1428 <way id='-34604' action='modify'> 1429 <nd ref='-33424' /> 1430 <nd ref='-33426' /> 1431 <nd ref='-33382' /> 1432 <tag k='highway' v='primary' /> 1433 <tag k='name' v='entry2-2' /> 1434 </way> 1435 <way id='-34606' action='modify'> 1436 <nd ref='-33392' /> 1437 <nd ref='-33428' /> 1438 <tag k='highway' v='primary' /> 1439 <tag k='name' v='exit2-2' /> 1440 </way> 1441 <way id='-34608' action='modify'> 1442 <nd ref='-33428' /> 1443 <nd ref='-33430' /> 1444 <tag k='highway' v='primary' /> 1445 </way> 1446 <way id='-34610' action='modify'> 1447 <nd ref='-33432' /> 1448 <nd ref='-33434' /> 1449 <tag k='highway' v='primary' /> 1450 </way> 1451 <way id='-34612' action='modify'> 1452 <nd ref='-33434' /> 1453 <nd ref='-33378' /> 1454 <tag k='highway' v='primary' /> 1455 <tag k='name' v='entry3' /> 1456 </way> 1457 <way id='-34614' action='modify'> 1458 <nd ref='-33386' /> 1459 <nd ref='-33436' /> 1460 <nd ref='-33438' /> 1461 <tag k='highway' v='primary' /> 1462 <tag k='name' v='exit3' /> 1463 </way> 1464 <way id='-34616' action='modify'> 1465 <nd ref='-33438' /> 1466 <nd ref='-33440' /> 1467 <tag k='highway' v='primary' /> 1468 </way> 1283 1469 <way id='23512811' timestamp='2015-07-24T23:15:22Z' uid='217070' user='Davlak' version='18' changeset='32862169'> 1284 1470 <nd ref='254636638' /> … … 1913 2099 <tag k='landuse' v='grass' /> 1914 2100 </way> 1915 <relation id='3494744' timestamp='2017-03-23T18:05:26Z' uid='339581' user='nyuriks' version='121' changeset='47103524'> 1916 <member type='way' ref='294951973' role='' /> 1917 <member type='way' ref='262051642' role='' /> 1918 <member type='way' ref='262543035' role='' /> 1919 <member type='way' ref='262170924' role='' /> 1920 <member type='way' ref='263052191' role='' /> 1921 <member type='way' ref='260422007' role='' /> 1922 <member type='way' ref='262721981' role='' /> 1923 <member type='way' ref='262868515' role='' /> 1924 <member type='way' ref='263210728' role='' /> 1925 <member type='way' ref='263318250' role='' /> 1926 <member type='way' ref='263461724' role='' /> 1927 <member type='way' ref='263510604' role='' /> 1928 <member type='way' ref='263531696' role='' /> 1929 <member type='way' ref='263587822' role='' /> 1930 <member type='way' ref='263591680' role='' /> 1931 <member type='way' ref='263592613' role='' /> 1932 <member type='way' ref='263623773' role='' /> 1933 <member type='way' ref='263625152' role='' /> 1934 <member type='way' ref='263665160' role='' /> 1935 <member type='way' ref='263744031' role='' /> 1936 <member type='way' ref='264284186' role='' /> 1937 <member type='way' ref='264450937' role='' /> 1938 <member type='way' ref='264550308' role='' /> 1939 <member type='way' ref='264940865' role='' /> 1940 <member type='way' ref='264946783' role='' /> 1941 <member type='way' ref='264948095' role='' /> 1942 <member type='way' ref='265001332' role='' /> 1943 <member type='way' ref='265038317' role='' /> 1944 <member type='way' ref='265043150' role='' /> 1945 <member type='way' ref='265073327' role='' /> 1946 <member type='way' ref='265359177' role='' /> 1947 <member type='relation' ref='3497980' role='' /> 1948 <member type='relation' ref='3500659' role='' /> 1949 <member type='relation' ref='3503470' role='' /> 1950 <member type='relation' ref='3511205' role='' /> 1951 <member type='relation' ref='3511206' role='' /> 1952 <member type='relation' ref='3510853' role='' /> 1953 <member type='relation' ref='3515482' role='' /> 1954 <member type='relation' ref='3515483' role='' /> 1955 <member type='relation' ref='3518435' role='' /> 1956 <member type='relation' ref='3521346' role='' /> 1957 <member type='relation' ref='3522658' role='' /> 1958 <member type='relation' ref='3524206' role='' /> 1959 <member type='relation' ref='3524695' role='' /> 1960 <member type='relation' ref='3527653' role='' /> 1961 <member type='relation' ref='3502111' role='' /> 1962 <member type='relation' ref='3520374' role='' /> 1963 <member type='relation' ref='3536343' role='' /> 1964 <member type='relation' ref='3536313' role='' /> 1965 <member type='relation' ref='3533000' role='' /> 1966 <member type='relation' ref='3536041' role='' /> 1967 <member type='relation' ref='3537738' role='' /> 1968 <member type='relation' ref='3537966' role='' /> 1969 <member type='relation' ref='3542735' role='' /> 1970 <member type='relation' ref='3542737' role='' /> 1971 <member type='relation' ref='3540182' role='' /> 1972 <member type='relation' ref='3548332' role='' /> 1973 <member type='relation' ref='3548872' role='' /> 1974 <member type='relation' ref='3559907' role='' /> 1975 <member type='relation' ref='3562103' role='' /> 1976 <member type='relation' ref='3562426' role='' /> 1977 <member type='relation' ref='3562535' role='' /> 1978 <member type='relation' ref='3565893' role='' /> 1979 <member type='relation' ref='3566431' role='' /> 1980 <member type='way' ref='375134601' role='' /> 1981 <member type='way' ref='265387877' role='' /> 1982 <member type='way' ref='375111785' role='' /> 1983 <member type='way' ref='265409435' role='' /> 1984 <member type='way' ref='265421585' role='' /> 1985 <member type='way' ref='265427998' role='' /> 1986 <member type='way' ref='265550313' role='' /> 1987 <member type='relation' ref='3568349' role='' /> 1988 <member type='way' ref='265561143' role='' /> 1989 <member type='way' ref='265562148' role='' /> 1990 <member type='way' ref='265569858' role='' /> 1991 <member type='relation' ref='3568452' role='' /> 1992 <member type='way' ref='265587741' role='' /> 1993 <member type='way' ref='265592267' role='' /> 1994 <member type='way' ref='347745790' role='' /> 1995 <member type='way' ref='294376691' role='' /> 1996 <member type='way' ref='265600432' role='' /> 1997 <member type='way' ref='265613756' role='' /> 1998 <member type='way' ref='265631809' role='' /> 1999 <member type='relation' ref='3569420' role='' /> 2000 <member type='relation' ref='3569500' role='' /> 2001 <member type='relation' ref='3569653' role='' /> 2002 <member type='relation' ref='3570648' role='' /> 2003 <member type='relation' ref='3571543' role='' /> 2004 <member type='relation' ref='3503470' role='' /> 2005 <member type='relation' ref='3579698' role='' /> 2101 <relation id='-34689' action='modify'> 2102 <member type='way' ref='-34580' role='' /> 2103 <member type='way' ref='-34582' role='' /> 2104 <member type='way' ref='-34584' role='' /> 2105 <member type='way' ref='-34586' role='' /> 2106 <member type='way' ref='-34588' role='' /> 2107 <member type='way' ref='-34590' role='' /> 2108 <member type='way' ref='-34584' role='' /> 2109 <member type='way' ref='-34592' role='' /> 2110 <member type='way' ref='-34594' role='' /> 2111 <tag k='name' v='1' /> 2112 <tag k='public_transport:version' v='2' /> 2113 <tag k='route' v='bus' /> 2114 <tag k='type' v='route' /> 2115 </relation> 2116 <relation id='-34691' action='modify'> 2117 <member type='way' ref='-34596' role='' /> 2118 <member type='way' ref='-34598' role='' /> 2119 <member type='way' ref='-34584' role='' /> 2120 <member type='way' ref='-34600' role='' /> 2121 <member type='way' ref='-34602' role='' /> 2122 <member type='way' ref='-34604' role='' /> 2123 <member type='way' ref='-34584' role='' /> 2124 <member type='way' ref='-34606' role='' /> 2125 <member type='way' ref='-34608' role='' /> 2126 <tag k='name' v='2' /> 2127 <tag k='public_transport:version' v='2' /> 2128 <tag k='route' v='bus' /> 2129 <tag k='type' v='route' /> 2130 </relation> 2131 <relation id='-34693' action='modify'> 2132 <member type='way' ref='-34610' role='' /> 2133 <member type='way' ref='-34612' role='' /> 2134 <member type='way' ref='-34584' role='' /> 2135 <member type='way' ref='-34614' role='' /> 2136 <member type='way' ref='-34616' role='' /> 2137 <tag k='public_transport:version' v='2' /> 2138 <tag k='route' v='bus' /> 2139 <tag k='type' v='route' /> 2140 </relation> 2141 <relation id='3494744' action='delete' timestamp='2017-03-23T18:05:26Z' uid='339581' user='nyuriks' version='121' changeset='47103524'> 2006 2142 <tag k='alt_name' v='Natura 2000 Emilia Romagna' /> 2007 2143 <tag k='name' v='Parchi Aree protette Natura 2000 Emilia Romagna' /> … … 2012 2148 <tag k='wikipedia' v='it:Natura 2000' /> 2013 2149 </relation> 2014 <relation id='3510569' timestamp='2017-03-23T18:05:27Z' uid='339581' user='nyuriks' version='45' changeset='47103524'> 2015 <member type='way' ref='263461724' role='' /> 2016 <member type='way' ref='262051642' role='' /> 2017 <member type='way' ref='262721981' role='' /> 2018 <member type='way' ref='262868515' role='' /> 2019 <member type='way' ref='260422007' role='' /> 2020 <member type='way' ref='263623773' role='' /> 2021 <member type='way' ref='263625152' role='' /> 2022 <member type='way' ref='263744031' role='' /> 2023 <member type='way' ref='264284186' role='' /> 2024 <member type='way' ref='264450937' role='' /> 2025 <member type='way' ref='264550308' role='' /> 2026 <member type='way' ref='264940865' role='' /> 2027 <member type='way' ref='264946783' role='' /> 2028 <member type='way' ref='264948095' role='' /> 2029 <member type='relation' ref='3500659' role='' /> 2030 <member type='relation' ref='3511206' role='' /> 2031 <member type='relation' ref='3511205' role='' /> 2032 <member type='relation' ref='3510853' role='' /> 2033 <member type='relation' ref='3515482' role='' /> 2034 <member type='relation' ref='3515483' role='' /> 2035 <member type='relation' ref='3537738' role='' /> 2036 <member type='relation' ref='3522658' role='' /> 2037 <member type='relation' ref='3518435' role='' /> 2038 <member type='relation' ref='3542735' role='' /> 2039 <member type='relation' ref='3542737' role='' /> 2040 <member type='relation' ref='3540182' role='' /> 2041 <member type='relation' ref='3548332' role='' /> 2042 <member type='relation' ref='3548872' role='' /> 2043 <member type='relation' ref='3559907' role='' /> 2044 <member type='way' ref='265001332' role='' /> 2045 <member type='way' ref='265038317' role='' /> 2046 <member type='way' ref='265043150' role='' /> 2047 <member type='relation' ref='3562103' role='' /> 2048 <member type='way' ref='265073327' role='' /> 2049 <member type='relation' ref='3562426' role='' /> 2050 <member type='relation' ref='3562535' role='' /> 2051 <member type='way' ref='265359177' role='' /> 2052 <member type='relation' ref='3565893' role='' /> 2053 <member type='way' ref='266074918' role='' /> 2054 <member type='relation' ref='3574678' role='' /> 2055 <member type='relation' ref='3579698' role='' /> 2056 <member type='way' ref='266573184' role='' /> 2057 <member type='relation' ref='3579847' role='' /> 2150 <relation id='3510569' action='delete' timestamp='2017-03-23T18:05:27Z' uid='339581' user='nyuriks' version='45' changeset='47103524'> 2058 2151 <tag k='name' v='Parchi regionali Provincia Bologna' /> 2059 2152 <tag k='operator' v='Natura 2000' /> … … 2063 2156 <tag k='wikipedia' v='it:Natura 2000' /> 2064 2157 </relation> 2065 <relation id='3542735' action='modify' timestamp='2017-01-04T00:43:15Z' uid='339581' user='nyuriks' version='5' changeset='44886932'> 2066 <member type='way' ref='263746207' role='outer' /> 2158 <relation id='3542735' action='delete' timestamp='2017-01-04T00:43:15Z' uid='339581' user='nyuriks' version='5' changeset='44886932'> 2067 2159 <tag k='WDPA_ID:ref' v='555528771' /> 2068 2160 <tag k='allocation:it' v='Il sito è localizzato nella periferia Nord della conurbazione bolognese e comprende un tratto di circa 2 km del fiume Reno, con le relative golene, che inizia circa 500 metri a Nord dell’Autostrada' /> … … 2993 3085 <tag k='via' v='Rigosa' /> 2994 3086 </relation> 2995 <relation id='6741375' timestamp='2016-11-26T10:46:14Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 2996 <member type='node' ref='280693382' role='stop' /> 2997 <member type='way' ref='455938776' role='platform' /> 2998 <member type='node' ref='4523145490' role='' /> 3087 <relation id='6741375' action='delete' timestamp='2016-11-26T10:46:14Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 2999 3088 <tag k='name' v='Ariosto' /> 3000 3089 <tag k='network' v='TPER' /> … … 3002 3091 <tag k='type' v='public_transport' /> 3003 3092 </relation> 3004 <relation id='6741377' timestamp='2016-11-26T10:46:15Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 3005 <member type='node' ref='3464979206' role='stop' /> 3006 <member type='way' ref='455938807' role='platform' /> 3007 <member type='node' ref='4523145524' role='' /> 3008 <member type='node' ref='3464967730' role='stop' /> 3009 <member type='way' ref='455938805' role='platform' /> 3010 <member type='node' ref='4523145521' role='' /> 3093 <relation id='6741377' action='delete' timestamp='2016-11-26T10:46:15Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 3011 3094 <tag k='name' v='Triumvirato' /> 3012 3095 <tag k='network' v='TPER' /> … … 3014 3097 <tag k='type' v='public_transport' /> 3015 3098 </relation> 3016 <relation id='6741378' timestamp='2016-11-26T10:46:15Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 3017 <member type='node' ref='2975209406' role='stop' /> 3018 <member type='way' ref='455938811' role='platform' /> 3019 <member type='node' ref='4523145528' role='' /> 3020 <member type='node' ref='2975202792' role='stop' /> 3021 <member type='way' ref='455938809' role='platform' /> 3022 <member type='node' ref='4523145527' role='' /> 3099 <relation id='6741378' action='delete' timestamp='2016-11-26T10:46:15Z' uid='362997' user='Virgile1994' version='1' changeset='43961143'> 3023 3100 <tag k='name' v='Acquedotto Triumvirato' /> 3024 3101 <tag k='network' v='TPER' /> -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutTest.java
r33412 r33413 41 41 private OsmDataLayer layer; 42 42 private SplitRoundaboutAction action; 43 private Way r1, r2, r3; 43 private Way r1, r2, r3, r4; 44 44 45 45 @Before … … 54 54 r2 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(205833435L, OsmPrimitiveType.WAY)); 55 55 r3 = (Way) ds.getPrimitiveById(new SimplePrimitiveId(25739002L, OsmPrimitiveType.WAY)); 56 r4 = (Way) ds.getPrimitives(p -> p.hasTag("name", "r4")).iterator().next(); 56 57 } 57 58 58 59 private Collection<Way> splitWay(Way w) { 59 Map<Relation, Integer> savedPositions = action.getSavedPositions(w);60 Map<Relation, List<Integer>> savedPositions = action.getSavedPositions(w); 60 61 List<Node> splitNodes = action.getSplitNodes(w); 61 assertEquals(4, splitNodes.size());62 62 SplitWayResult result = SplitWayAction.split(layer, w, splitNodes, Collections.emptyList()); 63 63 result.getCommand().executeCommand(); 64 64 Collection<Way> splitWays = result.getNewWays(); 65 splitWays.add(result.getOriginalWay()); 65 66 action.updateRelations(savedPositions, splitNodes, splitWays); 66 67 return splitWays; … … 69 70 @Test 70 71 public void test1() { 71 splitWay(r1).forEach(w -> { 72 if (w.firstNode().getUniqueId() == 267843779L && w.lastNode().getUniqueId() == 2968718407L) 72 Collection<Way> sw1 = splitWay(r1); 73 assertEquals(4, sw1.size()); 74 sw1.forEach(w -> { 75 if (w.firstNode().getUniqueId() == 267843779L && w.lastNode().getUniqueId() == 2968718407L) 73 76 assertEquals(w.getReferrers().size(), 5); 74 77 else if (w.firstNode().getUniqueId() == 2968718407L && w.lastNode().getUniqueId() == 2383688231L) … … 85 88 @Test 86 89 public void test2() { 87 splitWay(r2).forEach(w -> { 90 Collection<Way> sw2 = splitWay(r2); 91 assertEquals(4, sw2.size()); 92 sw2.forEach(w -> { 88 93 if(w.firstNode().getUniqueId() == 2158181809L && w.lastNode().getUniqueId() == 2158181798L) 89 94 assertEquals(w.getReferrers().size(), 8); … … 101 106 @Test 102 107 public void test3() { 103 splitWay(r3).forEach(w -> { 108 Collection<Way> sw3 = splitWay(r3); 109 assertEquals(4, sw3.size()); 110 sw3.forEach(w -> { 104 111 if(w.firstNode().getUniqueId() == 280697532L && w.lastNode().getUniqueId() == 280697452L) 105 112 assertEquals(w.getReferrers().size(), 0); … … 114 121 }); 115 122 } 123 124 @Test 125 public void test4() { 126 Collection<Way> sw4 = splitWay(r4); 127 assertEquals(10, sw4.size()); 128 Node entry11 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nentry1-1")).iterator().next(); 129 Node exit11 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nexit1-1")).iterator().next(); 130 Node entry12 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nentry1-2")).iterator().next(); 131 Node exit12 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nexit1-2")).iterator().next(); 132 Node entry21 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nentry2-1")).iterator().next(); 133 Node exit21 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nexit2-1")).iterator().next(); 134 Node entry22 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nentry2-2")).iterator().next(); 135 Node exit22 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nexit2-2")).iterator().next(); 136 Node entry3 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nentry3")).iterator().next(); 137 Node exit3 = (Node) ds.getPrimitives(p -> p.hasTag("name", "nexit3")).iterator().next(); 138 139 sw4.forEach(w -> { 140 if(w.firstNode().equals(entry11) && w.lastNode().equals(exit22)) 141 assertEquals(2, w.getReferrers().size()); 142 else if(w.firstNode().equals(exit22) && w.lastNode().equals(entry21)) 143 assertEquals(1, w.getReferrers().size()); 144 else if(w.firstNode().equals(entry21) && w.lastNode().equals(exit11)) 145 assertEquals(2, w.getReferrers().size()); 146 else if(w.firstNode().equals(exit11) && w.lastNode().equals(entry12)) 147 assertEquals(1, w.getReferrers().size()); 148 else if(w.firstNode().equals(entry12) && w.lastNode().equals(entry3)) 149 assertEquals(2, w.getReferrers().size()); 150 else if(w.firstNode().equals(entry3) && w.lastNode().equals(exit21)) 151 assertEquals(3, w.getReferrers().size()); 152 else if(w.firstNode().equals(exit21) && w.lastNode().equals(entry22)) 153 assertEquals(2, w.getReferrers().size()); 154 else if(w.firstNode().equals(entry22) && w.lastNode().equals(exit3)) 155 assertEquals(3, w.getReferrers().size()); 156 else if(w.firstNode().equals(exit3) && w.lastNode().equals(exit12)) 157 assertEquals(2, w.getReferrers().size()); 158 else if(w.firstNode().equals(exit12) && w.lastNode().equals(entry11)) 159 assertEquals(1, w.getReferrers().size()); 160 else 161 fail(); 162 }); 163 } 116 164 }
Note:
See TracChangeset
for help on using the changeset viewer.