Changeset 12725 in josm for trunk/src/org


Ignore:
Timestamp:
2017-09-04T20:19:23+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - deprecate ILatLon#getEastNorth() so ILatLon has no dependency on Main.proj

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/ILatLon.java

    r12171 r12725  
    4444     *
    4545     * @return the east north coordinates or {@code null} if #is
     46     * @deprecated use {@link #getEastNorth(org.openstreetmap.josm.data.projection.Projecting)}
    4647     */
     48    @Deprecated
    4749    default EastNorth getEastNorth() {
    4850        return getEastNorth(Main.getProjection());
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r12669 r12725  
    308308        case DEGREES_MINUTES_SECONDS: return degreesMinutesSeconds(y) + ((y < 0) ? SOUTH : NORTH);
    309309        case NAUTICAL: return degreesMinutes(y) + ((y < 0) ? SOUTH : NORTH);
    310         case EAST_NORTH: return cDdFormatter.format(this.getEastNorth().north());
     310        case EAST_NORTH: return cDdFormatter.format(this.getEastNorth(Main.getProjection()).north());
    311311        default: return "ERR";
    312312        }
     
    328328        case DEGREES_MINUTES_SECONDS: return degreesMinutesSeconds(x) + ((x < 0) ? WEST : EAST);
    329329        case NAUTICAL: return degreesMinutes(x) + ((x < 0) ? WEST : EAST);
    330         case EAST_NORTH: return cDdFormatter.format(this.getEastNorth().east());
     330        case EAST_NORTH: return cDdFormatter.format(this.getEastNorth(Main.getProjection()).east());
    331331        default: return "ERR";
    332332        }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r12275 r12725  
    417417            for (GpxTrackSegment seg : track.getSegments()) {
    418418                WayPoint r = null;
    419                 for (WayPoint S : seg.getWayPoints()) {
    420                     EastNorth en = S.getEastNorth();
     419                for (WayPoint wpSeg : seg.getWayPoints()) {
     420                    EastNorth en = wpSeg.getEastNorth(Main.getProjection());
    421421                    if (r == null) {
    422                         r = S;
     422                        r = wpSeg;
    423423                        rx = en.east();
    424424                        ry = en.north();
     
    455455                                double ny = ry + rnoverRS * a;
    456456                                bestEN = new EastNorth(nx, ny);
    457                                 bestTime = r.time + rnoverRS * (S.time - r.time);
     457                                bestTime = r.time + rnoverRS * (wpSeg.time - r.time);
    458458                                pnminsq = pnsq;
    459459                            }
    460460                        }
    461                         r = S;
     461                        r = wpSeg;
    462462                        rx = sx;
    463463                        ry = sy;
     
    465465                }
    466466                if (r != null) {
    467                     EastNorth c = r.getEastNorth();
     467                    EastNorth c = r.getEastNorth(Main.getProjection());
    468468                    /* if there is only one point in the seg, it will do this twice, but no matter */
    469469                    rx = c.east();
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r12167 r12725  
    9898    public double lon() {
    9999        return lon;
     100    }
     101
     102    /**
     103     * Replies the projected east/north coordinates.
     104     * <p>
     105     * Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.
     106     * @return the east north coordinates or {@code null} if #is
     107     */
     108    public EastNorth getEastNorth() {
     109        return getEastNorth(Main.getProjection());
    100110    }
    101111
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r12190 r12725  
    7676
    7777    @Override
     78    @Deprecated
    7879    public EastNorth getEastNorth() {
    7980        // No internal caching of projected coordinates needed. In contrast to getEastNorth()
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r12630 r12725  
    7474     * Visiting call for lat/lon.
    7575     * @param latlon lat/lon
     76     * @since 12725 (public for ILatLon parameter)
     77     */
     78    public void visit(ILatLon latlon) {
     79        if (latlon != null) {
     80            visit(latlon.getEastNorth(Main.getProjection()));
     81        }
     82    }
     83
     84    /**
     85     * Visiting call for lat/lon.
     86     * @param latlon lat/lon
    7687     */
    7788    public void visit(LatLon latlon) {
    78         if (latlon != null) {
    79             visit((ILatLon) latlon);
    80         }
    81     }
    82 
    83     private void visit(ILatLon latlon) {
    84         visit(latlon.getEastNorth());
     89        visit((ILatLon) latlon);
    8590    }
    8691
     
    138143        bounds = new ProjectionBounds(new LatLon(
    139144                        Math.max(-90, minLatlon.lat() - enlargeDegree),
    140                         Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(),
     145                        Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(Main.getProjection()),
    141146                new LatLon(
    142147                        Math.min(90, maxLatlon.lat() + enlargeDegree),
    143                         Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth());
     148                        Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(Main.getProjection()));
    144149    }
    145150
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r12620 r12725  
    1919import org.openstreetmap.josm.Main;
    2020import org.openstreetmap.josm.data.coor.EastNorth;
     21import org.openstreetmap.josm.data.coor.ILatLon;
    2122import org.openstreetmap.josm.data.coor.LatLon;
    2223import org.openstreetmap.josm.data.projection.datum.Datum;
     
    192193     * @param ll the geographical point to convert (in WGS84 lat/lon)
    193194     * @return the corresponding east/north coordinates
    194      */
    195     public static EastNorth project(LatLon ll) {
     195     * @since 12725
     196     */
     197    public static EastNorth project(ILatLon ll) {
    196198        if (ll == null) return null;
    197199        return Main.getProjection().latlon2eastNorth(ll);
     200    }
     201
     202    /**
     203     * Convert from lat/lon to easting/northing using the current projection.
     204     *
     205     * @param ll the geographical point to convert (in WGS84 lat/lon)
     206     * @return the corresponding east/north coordinates
     207     */
     208    public static EastNorth project(LatLon ll) {
     209        return project((ILatLon) ll);
    198210    }
    199211
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r12505 r12725  
    395395        Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet(
    396396                () -> Main.getProjection().getWorldBoundsLatLon());
    397         return b.getCenter().getEastNorth();
     397        return b.getCenter().getEastNorth(Main.getProjection());
    398398    }
    399399
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r12636 r12725  
    516516     * @return The point on screen where "point" would be drawn, relative to the own top/left.
    517517     */
    518     public Point2D getPoint2D(LatLon latlon) {
     518    public Point2D getPoint2D(ILatLon latlon) {
    519519        if (latlon == null) {
    520520            return new Point();
    521521        } else {
    522             return getPoint2D(latlon.getEastNorth());
    523         }
     522            return getPoint2D(latlon.getEastNorth(Main.getProjection()));
     523        }
     524    }
     525
     526    /**
     527     * Return the point on the screen where this Coordinate would be.
     528     *
     529     * Alternative: {@link #getState()}, then {@link MapViewState#getPointFor(ILatLon)}
     530     * @param latlon The point, where this geopoint would be drawn.
     531     * @return The point on screen where "point" would be drawn, relative to the own top/left.
     532     */
     533    public Point2D getPoint2D(LatLon latlon) {
     534        return getPoint2D((ILatLon) latlon);
    524535    }
    525536
     
    551562     * @return point
    552563     * @see #getPoint2D(LatLon)
    553      */
    554     public Point getPoint(LatLon latlon) {
     564     * @since 12725
     565     */
     566    public Point getPoint(ILatLon latlon) {
    555567        Point2D d = getPoint2D(latlon);
    556568        return new Point((int) d.getX(), (int) d.getY());
     569    }
     570
     571    /**
     572     * looses precision, may overflow (depends on p and current scale)
     573     * @param latlon lat/lon
     574     * @return point
     575     * @see #getPoint2D(LatLon)
     576     */
     577    public Point getPoint(LatLon latlon) {
     578        return getPoint((ILatLon) latlon);
    557579    }
    558580
     
    690712     * Zoom to given lat/lon.
    691713     * @param newCenter new center coordinates
     714     * @since 12725
     715     */
     716    public void zoomTo(ILatLon newCenter) {
     717        zoomTo(Projections.project(newCenter));
     718    }
     719
     720    /**
     721     * Zoom to given lat/lon.
     722     * @param newCenter new center coordinates
    692723     */
    693724    public void zoomTo(LatLon newCenter) {
    694         zoomTo(Projections.project(newCenter));
     725        zoomTo((ILatLon) newCenter);
    695726    }
    696727
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTransferData.java

    r11038 r12725  
    132132        for (PrimitiveData pd : getAll()) {
    133133            if (pd instanceof NodeData && !pd.isIncomplete()) {
    134                 visitor.visit(((NodeData) pd).getEastNorth());
     134                visitor.visit(((NodeData) pd));
    135135            }
    136136        }
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java

    r12718 r12725  
    7373                if (data instanceof NodeData) {
    7474                    NodeData nodeData = (NodeData) data;
    75                     nodeData.setEastNorth(nodeData.getEastNorth().add(offset));
     75                    nodeData.setEastNorth(nodeData.getEastNorth(Main.getProjection()).add(offset));
    7676                } else if (data instanceof WayData) {
    7777                    updateNodes(newIds.get(OsmPrimitiveType.NODE), data);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r12672 r12725  
    191191        if (bbox != null) {
    192192            add(tr("Bounding box: "), bbox.toStringCSV(", "));
    193             EastNorth bottomRigth = bbox.getBottomRight().getEastNorth();
    194             EastNorth topLeft = bbox.getTopLeft().getEastNorth();
     193            EastNorth bottomRigth = bbox.getBottomRight().getEastNorth(Main.getProjection());
     194            EastNorth topLeft = bbox.getTopLeft().getEastNorth(Main.getProjection());
    195195            add(tr("Bounding box (projected): "),
    196196                    Double.toString(topLeft.east()), ", ",
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r12620 r12725  
    651651                    continue;
    652652                }
    653                 Point screen = mv.getPoint(trkPnt.getEastNorth());
     653                Point screen = mv.getPoint(trkPnt);
    654654                // skip points that are on the same screenposition
    655655                if (trkPnt.drawLine && old != null && ((old.x != screen.x) || (old.y != screen.y))) {
     
    681681                }
    682682                if (trkPnt.drawLine) {
    683                     Point screen = mv.getPoint(trkPnt.getEastNorth());
     683                    Point screen = mv.getPoint(trkPnt);
    684684                    // skip points that are on the same screenposition
    685685                    if (old != null
     
    711711                }
    712712                if (trkPnt.drawLine) {
    713                     Point screen = mv.getPoint(trkPnt.getEastNorth());
     713                    Point screen = mv.getPoint(trkPnt);
    714714                    // skip points that are on the same screenposition
    715715                    if (old != null
     
    746746                    continue;
    747747                }
    748                 Point screen = mv.getPoint(trkPnt.getEastNorth());
     748                Point screen = mv.getPoint(trkPnt);
    749749
    750750                if (hdopCircle && trkPnt.get(GpxConstants.PT_HDOP) != null) {
     
    787787                }
    788788                if (!trkPnt.drawLine) {
    789                     Point screen = mv.getPoint(trkPnt.getEastNorth());
     789                    Point screen = mv.getPoint(trkPnt);
    790790                    g.drawRect(screen.x, screen.y, 0, 0);
    791791                }
     
    803803                    continue;
    804804                }
    805                 Point screen = mv.getPoint(trkPnt.getEastNorth());
     805                Point screen = mv.getPoint(trkPnt);
    806806                g.setColor(trkPnt.customColoring);
    807807                g.drawRect(screen.x, screen.y, 0, 0);
     
    853853
    854854            // transform coordinates
    855             final Point paintPnt = mv.getPoint(trkPnt.getEastNorth());
     855            final Point paintPnt = mv.getPoint(trkPnt);
    856856
    857857            // skip single points
     
    11121112
    11131113            // get transformed coordinates
    1114             final Point paintPnt = mv.getPoint(trkPnt.getEastNorth());
     1114            final Point paintPnt = mv.getPoint(trkPnt);
    11151115
    11161116            // end of line segment or end of list reached
     
    13621362
    13631363            // get transformed coordinates
    1364             final Point paintPnt = mv.getPoint(trkPnt.getEastNorth());
     1364            final Point paintPnt = mv.getPoint(trkPnt);
    13651365
    13661366            // end of line segment or end of list reached
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java

    r12636 r12725  
    187187                    continue;
    188188                }
    189                 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(), snapDistance);
     189                WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(Main.getProjection()), snapDistance);
    190190                if (wNear != null) {
    191191                    WayPoint wc = new WayPoint(w.getCoor());
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r12630 r12725  
    3939
    4040    @Override public boolean containsPoint(Point p) {
    41         Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth());
     41        Point screen = MainApplication.getMap().mapView.getPoint(this);
    4242        buttonRectangle.setLocation(screen.x+4, screen.y+2);
    4343        return buttonRectangle.contains(p);
     
    4949            return;
    5050        }
    51         Point screen = mv.getPoint(getEastNorth());
     51        Point screen = mv.getPoint(this);
    5252        buttonRectangle.setLocation(screen.x+4, screen.y+2);
    5353        paintIcon(mv, g, screen.x+4, screen.y+2);
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r12656 r12725  
    2323import javax.swing.ImageIcon;
    2424
     25import org.openstreetmap.josm.Main;
    2526import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
    2627import org.openstreetmap.josm.data.coor.CachedLatLon;
    2728import org.openstreetmap.josm.data.coor.EastNorth;
     29import org.openstreetmap.josm.data.coor.ILatLon;
    2830import org.openstreetmap.josm.data.coor.LatLon;
    2931import org.openstreetmap.josm.data.gpx.GpxConstants;
     
    7577 * @author Frederik Ramm
    7678 */
    77 public class Marker implements TemplateEngineDataProvider {
     79public class Marker implements TemplateEngineDataProvider, ILatLon {
    7880
    7981    public static final class TemplateEntryProperty extends CachedProperty<TemplateEntry> {
     
    318320
    319321    /**
     322     * @since 12725
     323     */
     324    @Override
     325    public double lon() {
     326        return coor == null ? Double.NaN : coor.lon();
     327    }
     328
     329    /**
     330     * @since 12725
     331     */
     332    @Override
     333    public double lat() {
     334        return coor == null ? Double.NaN : coor.lat();
     335    }
     336
     337    /**
    320338     * Returns the marker's projected coordinates.
    321339     * @return The marker's projected coordinates (easting/northing)
    322      */
     340     * @deprecated use {@link #getEastNorth(org.openstreetmap.josm.data.projection.Projecting)}
     341     */
     342    @Deprecated
    323343    public final EastNorth getEastNorth() {
    324         return coor.getEastNorth();
     344        return coor.getEastNorth(Main.getProjection());
    325345    }
    326346
     
    354374     */
    355375    public void paint(Graphics g, MapView mv, boolean mousePressed, boolean showTextOrIcon) {
    356         Point screen = mv.getPoint(getEastNorth());
     376        Point screen = mv.getPoint(this);
    357377        if (symbol != null && showTextOrIcon) {
    358378            paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2);
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r12636 r12725  
    211211    @Override public void visitBoundingBox(BoundingXYVisitor v) {
    212212        for (Marker mkr : data) {
    213             v.visit(mkr.getEastNorth());
     213            v.visit(mkr);
    214214        }
    215215    }
     
    352352            }
    353353        }
    354         MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth());
     354        MainApplication.getMap().mapView.zoomTo(currentMarker);
    355355    }
    356356
     
    371371            }
    372372        }
    373         MainApplication.getMap().mapView.zoomTo(currentMarker.getEastNorth());
     373        MainApplication.getMap().mapView.zoomTo(currentMarker);
    374374    }
    375375
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r12630 r12725  
    8585    @Override
    8686    public boolean containsPoint(Point p) {
    87         Point screen = MainApplication.getMap().mapView.getPoint(getEastNorth());
     87        Point screen = MainApplication.getMap().mapView.getPoint(this);
    8888        Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(),
    8989                symbol.getIconHeight());
     
    214214            for (Marker m : recent.parentLayer.data) {
    215215                if (m instanceof AudioMarker) {
    216                     double distanceSquared = m.getEastNorth().distanceSq(en);
     216                    double distanceSquared = m.getEastNorth(Main.getProjection()).distanceSq(en);
    217217                    if (distanceSquared < closestAudioMarkerDistanceSquared) {
    218218                        ca = (AudioMarker) m;
     
    283283    public void paint(Graphics g, MapView mv) {
    284284        if (time < 0.0) return;
    285         Point screen = mv.getPoint(getEastNorth());
     285        Point screen = mv.getPoint(this);
    286286        paintIcon(mv, g, screen.x, screen.y);
    287287    }
     
    347347            return;
    348348        setEastNorth(w2 == null ?
    349                 w1.getEastNorth() :
    350                     w1.getEastNorth().interpolate(w2.getEastNorth(),
     349                w1.getEastNorth(Main.getProjection()) :
     350                    w1.getEastNorth(Main.getProjection()).interpolate(w2.getEastNorth(Main.getProjection()),
    351351                            (audioTime - w1.time)/(w2.time - w1.time)));
    352352        time = audioTime;
     
    354354        if (jumpToMarker) {
    355355            jumpToMarker = false;
    356             mapView.zoomTo(w1.getEastNorth());
     356            mapView.zoomTo(w1);
    357357        }
    358358        mapView.repaint();
Note: See TracChangeset for help on using the changeset viewer.