Changeset 12778 in josm for trunk


Ignore:
Timestamp:
2017-09-08T01:04:05+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - deprecate Projections#project and Projections#inverseProject

replacement is a bit more verbose, but the fact that Main.proj is
involved need not be hidden

Location:
trunk/src/org/openstreetmap/josm
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java

    r12726 r12778  
    1919import java.util.TreeSet;
    2020
     21import org.openstreetmap.josm.Main;
    2122import org.openstreetmap.josm.command.ChangeCommand;
    2223import org.openstreetmap.josm.command.Command;
     
    2930import org.openstreetmap.josm.data.osm.Way;
    3031import org.openstreetmap.josm.data.osm.WaySegment;
    31 import org.openstreetmap.josm.data.projection.Projections;
    3232import org.openstreetmap.josm.gui.MainApplication;
    3333import org.openstreetmap.josm.gui.MapView;
     
    138138                if (joinWayToNode) {
    139139                    for (Node node : nodesInSegment) {
    140                         EastNorth newPosition = Geometry.closestPointToSegment(w.getNode(segmentIndex).getEastNorth(),
    141                                                                             w.getNode(segmentIndex+1).getEastNorth(),
    142                                                                             node.getEastNorth());
    143                         MoveCommand c = new MoveCommand(node, Projections.inverseProject(newPosition));
     140                        EastNorth newPosition = Geometry.closestPointToSegment(
     141                                w.getNode(segmentIndex).getEastNorth(),
     142                                w.getNode(segmentIndex+1).getEastNorth(),
     143                                node.getEastNorth());
     144                        MoveCommand c = new MoveCommand(
     145                                node, Main.getProjection().eastNorth2latlon(newPosition));
    144146                        // Avoid moving a given node several times at the same position in case of overlapping ways
    145147                        if (!cmds.contains(c)) {
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r12759 r12778  
    1414import javax.swing.Icon;
    1515
     16import org.openstreetmap.josm.Main;
    1617import org.openstreetmap.josm.data.coor.EastNorth;
    1718import org.openstreetmap.josm.data.coor.LatLon;
     
    2021import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2122import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
    22 import org.openstreetmap.josm.data.projection.Projections;
    2323import org.openstreetmap.josm.tools.ImageProvider;
    2424
     
    7272     */
    7373    public MoveCommand(Node node, LatLon position) {
    74         this(Collections.singleton((OsmPrimitive) node), Projections.project(position).subtract(node.getEastNorth()));
     74        this(Collections.singleton((OsmPrimitive) node),
     75                Main.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth()));
    7576    }
    7677
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r12753 r12778  
    1616import org.openstreetmap.josm.data.osm.visitor.Visitor;
    1717import org.openstreetmap.josm.data.projection.Projecting;
    18 import org.openstreetmap.josm.data.projection.Projections;
    1918import org.openstreetmap.josm.tools.CheckParameterUtil;
    2019import org.openstreetmap.josm.tools.Utils;
     
    142141            invalidateEastNorthCache();
    143142        } else if (eastNorth != null) {
    144             LatLon ll = Projections.inverseProject(eastNorth);
     143            LatLon ll = Main.getProjection().eastNorth2latlon(eastNorth);
    145144            this.lat = ll.lat();
    146145            this.lon = ll.lon();
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r12738 r12778  
    22package org.openstreetmap.josm.data.osm;
    33
     4import org.openstreetmap.josm.Main;
    45import org.openstreetmap.josm.data.coor.EastNorth;
    56import org.openstreetmap.josm.data.coor.LatLon;
    67import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    7 import org.openstreetmap.josm.data.projection.Projections;
    88
    99/**
     
    8383        // No internal caching of projected coordinates needed. In contrast to getEastNorth()
    8484        // on Node, this method is rarely used. Caching would be overkill.
    85         return Projections.project(getCoor());
     85        return Main.getProjection().latlon2eastNorth(getCoor());
    8686    }
    8787
    8888    @Override
    8989    public void setEastNorth(EastNorth eastNorth) {
    90         setCoor(Projections.inverseProject(eastNorth));
     90        setCoor(Main.getProjection().eastNorth2latlon(eastNorth));
    9191    }
    9292
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r12725 r12778  
    194194     * @return the corresponding east/north coordinates
    195195     * @since 12725
    196      */
     196     * @deprecated use <code>Main.getProjection().latlon2eastNorth(ll)</code>
     197     */
     198    @Deprecated
    197199    public static EastNorth project(ILatLon ll) {
    198200        if (ll == null) return null;
     
    205207     * @param ll the geographical point to convert (in WGS84 lat/lon)
    206208     * @return the corresponding east/north coordinates
    207      */
     209     * @deprecated use <code>Main.getProjection().latlon2eastNorth(ll)</code>
     210     */
     211    @Deprecated
    208212    public static EastNorth project(LatLon ll) {
    209213        return project((ILatLon) ll);
     
    215219     * @param en the geographical point to convert (in projected coordinates)
    216220     * @return the corresponding lat/lon (WGS84)
    217      */
     221     * @deprecated use <code>Main.getProjection().eastNorth2latlon(en)</code>
     222     */
     223    @Deprecated
    218224    public static LatLon inverseProject(EastNorth en) {
    219225        if (en == null) return null;
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r12725 r12778  
    5353import org.openstreetmap.josm.data.projection.Projection;
    5454import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
    55 import org.openstreetmap.josm.data.projection.Projections;
    5655import org.openstreetmap.josm.gui.help.Helpful;
    5756import org.openstreetmap.josm.gui.layer.NativeScaleLayer;
     
    715714     */
    716715    public void zoomTo(ILatLon newCenter) {
    717         zoomTo(Projections.project(newCenter));
     716        zoomTo(getProjection().latlon2eastNorth(newCenter));
    718717    }
    719718
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r12630 r12778  
    3131import org.openstreetmap.josm.data.coor.EastNorth;
    3232import org.openstreetmap.josm.data.coor.LatLon;
    33 import org.openstreetmap.josm.data.projection.Projections;
    3433import org.openstreetmap.josm.gui.MainApplication;
    3534import org.openstreetmap.josm.gui.MapView;
     
    266265        MapView mapView = MainApplication.getMap().mapView;
    267266        EastNorth center = mapView.getCenter();
    268         LatLon centerLL = Projections.inverseProject(center);
     267        LatLon centerLL = Main.getProjection().eastNorth2latlon(center);
    269268        centerEl.setAttribute("lat", Double.toString(centerLL.lat()));
    270269        centerEl.setAttribute("lon", Double.toString(centerLL.lon()));
Note: See TracChangeset for help on using the changeset viewer.