Changeset 1296 in josm


Ignore:
Timestamp:
2009-01-18T18:42:14+01:00 (16 years ago)
Author:
ulfl
Message:

add mappaint.lefthandtraffic option to distinguish if the turn restriction signs must be placed to the right (default) or to the left of the street (setting might be useful elsewhere ...)

fix a bug when the heading of the "from" way was exactly 0/180 degrees

File:
1 edited

Legend:

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

    r1295 r1296  
    4646    protected boolean drawMultipolygon;
    4747    protected boolean drawRestriction;
     48    protected boolean leftHandTraffic;
    4849    protected boolean restrictionDebug;
    4950    protected int showNames;
     
    660661        double dy = (pFrom.y >= pVia.y) ? (pFrom.y - pVia.y) : (pVia.y - pFrom.y);
    661662       
     663        double fromAngle;
    662664        if(dx == 0.0) {
    663             System.out.println("dx " + dx);
    664             return;
    665         }
    666         double fromAngle = Math.atan(dy / dx);
     665            fromAngle = Math.PI/2;
     666        } else {
     667            fromAngle = Math.atan(dy / dx);
     668        }
    667669        double fromAngleDeg = Math.toDegrees(fromAngle);
    668670
     
    684686
    685687        if(pFrom.x >= pVia.x && pFrom.y >= pVia.y) {
    686             vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90));
    687             vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90));
     688            if(leftHandTraffic) {
     689                vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90));
     690                vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90));
     691            } else {
     692                vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90));
     693                vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90));
     694            }
    688695            iconAngle = 270+fromAngleDeg;
    689696        }
    690697        if(pFrom.x < pVia.x && pFrom.y >= pVia.y) {
    691             vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg));
    692             vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg));
     698            if(leftHandTraffic) {
     699                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg));
     700                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg));
     701            } else {
     702                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180));
     703                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180));
     704            }
    693705            iconAngle = 90-fromAngleDeg;
    694706        }
    695707        if(pFrom.x < pVia.x && pFrom.y < pVia.y) {
    696             vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90));
    697             vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90));
     708            if(leftHandTraffic) {
     709                vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90));
     710                vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90));
     711            } else {
     712                vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90));
     713                vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90));
     714            }
    698715            iconAngle = 90+fromAngleDeg;
    699716        }
    700717        if(pFrom.x >= pVia.x && pFrom.y < pVia.y) {
    701             vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg+180));
    702             vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg+180));
     718            if(leftHandTraffic) {
     719                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180));
     720                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180));
     721             } else {
     722                vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg));
     723                vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg));
     724            }
    703725            iconAngle = 270-fromAngleDeg;
    704726        }
     
    11931215        drawRestriction = Main.pref.getBoolean("mappaint.restriction",false);
    11941216        restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);
     1217        leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic",false);
    11951218        orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
    11961219        String currentLocale = Locale.getDefault().getLanguage();
Note: See TracChangeset for help on using the changeset viewer.