Ignore:
Timestamp:
2009-02-16T15:14:34+01:00 (15 years ago)
Author:
stoecker
Message:

applied patch #2185 by bruce89

Location:
trunk/src/org/openstreetmap/josm/data
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r1398 r1415  
    55import java.util.Arrays;
    66import java.util.Collection;
    7 import java.util.Collections;
    87import java.util.Comparator;
    98import java.util.HashSet;
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r1200 r1415  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 import java.text.DecimalFormat;
    6 import java.text.NumberFormat;
    75
    86import org.openstreetmap.josm.Main;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r1226 r1415  
    6565     * If the bounding box has not been set (<code>min</code> or <code>max</code>
    6666     * equal <code>null</code>) this method does not do anything.
    67      *
    68      * @param enlargeDegree
    6967     */
    7068    public void enlargeBoundingBox() {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r1411 r1415  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1/* License: GPL. Copyright 2007 by Immanuel Scholz and others */
    22package org.openstreetmap.josm.data.osm.visitor;
     3
     4/* To enable debugging or profiling remove the double / signs */
    35
    46import static org.openstreetmap.josm.tools.I18n.marktr;
     
    4749    protected boolean drawRestriction;
    4850    protected boolean leftHandTraffic;
    49     protected boolean restrictionDebug;
     51    //protected boolean restrictionDebug;
    5052    protected int showNames;
    5153    protected int showIcons;
     
    7072    private EastNorth maxEN;
    7173
    72     protected int profilerVisibleNodes;
    73     protected int profilerVisibleWays;
    74     protected int profilerVisibleAreas;
    75     protected int profilerSegments;
    76     protected int profilerVisibleSegments;
    77     protected boolean profilerOmitDraw;
     74    //protected int profilerVisibleNodes;
     75    //protected int profilerVisibleWays;
     76    //protected int profilerVisibleAreas;
     77    //protected int profilerSegments;
     78    //protected int profilerVisibleSegments;
     79    //protected boolean profilerOmitDraw;
    7880
    7981    protected boolean isZoomOk(ElemStyle e) {
     
    8486            return (circum < 1500);
    8587
    86         // formula to calculate a map scale: natural size / map size = scale
    87         // example: 876000mm (876m as displayed) / 22mm (roughly estimated screen size of legend bar) = 39818
    88         //
    89         // so the exact "correcting value" below depends only on the screen size and resolution
    90         // XXX - do we need a Preference setting for this (if things vary widely)?
     88        /* formula to calculate a map scale: natural size / map size = scale
     89          example: 876000mm (876m as displayed) / 22mm (roughly estimated screen size of legend bar) = 39818
     90
     91          so the exact "correcting value" below depends only on the screen size and resolution
     92           XXX - do we need a Preference setting for this (if things vary widely)? */
    9193        return !(circum >= e.maxScale / 22 || circum < e.minScale / 22);
    9294    }
     
    132134     */
    133135    public void visit(Node n) {
    134         // check, if the node is visible at all
     136        /* check, if the node is visible at all */
    135137        if((n.eastNorth.east()  > maxEN.east() ) ||
    136138           (n.eastNorth.north() > maxEN.north()) ||
     
    145147        IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(n);
    146148
    147         if(profilerOmitDraw)
    148             return;
     149        //if(profilerOmitDraw)
     150        //    return;
    149151
    150152        if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist)
     
    171173        }
    172174
    173         // check, if the way is visible at all
     175        /* check, if the way is visible at all */
    174176        double minx = 10000;
    175177        double maxx = -10000;
     
    208210        if(wayStyle==null)
    209211        {
    210             // way without style
    211             profilerVisibleWays++;
    212             if(!profilerOmitDraw)
    213                 drawWay(w, null, untaggedColor, w.selected);
     212            /* way without style */
     213            //profilerVisibleWays++;
     214            //if(!profilerOmitDraw)
     215            drawWay(w, null, untaggedColor, w.selected);
    214216        }
    215217        else if(wayStyle instanceof LineElemStyle)
    216218        {
    217             // way with line style
    218             profilerVisibleWays++;
    219             if(!profilerOmitDraw)
    220                 drawWay(w, (LineElemStyle)wayStyle, untaggedColor, w.selected);
     219            /* way with line style */
     220            //profilerVisibleWays++;
     221            //if(!profilerOmitDraw)
     222            drawWay(w, (LineElemStyle)wayStyle, untaggedColor, w.selected);
    221223        }
    222224        else if (wayStyle instanceof AreaElemStyle)
    223225        {
    224             // way with area style
    225             if(!profilerOmitDraw)
    226             {
    227                 if (fillAreas > dist)
    228                 {
    229                     profilerVisibleAreas++;
    230                     drawArea(w, w.selected ? selectedColor : ((AreaElemStyle)wayStyle).color);
    231                     if(!w.isClosed())
    232                         w.putError(tr("Area style way is not closed."), true);
    233                 }
    234                 drawWay(w, ((AreaElemStyle)wayStyle).line, ((AreaElemStyle)wayStyle).color, w.selected);
    235             }
     226            /* way with area style */
     227            //if(!profilerOmitDraw)
     228            //{
     229            if (fillAreas > dist)
     230            {
     231            //    profilerVisibleAreas++;
     232                drawArea(w, w.selected ? selectedColor : ((AreaElemStyle)wayStyle).color);
     233                if(!w.isClosed())
     234                    w.putError(tr("Area style way is not closed."), true);
     235            }
     236            drawWay(w, ((AreaElemStyle)wayStyle).line, ((AreaElemStyle)wayStyle).color, w.selected);
     237            //}
    236238        }
    237239    }
    238240
    239241    public void drawWay(Way w, LineElemStyle l, Color color, Boolean selected) {
    240         // show direction arrows, if draw.segment.relevant_directions_only is not set,
    241         // the way is tagged with a direction key
    242         // (even if the tag is negated as in oneway=false) or the way is selected
     242        /* show direction arrows, if draw.segment.relevant_directions_only is not set,
     243          the way is tagged with a direction key
     244           (even if the tag is negated as in oneway=false) or the way is selected */
    243245        boolean showDirection = w.selected || ((!useRealWidth) && (showDirectionArrow
    244246        && (!showRelevantDirectionsOnly || w.hasDirectionKeys)));
    245         // head only takes over control if the option is true,
    246         // the direction should be shown at all and not only because it's selected
     247        /* head only takes over control if the option is true,
     248           the direction should be shown at all and not only because it's selected */
    247249        boolean showOnlyHeadArrowOnly = showDirection && !w.selected && showHeadArrowOnly;
    248250        int width = defaultSegmentWidth;
    249         int realWidth = 0; //the real width of the element in meters
     251        int realWidth = 0; /* the real width of the element in meters */
    250252        int dashed = 0;
    251253        Color dashedColor = null;
     
    273275            color = selectedColor;
    274276
    275         // draw overlays under the way
     277        /* draw overlays under the way */
    276278        if(l != null && l.overlays != null)
    277279        {
     
    294296        }
    295297
    296         // draw the way
     298        /* draw the way */
    297299        lastN = null;
    298300        Iterator<Node> it = w.nodes.iterator();
     
    306308        }
    307309
    308         // draw overlays above the way
     310        /* draw overlays above the way */
    309311        if(l != null && l.overlays != null)
    310312        {
     
    392394                                if(c.selected) selected = true;
    393395                                --left;
    394                                 if(n == null) n = new ArrayList(w.nodes);
     396                                if(n == null) n = new ArrayList<Node>(w.nodes);
    395397                                n.remove((mode == 21 || mode == 22) ? nl : 0);
    396398                                if(mode == 21)
     
    466468        r.mappaintVisibleCode = 0;
    467469
    468         // TODO: is it possible to do this like the nodes/ways code?
    469         if(profilerOmitDraw)
    470             return;
     470        /* TODO: is it possible to do this like the nodes/ways code? */
     471        //if(profilerOmitDraw)
     472        //    return;
    471473
    472474        if(selectedCall)
     
    506508    }
    507509
    508     // this current experimental implementation will only work for standard restrictions:
    509     // from(Way) / via(Node) / to(Way)
     510    /* this current experimental implementation will only work for standard restrictions:
     511       from(Way) / via(Node) / to(Way) */
    510512    public void drawRestriction(Relation r) {
    511         if(restrictionDebug)
    512             System.out.println("Restriction: " + r.keys.get("name") + " restriction " + r.keys.get("restriction"));
     513        //if(restrictionDebug)
     514        //    System.out.println("Restriction: " + r.keys.get("name") + " restriction " + r.keys.get("restriction"));
    513515
    514516        r.clearErrors();
     
    518520        Node via = null;
    519521
    520         // find the "from", "via" and "to" elements
     522        /* find the "from", "via" and "to" elements */
    521523        for (RelationMember m : r.members)
    522524        {
    523             if(restrictionDebug)
    524                 System.out.println("member " + m.member + " selected " + r.selected);
     525            //if(restrictionDebug)
     526            //    System.out.println("member " + m.member + " selected " + r.selected);
    525527
    526528            if(m.member == null)
     
    538540                {
    539541                    Way w = (Way) m.member;
    540                     ElemStyle style = getPrimitiveStyle(w);
    541                     //if(r.selected) {
    542                     //    drawWay(w, null /*(LineElemStyle)style*/, selectedColor, true);
    543                     //    w.mappaintDrawnCode = paintid;
    544                     //}
    545542                    if(w.nodes.size() < 2)
    546543                    {
     
    594591        }
    595592
    596         // check if "from" way starts or ends at via
     593        /* check if "from" way starts or ends at via */
    597594        if(fromWay.nodes.get(0) != via && fromWay.nodes.get(fromWay.nodes.size()-1) != via) {
    598595            r.putError(tr("The \"from\" way doesn't start or end at a \"via\" node."), true);
    599596            return;
    600597        }
    601         // check if "to" way starts or ends at via
     598        /* check if "to" way starts or ends at via */
    602599        /*if(toWay.nodes.get(0) != via && toWay.nodes.get(toWay.nodes.size()-1) != via) {
    603600            r.putError(tr("to way doesn't start or end at a via node"), true);
    604             //return;
     601            return;
    605602        }*/
    606603
    607         // find the "direct" nodes before the via node
     604        /* find the "direct" nodes before the via node */
    608605        Node fromNode = null;
    609606        try
     
    620617        }
    621618
    622         // find the "direct" node after the via node
     619        /* find the "direct" node after the via node */
    623620        Node toNode = null;
    624621        try
    625622        {
    626623            if(toWay.nodes.get(0) == via) {
    627                 if(restrictionDebug)
    628                     System.out.println("To way heading away from via");
     624                //if(restrictionDebug)
     625                //    System.out.println("To way heading away from via");
    629626                toNode = toWay.nodes.get(1);
    630627            } else {
    631                 if(restrictionDebug)
    632                     System.out.println("To way heading towards via");
     628                //if(restrictionDebug)
     629                //    System.out.println("To way heading towards via");
    633630                toNode = toWay.nodes.get(toWay.nodes.size()-2);
    634631            }
     
    640637        Point pVia = nc.getPoint(via.eastNorth);
    641638
    642         if(restrictionDebug) {
    643             Point pTo = nc.getPoint(toNode.eastNorth);
    644 
    645             // debug output of interesting nodes
    646             System.out.println("From: " + fromNode);
    647             drawNode(fromNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    648             System.out.println("Via: " + via);
    649             drawNode(via, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    650             System.out.println("To: " + toNode);
    651             drawNode(toNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
    652             System.out.println("From X: " + pFrom.x + " Y " + pFrom.y);
    653             System.out.println("Via  X: " + pVia.x  + " Y " + pVia.y);
    654             System.out.println("To   X: " + pTo.x   + " Y " + pTo.y);
    655         }
    656 
    657         // starting from via, go back the "from" way a few pixels
    658         // (calculate the vector vx/vy with the specified length and the direction away from the "via" node along the first segment of the "from" way)
     639        //if(restrictionDebug) {
     640        //    Point pTo = nc.getPoint(toNode.eastNorth);
     641
     642        //    /* debug output of interesting nodes */
     643        //    System.out.println("From: " + fromNode);
     644        //    drawNode(fromNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
     645        //    System.out.println("Via: " + via);
     646        //    drawNode(via, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
     647        //    System.out.println("To: " + toNode);
     648        //    drawNode(toNode, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode);
     649        //    System.out.println("From X: " + pFrom.x + " Y " + pFrom.y);
     650        //    System.out.println("Via  X: " + pVia.x  + " Y " + pVia.y);
     651        //    System.out.println("To   X: " + pTo.x   + " Y " + pTo.y);
     652        //}
     653
     654        /* starting from via, go back the "from" way a few pixels
     655           (calculate the vector vx/vy with the specified length and the direction
     656           away from the "via" node along the first segment of the "from" way)
     657        */
    659658        double distanceFromVia=14;
    660659        double dx = (pFrom.x >= pVia.x) ? (pFrom.x - pVia.x) : (pVia.x - pFrom.x);
     
    675674        if(pFrom.y < pVia.y) vy = -vy;
    676675
    677         if(restrictionDebug)
    678             System.out.println("vx " + vx + " vy " + vy);
    679 
    680         // go a few pixels away from the way (in a right angle)
    681         // (calculate the vx2/vy2 vector with the specified length and the direction 90degrees away from the first segment of the "from" way)
     676        //if(restrictionDebug)
     677        //    System.out.println("vx " + vx + " vy " + vy);
     678
     679        /* go a few pixels away from the way (in a right angle)
     680           (calculate the vx2/vy2 vector with the specified length and the direction
     681           90degrees away from the first segment of the "from" way)
     682        */
    682683        double distanceFromWay=8;
    683684        double vx2 = 0;
     
    733734        }
    734735
    735         // rotate icon with direction last node in from to
    736         if(restrictionDebug)
    737             System.out.println("Deg1 " + fromAngleDeg + " Deg2 " + (fromAngleDeg + 180) + " Icon " + iconAngle);
     736        /* rotate icon with direction last node in from to */
     737        //if(restrictionDebug)
     738        //    System.out.println("Deg1 " + fromAngleDeg + " Deg2 " + (fromAngleDeg + 180) + " Icon " + iconAngle);
    738739        ImageIcon rotatedIcon = ImageProvider.createRotatedImage(null /*icon2*/, nodeStyle.icon, iconAngle);
    739740
    740         // scale down icon to 16*16 pixels
     741        /* scale down icon to 16*16 pixels */
    741742        ImageIcon smallIcon = new ImageIcon(rotatedIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
    742743        int w = smallIcon.getIconWidth(), h=smallIcon.getIconHeight();
     
    10411042        Polygon polygon = getPolygon(w);
    10421043
    1043         // set the opacity (alpha) level of the filled polygon
     1044        /* set the opacity (alpha) level of the filled polygon */
    10441045        g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
    10451046        g.fillPolygon(polygon);
     
    10481049    protected void drawAreaPolygon(Polygon polygon, Color color)
    10491050    {
    1050         // set the opacity (alpha) level of the filled polygon
     1051        /* set the opacity (alpha) level of the filled polygon */
    10511052        g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), fillAlpha));
    10521053        g.fillPolygon(polygon);
     
    10571058        if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    10581059
    1059         profilerVisibleNodes++;
     1060        //profilerVisibleNodes++;
    10601061
    10611062        int w = icon.getIconWidth(), h=icon.getIconHeight();
     
    10921093
    10931094    private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, int dashed, Color dashedColor) {
    1094         profilerSegments++;
     1095        //profilerSegments++;
    10951096        if (col != currentColor || width != currentWidth || dashed != currentDashed || dashedColor != currentDashedColor) {
    10961097            displaySegments(col, width, dashed, dashedColor);
     
    11021103            return;
    11031104        }
    1104         profilerVisibleSegments++;
     1105        //profilerVisibleSegments++;
    11051106        currentPath.moveTo(p1.x, p1.y);
    11061107        currentPath.lineTo(p2.x, p2.y);
     
    11661167                return;
    11671168
    1168             profilerVisibleNodes++;
     1169            //profilerVisibleNodes++;
    11691170
    11701171            g.setColor(color);
     
    11971198    }
    11981199
    1199     // Shows areas before non-areas
     1200    /* Shows areas before non-areas */
    12001201    public void visitAll(DataSet data, Boolean virtual) {
    12011202
    1202         boolean profiler = Main.pref.getBoolean("mappaint.profiler",false);
    1203         profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false);
     1203        //boolean profiler = Main.pref.getBoolean("mappaint.profiler",false);
     1204        //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false);
    12041205
    12051206        useStyleCache = Main.pref.getBoolean("mappaint.cache",true);
     
    12131214        dist = ll1.greatCircleDistance(ll2);
    12141215
    1215         long profilerStart = java.lang.System.currentTimeMillis();
    1216         long profilerLast = profilerStart;
    1217         int profilerN;
    1218         if(profiler)
    1219             System.out.println("Mappaint Profiler (" +
    1220                 (useStyleCache ? "cache=true, " : "cache=false, ") +
    1221                 "fillareas " + fillAreas + ", " +
    1222                 "fillalpha=" + fillAlpha + "%, " +
    1223                 "dist=" + (int)dist + "m)");
     1216        //long profilerStart = java.lang.System.currentTimeMillis();
     1217        //long profilerLast = profilerStart;
     1218        //int profilerN;
     1219        //if(profiler)
     1220        //    System.out.println("Mappaint Profiler (" +
     1221        //        (useStyleCache ? "cache=true, " : "cache=false, ") +
     1222        //        "fillareas " + fillAreas + ", " +
     1223        //        "fillalpha=" + fillAlpha + "%, " +
     1224        //        "dist=" + (int)dist + "m)");
    12241225
    12251226        getSettings(virtual);
    12261227        useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false);
    12271228        zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay",false);
    1228         circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter
     1229        circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; /* circumference of the earth in meter */
    12291230        styles = MapPaintStyles.getStyles().getStyleSet();
    12301231        drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon",true);
    12311232        drawRestriction = Main.pref.getBoolean("mappaint.restriction",true);
    1232         restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);
     1233        //restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);
    12331234        leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic",false);
    12341235        orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
     
    12431244        viewid = nc.getViewID();
    12441245
    1245         profilerVisibleNodes = 0;
    1246         profilerVisibleWays = 0;
    1247         profilerVisibleAreas = 0;
    1248         profilerSegments = 0;
    1249         profilerVisibleSegments = 0;
    1250 
    1251         if(profiler)
    1252         {
    1253             System.out.format("Prepare  : %5dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
    1254             profilerLast = java.lang.System.currentTimeMillis();
    1255         }
     1246        //profilerVisibleNodes = 0;
     1247        //profilerVisibleWays = 0;
     1248        //profilerVisibleAreas = 0;
     1249        //profilerSegments = 0;
     1250        //profilerVisibleSegments = 0;
     1251
     1252        //if(profiler)
     1253        //{
     1254        //    System.out.format("Prepare  : %5dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
     1255        //    profilerLast = java.lang.System.currentTimeMillis();
     1256        //}
    12561257
    12571258        if (fillAreas > dist && styles != null && styles.hasAreas()) {
     
    12591260
    12601261            /*** RELATIONS ***/
    1261             profilerN = 0;
     1262        //    profilerN = 0;
    12621263            for (final Relation osm : data.relations)
    12631264            {
     
    12651266                {
    12661267                    osm.visit(this);
    1267                     profilerN++;
    1268                 }
    1269             }
    1270 
    1271             if(profiler)
    1272             {
    1273                 System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    1274                 profilerLast = java.lang.System.currentTimeMillis();
    1275             }
     1268        //            profilerN++;
     1269                }
     1270            }
     1271
     1272        //    if(profiler)
     1273        //    {
     1274        //        System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     1275        //        profilerLast = java.lang.System.currentTimeMillis();
     1276        //    }
    12761277
    12771278            /*** AREAS ***/
    1278             profilerN = 0;
     1279        //    profilerN = 0;
    12791280            for (final Way osm : data.ways)
    12801281            {
     
    12851286                    {
    12861287                        osm.visit(this);
    1287                         profilerN++;
     1288        //                profilerN++;
    12881289                    } else
    1289                         noAreaWays.add((Way)osm);
    1290                 }
    1291             }
    1292 
    1293             if(profiler)
    1294             {
    1295                 System.out.format("Areas    : %5dms, calls=%7d, visible=%d\n",
    1296                     (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas);
    1297                 profilerLast = java.lang.System.currentTimeMillis();
    1298             }
     1290                        noAreaWays.add(osm);
     1291                }
     1292            }
     1293
     1294        //    if(profiler)
     1295        //    {
     1296        //        System.out.format("Areas    : %5dms, calls=%7d, visible=%d\n",
     1297        //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas);
     1298        //        profilerLast = java.lang.System.currentTimeMillis();
     1299        //    }
    12991300
    13001301            /*** WAYS ***/
    1301             profilerN = 0;
     1302        //    profilerN = 0;
    13021303            fillAreas = 0;
    13031304            for (final OsmPrimitive osm : noAreaWays)
    13041305            {
    13051306                osm.visit(this);
    1306                 profilerN++;
    1307             }
    1308 
    1309             if(profiler)
    1310             {
    1311                 System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n",
    1312                     (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);
    1313                 profilerLast = java.lang.System.currentTimeMillis();
    1314             }
     1307        //        profilerN++;
     1308            }
     1309
     1310        //    if(profiler)
     1311        //    {
     1312        //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n",
     1313        //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);
     1314        //        profilerLast = java.lang.System.currentTimeMillis();
     1315        //    }
    13151316        }
    13161317        else
    13171318        {
    13181319            /*** WAYS (filling disabled)  ***/
    1319             profilerN = 0;
     1320        //    profilerN = 0;
    13201321            for (final OsmPrimitive osm : data.ways)
    13211322                if (!osm.incomplete && !osm.deleted && !osm.selected
     
    13231324                {
    13241325                    osm.visit(this);
    1325                     profilerN++;
    1326                 }
    1327 
    1328             if(profiler)
    1329             {
    1330                 System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n",
    1331                     (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);
    1332                 profilerLast = java.lang.System.currentTimeMillis();
    1333             }
     1326        //            profilerN++;
     1327                }
     1328
     1329        //    if(profiler)
     1330        //    {
     1331        //        System.out.format("Ways     : %5dms, calls=%7d, visible=%d\n",
     1332        //            (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);
     1333        //        profilerLast = java.lang.System.currentTimeMillis();
     1334        //    }
    13341335        }
    13351336
    13361337        /*** SELECTED  ***/
    13371338        selectedCall = true;
    1338         profilerN = 0;
     1339        //profilerN = 0;
    13391340        for (final OsmPrimitive osm : data.getSelected()) {
    13401341            if (!osm.incomplete && !osm.deleted && !(osm instanceof Node)
     
    13421343            {
    13431344                osm.visit(this);
    1344                 profilerN++;
    1345             }
    1346         }
    1347 
    1348         if(profiler)
    1349         {
    1350             System.out.format("Selected : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    1351             profilerLast = java.lang.System.currentTimeMillis();
    1352         }
     1345        //        profilerN++;
     1346            }
     1347        }
     1348
     1349        //if(profiler)
     1350        //{
     1351        //    System.out.format("Selected : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     1352        //    profilerLast = java.lang.System.currentTimeMillis();
     1353        //}
    13531354
    13541355        /*** DISPLAY CACHED SEGMENTS (WAYS) NOW ***/
     
    13561357
    13571358        /*** NODES ***/
    1358         profilerN = 0;
     1359        //profilerN = 0;
    13591360        for (final OsmPrimitive osm : data.nodes)
    13601361            if (!osm.incomplete && !osm.deleted
     
    13621363            {
    13631364                osm.visit(this);
    1364                 profilerN++;
    1365             }
    1366 
    1367         if(profiler)
    1368         {
    1369             System.out.format("Nodes    : %5dms, calls=%7d, visible=%d\n",
    1370                 (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleNodes);
    1371             profilerLast = java.lang.System.currentTimeMillis();
    1372         }
     1365        //        profilerN++;
     1366            }
     1367
     1368        //if(profiler)
     1369        //{
     1370        //    System.out.format("Nodes    : %5dms, calls=%7d, visible=%d\n",
     1371        //        (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleNodes);
     1372        //    profilerLast = java.lang.System.currentTimeMillis();
     1373        //}
    13731374
    13741375        /*** VIRTUAL  ***/
    13751376        if (virtualNodeSize != 0)
    13761377        {
    1377             profilerN = 0;
     1378        //    profilerN = 0;
    13781379            currentColor = nodeColor;
    13791380            for (final OsmPrimitive osm : data.ways)
     
    13811382                && osm.mappaintVisibleCode != viewid )
    13821383                {
    1383                     // TODO: move this into the SimplePaint code?
    1384                     if(!profilerOmitDraw)
     1384                    /* TODO: move this into the SimplePaint code? */
     1385        //            if(!profilerOmitDraw)
    13851386                        visitVirtual((Way)osm);
    1386                     profilerN++;
    1387                 }
    1388 
    1389             if(profiler)
    1390             {
    1391                 System.out.format("Virtual  : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    1392                 profilerLast = java.lang.System.currentTimeMillis();
    1393             }
     1387        //            profilerN++;
     1388                }
     1389
     1390        //    if(profiler)
     1391        //    {
     1392        //        System.out.format("Virtual  : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     1393        //        profilerLast = java.lang.System.currentTimeMillis();
     1394        //    }
    13941395
    13951396            displaySegments(null);
    13961397        }
    13971398
    1398         if(profiler)
    1399         {
    1400             System.out.format("Segments :          calls=%7d, visible=%d\n", profilerSegments, profilerVisibleSegments);
    1401             System.out.format("All      : %5dms\n", (profilerLast-profilerStart));
    1402         }
     1399        //if(profiler)
     1400        //{
     1401        //    System.out.format("Segments :          calls=%7d, visible=%d\n", profilerSegments, profilerVisibleSegments);
     1402        //    System.out.format("All      : %5dms\n", (profilerLast-profilerStart));
     1403        //}
    14031404    }
    14041405
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r1409 r1415  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
     1/* License: GPL. Copyright 2007 by Immanuel Scholz and others */
    22package org.openstreetmap.josm.data.osm.visitor;
     3
     4/* To enable debugging or profiling remove the double / signs */
    35
    46import static org.openstreetmap.josm.tools.I18n.marktr;
     
    127129
    128130    public void visitAll(DataSet data, Boolean virtual) {
    129         boolean profiler = Main.pref.getBoolean("simplepaint.profiler",false);
    130         long profilerStart = java.lang.System.currentTimeMillis();
    131         long profilerLast = profilerStart;
    132         int profilerN = 0;
    133         if(profiler)
    134             System.out.println("Simplepaint Profiler");
     131        //boolean profiler = Main.pref.getBoolean("simplepaint.profiler",false);
     132        //long profilerStart = java.lang.System.currentTimeMillis();
     133        //long profilerLast = profilerStart;
     134        //int profilerN = 0;
     135        //if(profiler)
     136        //    System.out.println("Simplepaint Profiler");
    135137
    136138        getSettings(virtual);
    137139
    138         if(profiler)
    139         {
    140             System.out.format("Prepare  : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
    141             profilerLast = java.lang.System.currentTimeMillis();
    142         }
    143 
    144         // draw tagged ways first, then untagged ways. takes
    145         // time to iterate through list twice, OTOH does not
    146         // require changing the colour while painting...
    147         profilerN = 0;
     140        //if(profiler)
     141        //{
     142        //    System.out.format("Prepare  : %4dms\n", (java.lang.System.currentTimeMillis()-profilerLast));
     143        //    profilerLast = java.lang.System.currentTimeMillis();
     144        //}
     145
     146        /* draw tagged ways first, then untagged ways. takes
     147          time to iterate through list twice, OTOH does not
     148           require changing the colour while painting... */
     149        //profilerN = 0;
    148150        for (final OsmPrimitive osm : data.relations)
    149151            if (!osm.deleted && !osm.selected)
    150152            {
    151153                osm.visit(this);
    152                 profilerN++;
    153             }
    154 
    155         if(profiler)
    156         {
    157             System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    158             profilerLast = java.lang.System.currentTimeMillis();
    159         }
    160 
    161         profilerN = 0;
     154        //        profilerN++;
     155            }
     156
     157        //if(profiler)
     158        //{
     159        //    System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     160        //    profilerLast = java.lang.System.currentTimeMillis();
     161        //}
     162
     163        //profilerN = 0;
    162164        for (final OsmPrimitive osm : data.ways)
    163165            if (!osm.deleted && !osm.selected && osm.tagged)
    164166            {
    165167                osm.visit(this);
    166                 profilerN++;
     168        //        profilerN++;
    167169            }
    168170        displaySegments();
     
    172174            {
    173175                osm.visit(this);
    174                 profilerN++;
     176        //        profilerN++;
    175177            }
    176178        displaySegments();
    177179
    178         if(profiler)
    179         {
    180             System.out.format("Ways     : %4dms, n=%5d\n",
    181                 (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    182             profilerLast = java.lang.System.currentTimeMillis();
    183         }
    184 
    185         profilerN = 0;
     180        //if(profiler)
     181        //{
     182        //    System.out.format("Ways     : %4dms, n=%5d\n",
     183        //        (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     184        //    profilerLast = java.lang.System.currentTimeMillis();
     185        //}
     186
     187        //profilerN = 0;
    186188        for (final OsmPrimitive osm : data.getSelected())
    187189            if (!osm.deleted)
    188190            {
    189191                osm.visit(this);
    190                 profilerN++;
     192        //        profilerN++;
    191193            }
    192194        displaySegments();
    193195
    194         if(profiler)
    195         {
    196             System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    197             profilerLast = java.lang.System.currentTimeMillis();
    198         }
    199 
    200         profilerN = 0;
     196        //if(profiler)
     197        //{
     198        //    System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     199        //    profilerLast = java.lang.System.currentTimeMillis();
     200        //}
     201
     202        //profilerN = 0;
    201203        for (final OsmPrimitive osm : data.nodes)
    202204            if (!osm.deleted && !osm.selected)
    203205            {
    204206                osm.visit(this);
    205                 profilerN++;
    206             }
    207         if(profiler)
    208         {
    209             System.out.format("Nodes    : %4dms, n=%5d\n",
    210                 (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    211             profilerLast = java.lang.System.currentTimeMillis();
    212         }
     207        //        profilerN++;
     208            }
     209
     210        //if(profiler)
     211        //{
     212        //    System.out.format("Nodes    : %4dms, n=%5d\n",
     213        //        (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     214        //    profilerLast = java.lang.System.currentTimeMillis();
     215        //}
    213216
    214217        if(virtualNodeSize != 0)
    215218        {
    216             profilerN = 0;
     219        //    profilerN = 0;
    217220            currentColor = nodeColor;
    218221            for (final OsmPrimitive osm : data.ways)
     
    220223                    {
    221224                        visitVirtual((Way)osm);
    222                         profilerN++;
     225        //                profilerN++;
    223226                    }
    224227            displaySegments();
    225228
    226             if(profiler)
    227             {
    228                 System.out.format("Virtual  : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    229                 profilerLast = java.lang.System.currentTimeMillis();
    230             }
    231         }
    232 
    233         if(profiler)
    234         {
    235             System.out.format("All      : %4dms\n", (profilerLast-profilerStart));
    236         }
     229        //    if(profiler)
     230        //    {
     231        //        System.out.format("Virtual  : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     232        //        profilerLast = java.lang.System.currentTimeMillis();
     233        //    }
     234        }
     235
     236        //if(profiler)
     237        //{
     238        //    System.out.format("All      : %4dms\n", (profilerLast-profilerStart));
     239        //}
    237240    }
    238241
     
    294297            return;
    295298
    296         // show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key
    297         // (even if the tag is negated as in oneway=false) or the way is selected
     299        /* show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key
     300           (even if the tag is negated as in oneway=false) or the way is selected */
    298301
    299302        boolean showThisDirectionArrow = w.selected
    300303        || (showDirectionArrow && (!showRelevantDirectionsOnly || w.hasDirectionKeys));
    301         // head only takes over control if the option is true,
    302         // the direction should be shown at all and not only because it's selected
     304        /* head only takes over control if the option is true,
     305           the direction should be shown at all and not only because it's selected */
    303306        boolean showOnlyHeadArrowOnly = showThisDirectionArrow && !w.selected && showHeadArrowOnly;
    304307        Color wayColor;
     
    390393            }
    391394
    392             displaySegments(); // draw nodes on top!
     395            displaySegments(); /* draw nodes on top! */
    393396            Color c = g.getColor();
    394397            g.setColor(backgroundColor);
  • trunk/src/org/openstreetmap/josm/data/projection/Lambert.java

    r1309 r1415  
    206206     * reference ellipsoid used by Lambert is Clark
    207207     *
    208      * @param coord projected coordinates pair in meters
    209      * @param Xs    false east (coordinate system origin) in meters
    210      * @param Ys    false north (coordinate system origin) in meters
    211      * @param c     projection constant
    212      * @param n     projection exponent
     208     * @param eastNorth projected coordinates pair in meters
     209     * @param Xs        false east (coordinate system origin) in meters
     210     * @param Ys        false north (coordinate system origin) in meters
     211     * @param c         projection constant
     212     * @param n         projection exponent
    213213     * @return LatLon in radian
    214214     */
     
    236236     * Translate latitude/longitude in WGS84, (ellipsoid GRS80) to Lambert
    237237     * geographic, (ellipsoid Clark)
    238      *
    239      * @param wgs
    240      * @return
    241238     */
    242239    private LatLon GRS802Clark(LatLon wgs) {
     
    256253    }
    257254
    258     /**
    259      * @param lambert
    260      * @return
    261      */
    262255    private LatLon Clark2GRS80(LatLon lambert) {
    263256        double lat = lambert.lat(); // in radian
Note: See TracChangeset for help on using the changeset viewer.