Ignore:
Timestamp:
2017-11-25T23:49:23+01:00 (2 years ago)
Author:
Don-vip
Message:

fix #13694 - Display UTM zone in node info panel (no i18n impact)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

    r12013 r13167  
    55
    66import org.openstreetmap.josm.data.Bounds;
     7import org.openstreetmap.josm.data.coor.LatLon;
    78import org.openstreetmap.josm.data.projection.ProjectionConfigurationException;
    89import org.openstreetmap.josm.tools.CheckParameterUtil;
     10import org.openstreetmap.josm.tools.Pair;
    911import org.openstreetmap.josm.tools.Utils;
    1012
     
    7072 */
    7173public class TransverseMercator extends AbstractProj {
     74
     75    /** Earth emispheres **/
     76    public enum Hemisphere {
     77        /** North emisphere */
     78        North,
     79        /** South emisphere */
     80        South
     81    }
    7282
    7383    /**
     
    223233        return new Bounds(-89, -7, 89, 7, false);
    224234    }
     235
     236    /**
     237     * Determines the UTM zone of a given lat/lon.
     238     * @param ll lat/lon to locate in the UTM grid.
     239     * @return the UTM zone of {@code ll}
     240     * @since 13167
     241     */
     242    public static Pair<Integer, Hemisphere> locateUtmZone(LatLon ll) {
     243        return new Pair<>((int) Math.floor((ll.lon() + 180d) / 6d) + 1,
     244                ll.lat() > 0 ? Hemisphere.North : Hemisphere.South);
     245    }
    225246}
Note: See TracChangeset for help on using the changeset viewer.