Ignore:
Timestamp:
2022-06-15T20:10:48+02:00 (3 years ago)
Author:
taylor.smock
Message:

See #22115: Extract methods from LatLon into ILatLon where they are generally applicable

This uses the extracted methods where possible, and removes unnecessary
Node#getCoor calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/simplifyarea/src/org/openstreetmap/josm/plugins/simplifyarea/SimplifyAreaAction.java

    r35976 r35978  
    2929import org.openstreetmap.josm.data.Bounds;
    3030import org.openstreetmap.josm.data.UndoRedoHandler;
     31import org.openstreetmap.josm.data.coor.ILatLon;
    3132import org.openstreetmap.josm.data.coor.LatLon;
    3233import org.openstreetmap.josm.data.osm.Node;
     
    257258                    }
    258259
    259                     final LatLon a = coordMap.get(n1);
    260                     final LatLon b = coordMap.get(n2);
     260                    final ILatLon a = coordMap.get(n1);
     261                    final ILatLon b = coordMap.get(n2);
    261262                   
    262263                    if (a != null && b != null) {
     
    419420    }
    420421
    421     public static double computeConvectAngle(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
     422    public static double computeConvectAngle(final ILatLon coord1, final ILatLon coord2, final ILatLon coord3) {
    422423        final double angle =  Math.abs(heading(coord2, coord3) - heading(coord1, coord2));
    423424        return Math.toDegrees(angle < Math.PI ? angle : 2 * Math.PI - angle);
    424425    }
    425426
    426     public static double computeArea(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
     427    public static double computeArea(final ILatLon coord1, final ILatLon coord2, final ILatLon coord3) {
    427428        final double a = coord1.greatCircleDistance(coord2);
    428429        final double b = coord2.greatCircleDistance(coord3);
     
    437438    public static double R = 6378135;
    438439
    439     public static double crossTrackError(final LatLon l1, final LatLon l2, final LatLon l3) {
     440    public static double crossTrackError(final ILatLon l1, final ILatLon l2, final ILatLon l3) {
    440441        return R * Math.asin(sin(l1.greatCircleDistance(l2) / R) * sin(heading(l1, l2) - heading(l1, l3)));
    441442    }
    442443
    443     public static double heading(final LatLon a, final LatLon b) {
     444    public static double heading(final ILatLon a, final ILatLon b) {
    444445        double hd = Math.atan2(sin(toRadians(a.lon() - b.lon())) * cos(toRadians(b.lat())),
    445446                cos(toRadians(a.lat())) * sin(toRadians(b.lat())) -
Note: See TracChangeset for help on using the changeset viewer.