Changeset 1423 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-02-17T18:30:00+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1400 r1423 147 147 return nodes.size() >= 3 && lastNode() == firstNode(); 148 148 } 149 149 150 150 public Node lastNode() { 151 151 return nodes.get(nodes.size()-1); 152 152 } 153 153 154 154 public Node firstNode() { 155 155 return nodes.get(0); 156 156 } 157 157 158 158 public boolean isFirstLastNode(Node n) { 159 159 return n == firstNode() || n == lastNode(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1415 r1423 518 518 Way fromWay = null; 519 519 Way toWay = null; 520 Node via = null;520 OsmPrimitive via = null; 521 521 522 522 /* find the "from", "via" and "to" elements */ … … 557 557 toWay = w; 558 558 } 559 } else if("via".equals(m.role)) { 560 if(via != null) 561 r.putError(tr("More than one \"via\" found."), true); 562 else 563 via = w; 559 564 } 560 565 else … … 565 570 Node n = (Node) m.member; 566 571 if("via".equals(m.role)) 572 { 567 573 if(via != null) 568 System.out.println("More than one \"via\" found.");569 else {574 r.putError(tr("More than one \"via\" found."), true); 575 else 570 576 via = n; 571 577 } 572 578 else 573 579 r.putError(tr("Unknown role ''{0}''.", m.role), true); … … 587 593 } 588 594 if (via == null) { 589 r.putError(tr("No \"via\" node found."), true);595 r.putError(tr("No \"via\" node or way found."), true); 590 596 return; 591 597 } 592 598 593 /* check if "from" way starts or ends at via */ 594 if(fromWay.nodes.get(0) != via && fromWay.nodes.get(fromWay.nodes.size()-1) != via) { 595 r.putError(tr("The \"from\" way doesn't start or end at a \"via\" node."), true); 596 return; 597 } 598 /* check if "to" way starts or ends at via */ 599 /*if(toWay.nodes.get(0) != via && toWay.nodes.get(toWay.nodes.size()-1) != via) { 600 r.putError(tr("to way doesn't start or end at a via node"), true); 601 return; 602 }*/ 599 Node viaNode; 600 if(via instanceof Node) 601 { 602 viaNode = (Node) via; 603 if(!fromWay.isFirstLastNode(viaNode)) { 604 r.putError(tr("The \"from\" way doesn't start or end at a \"via\" node."), true); 605 return; 606 } 607 if(!toWay.isFirstLastNode(viaNode)) 608 r.putError(tr("The \"to\" way doesn't start or end at a \"via\" node."), true); 609 } 610 else 611 { 612 Way viaWay = (Way) via; 613 Node firstNode = viaWay.firstNode(); 614 Node lastNode = viaWay.lastNode(); 615 if(fromWay.isFirstLastNode(firstNode)) 616 viaNode = firstNode; 617 else if(fromWay.isFirstLastNode(lastNode)) 618 viaNode = firstNode; 619 else { 620 r.putError(tr("The \"from\" way doesn't start or end at the \"via\" way."), true); 621 return; 622 } 623 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) 624 r.putError(tr("The \"to\" way doesn't start or end at the \"via\" way."), true); 625 } 603 626 604 627 /* find the "direct" nodes before the via node */ 605 628 Node fromNode = null; 606 try 607 { 608 if(fromWay.nodes.get(0) == via) { 609 //System.out.println("From way heading away from via"); 610 fromNode = fromWay.nodes.get(1); 611 } else { 612 //System.out.println("From way heading towards via"); 613 fromNode = fromWay.nodes.get(fromWay.nodes.size()-2); 614 } 615 } catch (IndexOutOfBoundsException ioobe) { 616 r.putError(tr("The \"{0}\" way must contain at least 2 nodes.", "from"), true); 617 } 618 629 if(fromWay.firstNode() == via) { 630 //System.out.println("From way heading away from via"); 631 fromNode = fromWay.nodes.get(1); 632 } else { 633 //System.out.println("From way heading towards via"); 634 fromNode = fromWay.nodes.get(fromWay.nodes.size()-2); 635 } 636 637 Point pFrom = nc.getPoint(fromNode.eastNorth); 638 Point pVia = nc.getPoint(viaNode.eastNorth); 639 640 //if(restrictionDebug) { 619 641 /* find the "direct" node after the via node */ 620 Node toNode = null; 621 try 622 { 623 if(toWay.nodes.get(0) == via) { 624 //if(restrictionDebug) 625 // System.out.println("To way heading away from via"); 626 toNode = toWay.nodes.get(1); 627 } else { 628 //if(restrictionDebug) 629 // System.out.println("To way heading towards via"); 630 toNode = toWay.nodes.get(toWay.nodes.size()-2); 631 } 632 } catch (IndexOutOfBoundsException ioobe) { 633 r.putError(tr("The \"{0}\" way must contain at least 2 nodes.", "to"), true); 634 } 635 636 Point pFrom = nc.getPoint(fromNode.eastNorth); 637 Point pVia = nc.getPoint(via.eastNorth); 638 639 //if(restrictionDebug) { 642 // Node toNode = null; 643 // if(toWay.firstNode() == via) { 644 // System.out.println("To way heading away from via"); 645 // toNode = toWay.nodes.get(1); 646 // } else { 647 // System.out.println("To way heading towards via"); 648 // toNode = toWay.nodes.get(toWay.nodes.size()-2); 649 // } 640 650 // Point pTo = nc.getPoint(toNode.eastNorth); 641 651 … … 681 691 90degrees away from the first segment of the "from" way) 682 692 */ 683 double distanceFromWay= 8;693 double distanceFromWay=10; 684 694 double vx2 = 0; 685 695 double vy2 = 0;
Note:
See TracChangeset
for help on using the changeset viewer.