Changeset 32797 in osm for applications/editors


Ignore:
Timestamp:
2016-08-11T18:40:15+02:00 (8 years ago)
Author:
darya
Message:

clarification stop area test

Location:
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java

    r32793 r32797  
    7171        public void clearFixVariants() {
    7272                fixVariants.clear();
     73                wayColoring.clear();
    7374                Main.map.mapView.repaint();
    7475        }
     
    274275
    275276                if (event.getRemovedLayer() instanceof OsmDataLayer) {
    276 
    277277                        this.primitives.clear();
     278                        this.fixVariants.clear();
     279                        this.wayColoring.clear();
    278280                        Main.map.mapView.repaint();
    279281                }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java

    r32794 r32797  
    55import java.awt.Graphics;
    66import java.awt.Point;
    7 import java.awt.Polygon;
    87import java.util.ArrayList;
    98import java.util.Collections;
     
    2625import org.openstreetmap.josm.tools.Pair;
    2726
    28 import com.sun.org.apache.bcel.internal.generic.CPInstruction;
    29 
    3027public class PTAssistantPaintVisitor extends PaintVisitor {
    3128
     
    407404                        HashMap<Way, List<Character>> wayColoring) {
    408405
    409 //              drawFixVariantsWithParallelLines(wayColoring);
     406                drawFixVariantsWithParallelLines(wayColoring, fixVariants.size());
    410407
    411408                Color[] colors = { new Color(255, 0, 0, 150), new Color(0, 255, 0, 150), new Color(0, 0, 255, 150),
     
    419416                for (Character c : fixVariants.keySet()) {
    420417                        if (fixVariants.get(c) != null) {
    421                                 drawFixVariant(fixVariants.get(c), colors[colorIndex % 5]);
     418                                // drawFixVariant(fixVariants.get(c), colors[colorIndex % 5]);
    422419                                drawFixVariantLetter(c.toString(), colors[colorIndex % 5], letterX, letterY);
    423420                                colorIndex++;
     
    451448         * @param wayColoring
    452449         */
    453         protected void drawFixVariantsWithParallelLines(Map<Way, List<Character>> wayColoring) {
     450        protected void drawFixVariantsWithParallelLines(Map<Way, List<Character>> wayColoring, int numberOfFixVariants) {
    454451
    455452                HashMap<Character, Color> colors = new HashMap<>();
    456                 colors.put('A', new Color(255, 0, 0, 150));
    457                 colors.put('B', new Color(0, 255, 0, 150));
    458                 colors.put('C', new Color(0, 0, 255, 150));
    459                 colors.put('D', new Color(255, 255, 0, 150));
    460                 colors.put('E', new Color(0, 255, 255, 150));
     453                colors.put('A', new Color(255, 0, 0, 200));
     454                colors.put('B', new Color(0, 255, 0, 200));
     455                colors.put('C', new Color(0, 0, 255, 200));
     456                colors.put('D', new Color(255, 255, 0, 200));
     457                colors.put('E', new Color(0, 255, 255, 200));
    461458
    462459                for (Way way : wayColoring.keySet()) {
    463460                        List<Character> letterList = wayColoring.get(way);
    464                         List<Color> wayColors = new ArrayList<>();
    465                         for (Character letter : letterList) {
    466                                 wayColors.add(colors.get(letter));
    467                         }
    468                         for (Pair<Node, Node> nodePair : way.getNodePairs(false)) {
    469                                 drawSegmentWithParallelLines(nodePair.a, nodePair.b, wayColors);
    470                         }
     461//                      if (letterList.size() != numberOfFixVariants) {
     462                                List<Color> wayColors = new ArrayList<>();
     463                                for (Character letter : letterList) {
     464                                        wayColors.add(colors.get(letter));
     465                                }
     466                                for (Pair<Node, Node> nodePair : way.getNodePairs(false)) {
     467                                        drawSegmentWithParallelLines(nodePair.a, nodePair.b, wayColors);
     468                                }
     469//                      }
    471470                }
    472471        }
     
    486485                Point p2 = mv.getPoint(n2);
    487486                double t = Math.atan2((double) p2.x - p1.x, (double) p2.y - p1.y);
    488                 // double cosT = 9 * Math.cos(t);
    489                 // double sinT = 9 * Math.sin(t);
     487                double cosT = 9 * Math.cos(t);
     488                double sinT = 9 * Math.sin(t);
     489                double heightCosT = 9 * Math.cos(t);
     490                double heightSinT = 9 * Math.sin(t);
     491
     492                double prevPointX = p1.x;
     493                double prevPointY = p1.y;
     494                double nextPointX = p1.x + heightSinT;
     495                double nextPointY = p1.y + heightCosT;
     496
     497                Color currentColor = colors.get(0);
     498                int i = 0;
     499                g.setColor(currentColor);
     500                g.fillOval((int) (p1.x - 9), (int) (p1.y - 9), 18, 18);
     501
     502                if (colors.size() == 1) {
     503                        int[] xPoints = { (int) (p1.x + cosT), (int) (p2.x + cosT), (int) (p2.x - cosT), (int) (p1.x - cosT) };
     504                        int[] yPoints = { (int) (p1.y - sinT), (int) (p2.y - sinT), (int) (p2.y + sinT), (int) (p1.y + sinT) };
     505                        g.setColor(currentColor);
     506                        g.fillPolygon(xPoints, yPoints, 4);
     507                } else {
     508                        boolean iterate = true;
     509//                      while (Math.abs(p2.x - p1.x) > Math.abs(nextPointX - p1.x) && Math.abs(p2.y - p1.y) > Math.abs(nextPointY - p1.y)) {
     510//                      while((p1.x < p2.x && nextPointX < p2.x) || (p1.x >= p2.x && nextPointX >= p2.x)) {
     511                        while (iterate) {
     512                                // for (int i = 0; i < colors.size(); i++) {
     513                                currentColor = colors.get(i % colors.size());
     514                                // if (Math.abs(p2.x - p1.x) > Math.abs(nextPointX - p1.x)) {
     515
     516                                int[] xPoints = { (int) (prevPointX + cosT), (int) (nextPointX + cosT), (int) (nextPointX - cosT),
     517                                                (int) (prevPointX - cosT) };
     518                                int[] yPoints = { (int) (prevPointY - sinT), (int) (nextPointY - sinT), (int) (nextPointY + sinT),
     519                                                (int) (prevPointY + sinT) };
     520                                g.setColor(currentColor);
     521                                g.fillPolygon(xPoints, yPoints, 4);
     522
     523                                prevPointX = prevPointX + heightSinT;
     524                                prevPointY = prevPointY + heightCosT;
     525                                nextPointX = nextPointX + heightSinT;
     526                                nextPointY = nextPointY + heightCosT;
     527                                i++;
     528                                if ((p1.x < p2.x && nextPointX >= p2.x) || (p1.x >= p2.x && nextPointX <= p2.x)) {
     529                                        iterate = false;
     530                                }
     531                               
     532                                // }
     533                                // }
     534                        }
     535
     536                        int[] lastXPoints = { (int) (prevPointX + cosT), (int) (p2.x + cosT), (int) (p2.x - cosT),
     537                                        (int) (prevPointX - cosT) };
     538                        int[] lastYPoints = { (int) (prevPointY - sinT), (int) (p2.y - sinT), (int) (p2.y + sinT),
     539                                        (int) (prevPointY + sinT) };
     540                        g.setColor(currentColor);
     541                        g.fillPolygon(lastXPoints, lastYPoints, 4);
     542                }
     543
     544                g.setColor(currentColor);
     545                g.fillOval((int) (p2.x - 9), (int) (p2.y - 9), 18, 18);
     546
     547                // double cosT = 20*Math.cos(t);
     548                // double sinT = 20*Math.sin(t);
     549                // int[] xPointsBasic = { (int) (p1.x + cosT/colors.size()/2), (int)
     550                // (p2.x + cosT/colors.size()/2),
     551                // (int) (p2.x - cosT/colors.size()/2), (int) (p1.x -
     552                // cosT/colors.size()/2) };
     553                // int[] yPointsBasic = { (int) (p1.y - sinT/colors.size()/2), (int)
     554                // (p2.y - sinT/colors.size()/2),
     555                // (int) (p2.y + sinT/colors.size()/2), (int) (p1.y +
     556                // sinT/colors.size()/2) };
    490557                //
    491                 // int[] xPoints = { (int) (p1.x + cosT), (int) (p2.x + cosT), (int)
    492                 // (p2.x - cosT), (int) (p1.x - cosT) };
    493                 // int[] yPoints = { (int) (p1.y - sinT), (int) (p2.y - sinT), (int)
    494                
    495                 double cosT = 9*Math.cos(t);
    496                 double sinT = 9*Math.sin(t);
    497                
    498                  int[] xPointsBasic = { (int) (p1.x + cosT/colors.size()), (int) (p2.x + cosT/colors.size()),
    499                  (int) (p2.x - cosT/colors.size()), (int) (p1.x - cosT/colors.size()) };
    500                  int[] yPointsBasic = { (int) (p1.y - sinT/colors.size()), (int) (p2.y - sinT/colors.size()),
    501                  (int) (p2.y + sinT/colors.size()), (int) (p1.y + sinT/colors.size()) };
    502                
    503                 for (int i = 0; i < colors.size(); i++) {
    504                         Polygon polygon = new Polygon(xPointsBasic, yPointsBasic, 4);
    505                         int halfStripeWidthCos = (int) cosT/colors.size();
    506                         int halfStripeWidthSin = (int) sinT / colors.size();
    507                         polygon.translate((int)(-cosT + halfStripeWidthCos*(i)*2), (int)(- sinT + halfStripeWidthSin*(i)*2));
    508                         g.setColor(colors.get(i));
    509                         g.fillPolygon(polygon);
    510                 }
    511                
    512                
    513 //              double cosT = 18 * Math.cos(t);
    514 //              double sinT = 18 * Math.sin(t);
    515 //              // int[] xPointsBasic = { (int) (p1.x + cosT), (int) (p2.x + cosT),
    516 //              // (int) (p2.x - cosT), (int) (p1.x - cosT) };
    517 //              // int[] yPointsBasic = { (int) (p1.y - sinT), (int) (p2.y - sinT),
    518 //              // (int) (p2.y + sinT), (int) (p1.y + sinT) };
    519 //
    520 //              for (int i = 0; i < colors.size(); i++) {
    521 //                      int[] xPoints = { (int) (p1.x - cosT / 2 + cosT / colors.size() *(i+0.5)),
    522 //                                      (int) (p2.x - cosT / 2 + cosT / colors.size() * (i+0.5)),
    523 //                                      (int) (p2.x - cosT / 2 + cosT / colors.size() * (i)),//
    524 //                                      (int) (p1.x - cosT / 2 + cosT / colors.size() * (i)) };//
    525 //                      int[] yPoints = { (int) (p1.y - sinT / 2 + sinT / colors.size() * (i)),//
    526 //                                      (int) (p2.y - sinT / 2 + sinT / colors.size() * (i)),//
    527 //                                      (int) (p2.y - sinT / 2 + sinT / colors.size() * (i+0.5)),
    528 //                                      (int) (p1.y - sinT / 2 + sinT / colors.size() * (i+0.5)) };
    529 //                      g.setColor(colors.get(i));
    530 //                      g.fillPolygon(xPoints, yPoints, 4);
    531 //              }
    532                
    533                
    534 
    535                 // int[] xPoints1 = { (int) (p1.x + cosT), (int) (p2.x + cosT), (int)
    536                 // (p2.x - cosT), (int) (p1.x - cosT) };
    537                 // int[] yPoints1 = { (int) (p1.y - sinT), (int) (p2.y - sinT), (int)
    538                 // (p2.y + sinT), (int) (p1.y + sinT) };
    539                 // Polygon polygon1 = new Polygon(xPointsBasic, yPointsBasic, 4);
    540                 // polygon1.translate((int)(4.5 * Math.cos(t)), (int)(4.5 *
    541                 // Math.sin(t)));
    542                 // g.setColor(colors.get(0));
    543                 // g.fillPolygon(polygon1);
    544                 //
    545                 // if (colors.size() > 1) {
    546                 // Polygon polygon2 = new Polygon(xPointsBasic, yPointsBasic, 4);
    547                 // polygon2.translate((int)(-4.5 * Math.cos(t)),
    548                 // (int)(-4.5*Math.sin(t)));
    549                 // g.setColor(colors.get(1));
    550                 // g.fillPolygon(polygon2);
     558                // for (int i = 0; i < colors.size(); i++) {
     559                // Polygon polygon = new Polygon(xPointsBasic, yPointsBasic, 4);
     560                // double halfStripeWidthCos = cosT/colors.size();
     561                // double halfStripeWidthSin = sinT/colors.size();
     562                //// polygon.translate((int)(-cosT + halfStripeWidthCos*(2*i+1)),
     563                // (int)(- sinT + halfStripeWidthSin*(2*i+1)));
     564                // int deltaX, deltaY;
     565                // if (cosT > 0) {
     566                // deltaX = (int)(-cosT + halfStripeWidthCos * (2*i+1));
     567                // } else {
     568                // deltaX = (int)(cosT - halfStripeWidthCos * (2*i+1));
    551569                // }
    552 
    553                 // double cosT = 9 * Math.cos(t);
    554                 // double sinT = 9 * Math.sin(t);
    555                 //
    556                 // int[] xPoints = { (int) (p1.x + cosT), (int) (p2.x + cosT), (int)
    557                 // (p2.x - cosT), (int) (p1.x - cosT) };
    558                 // int[] yPoints = { (int) (p1.y - sinT), (int) (p2.y - sinT), (int)
    559                 // (p2.y + sinT), (int) (p1.y + sinT) };
    560                 // g.setColor(color);
    561                 // g.fillPolygon(xPoints, yPoints, 4);
    562                 // g.fillOval((int) (p1.x - 9), (int) (p1.y - 9), 18, 18);
    563                 // g.fillOval((int) (p2.x - 9), (int) (p2.y - 9), 18, 18);
     570                // if (sinT > 0) {
     571                // deltaY = (int)(- sinT + halfStripeWidthSin*(2*i+1));
     572                // } else {
     573                // deltaY = (int)(sinT - halfStripeWidthSin*(2*i+1));
     574                // }
     575                // polygon.translate(deltaX, deltaY);
     576                // g.setColor(colors.get(i));
     577                // g.fillPolygon(polygon);
     578                // }
    564579        }
    565580
     
    568583                Font stringFont = new Font("SansSerif", Font.PLAIN, 50);
    569584                g.setFont(stringFont);
    570                 g.drawString(letter, (int) letterX, (int) letterY);
    571                 g.drawString(letter, (int) letterX, (int) letterY);
     585                try {
     586                        g.drawString(letter, (int) letterX, (int) letterY);
     587                        g.drawString(letter, (int) letterX, (int) letterY);
     588                } catch (NullPointerException ex) {
     589                        // do nothing
     590                }
     591
    572592        }
    573593
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java

    r32791 r32797  
    126126                        else if (referrer.get("public_transport") == "stop_area") {
    127127                                for (RelationMember stopAreaMember : referrer.getMembers()) {
    128                                         if (stopAreaMember.isNode()) {
    129                                                 Node stopAreaMemberFoo = stopAreaMember.getNode();
    130                                                 if (stopAreaMemberFoo.get("public_transport") == "platform") {
    131                                                         for (Relation stopAreaMemberReferrer : OsmPrimitive
    132                                                                         .getFilteredList(stopAreaMemberFoo.getReferrers(), Relation.class)) {
    133                                                                 if (stopAreaMemberReferrer.get("type") == "route") {
    134                                                                         platformRelationIds.put(stopAreaMemberReferrer.getId(),
    135                                                                                         stopAreaMemberReferrer.getId());
    136                                                                 }
     128                                        OsmPrimitive stopAreaMemberFoo = stopAreaMember.getMember();
     129                                        if (stopAreaMemberFoo.get("public_transport") == "platform") {
     130                                                for (Relation stopAreaMemberReferrer : OsmPrimitive
     131                                                                .getFilteredList(stopAreaMemberFoo.getReferrers(), Relation.class)) {
     132                                                        if (stopAreaMemberReferrer.get("type") == "route") {
     133                                                                platformRelationIds.put(stopAreaMemberReferrer.getId(), stopAreaMemberReferrer.getId());
    137134                                                        }
    138135                                                }
     
    140137                                }
    141138                        }
     139                }
     140
     141                // Check if the stop_position has no referrers at all. If it has no
     142                // referrers, then no error should be reported (changed on 11.08.2016 by
     143                // darya):
     144                if (stopPositionRelationIds.isEmpty()) {
     145                        return;
    142146                }
    143147
Note: See TracChangeset for help on using the changeset viewer.