Ticket #2317: wrong_angle.patch

File wrong_angle.patch, 1.3 KB (added by xeen, 3 years ago)

I have no idea why this works. Either the latlon.heading code is wrong (which I doubt) or the problem arose from converting the mouse position using projection.eastNorth2LatLon. Tested for Mercator, SwissGrid and UTM 33. Plus, now I know where all these tilted "rectangular" buildings came from :)

  • src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

     
    733733        // find out the distance, in metres, between the base point and the mouse cursor 
    734734        LatLon mouseLatLon = mv.getProjection().eastNorth2latlon(currentMouseEastNorth); 
    735735        distance = currentBaseNode.getCoor().greatCircleDistance(mouseLatLon); 
    736         double hdg = Math.toDegrees(currentBaseNode.getCoor().heading(mouseLatLon)); 
     736 
     737        double hdg = Math.toDegrees(currentBaseNode.getEastNorth() 
     738                .heading(currentMouseEastNorth)); 
    737739        if (previousNode != null) { 
    738             angle = hdg - Math.toDegrees(previousNode.getCoor().heading(currentBaseNode.getCoor())); 
    739             if (angle < 0) { 
    740                 angle += 360; 
    741             } 
     740            angle = hdg - Math.toDegrees(previousNode.getEastNorth() 
     741                    .heading(currentBaseNode.getEastNorth())); 
     742            angle += angle < 0 ? 360 : 0; 
    742743        } 
     744 
    743745        Main.map.statusLine.setAngle(angle); 
    744746        Main.map.statusLine.setHeading(hdg); 
    745747        Main.map.statusLine.setDist(distance);