Changeset 13167 in josm


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

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

Location:
trunk/src/org/openstreetmap/josm
Files:
3 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}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r12745 r13167  
    2020import org.openstreetmap.josm.data.osm.RelationMember;
    2121import org.openstreetmap.josm.data.osm.Way;
     22import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
     23import org.openstreetmap.josm.data.projection.proj.TransverseMercator.Hemisphere;
    2224import org.openstreetmap.josm.tools.Geometry;
     25import org.openstreetmap.josm.tools.Pair;
    2326import org.openstreetmap.josm.tools.Utils;
    2427import org.openstreetmap.josm.tools.date.DateUtils;
     
    212215                    Double.toString(n.lat()), ", ",
    213216                    Double.toString(n.lon()));
     217            EastNorth en = n.getEastNorth();
    214218            add(tr("Coordinates (projected): "),
    215                     Double.toString(n.getEastNorth().east()), ", ",
    216                     Double.toString(n.getEastNorth().north()));
     219                    Double.toString(en.east()), ", ",
     220                    Double.toString(en.north()));
     221            Pair<Integer, Hemisphere> utmZone = TransverseMercator.locateUtmZone(n.getCoor());
     222            String utmLabel = tr("UTM Zone");
     223            add(utmLabel, utmLabel.endsWith(":") ? " " : ": ", Integer.toString(utmZone.a), utmZone.b.toString().substring(0, 1));
    217224        }
    218225    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTMProjectionChoice.java

    r12620 r13167  
    1616import javax.swing.JRadioButton;
    1717
     18import org.openstreetmap.josm.data.projection.proj.TransverseMercator.Hemisphere;
    1819import org.openstreetmap.josm.tools.GBC;
    1920import org.openstreetmap.josm.tools.Logging;
     
    2526 */
    2627public class UTMProjectionChoice extends ListProjectionChoice {
    27 
    28     /** Earth emispheres **/
    29     public enum Hemisphere {
    30         /** North emisphere */
    31         North,
    32         /** South emisphere */
    33         South
    34     }
    3528
    3629    private static final Hemisphere DEFAULT_HEMISPHERE = Hemisphere.North;
Note: See TracChangeset for help on using the changeset viewer.