Ignore:
Timestamp:
2017-05-15T15:43:30+02:00 (3 years ago)
Author:
michael2402
Message:

See #13415: Add the ILatLon interface, unify handling of Nodes and CachedLatLon

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r12074 r12161  
    2020import org.openstreetmap.josm.data.ProjectionBounds;
    2121import org.openstreetmap.josm.data.coor.EastNorth;
     22import org.openstreetmap.josm.data.coor.ILatLon;
    2223import org.openstreetmap.josm.data.coor.LatLon;
    2324import org.openstreetmap.josm.data.osm.Node;
     
    180181    /**
    181182     * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate.
     183     * <p>
     184     * This method exists to not break binary compatibility with old plugins
    182185     * @param latlon the position
    183186     * @return The point for that position.
     
    185188     */
    186189    public MapViewPoint getPointFor(LatLon latlon) {
    187         return getPointFor(getProjection().latlon2eastNorth(latlon));
     190        return getPointFor((ILatLon) latlon);
     191    }
     192
     193    /**
     194     * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate.
     195     * @param latlon the position
     196     * @return The point for that position.
     197     * @since xxx
     198     */
     199    public MapViewPoint getPointFor(ILatLon latlon) {
     200        try {
     201            return getPointFor(Optional.ofNullable(latlon.getEastNorth(getProjection()))
     202                    .orElseThrow(IllegalArgumentException::new));
     203        } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
     204            throw BugReport.intercept(e).put("latlon", latlon);
     205        }
    188206    }
    189207
     
    196214     */
    197215    public MapViewPoint getPointFor(Node node) {
    198         try {
    199             return getPointFor(Optional.ofNullable(node.getEastNorth(getProjection()))
    200                     .orElseThrow(IllegalArgumentException::new));
    201         } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
    202             throw BugReport.intercept(e).put("node", node);
    203         }
     216        return getPointFor((ILatLon) node);
    204217    }
    205218
     
    249262     * Gets the current projection used for the MapView.
    250263     * @return The projection.
     264     * @see #getProjecting()
    251265     */
    252266    public Projection getProjection() {
    253267        return projecting.getBaseProjection();
     268    }
     269
     270    /**
     271     * Gets the current projecting instance that is used to convert between east/north and lat/lon space.
     272     * @return The projection.
     273     * @since xxx
     274     */
     275    public Projecting getProjecting() {
     276        return projecting;
    254277    }
    255278
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r10198 r12161  
    203203
    204204    void addCoordinates(Node n) {
    205         if (n.getCoor() != null) {
     205        if (n.isLatLonKnown()) {
    206206            add(tr("Coordinates: "),
    207                     Double.toString(n.getCoor().lat()), ", ",
    208                     Double.toString(n.getCoor().lon()));
     207                    Double.toString(n.lat()), ", ",
     208                    Double.toString(n.lon()));
    209209            add(tr("Coordinates (projected): "),
    210210                    Double.toString(n.getEastNorth().east()), ", ",
  • trunk/src/org/openstreetmap/josm/gui/draw/MapViewPath.java

    r11817 r12161  
    99
    1010import org.openstreetmap.josm.data.coor.EastNorth;
    11 import org.openstreetmap.josm.data.osm.Node;
     11import org.openstreetmap.josm.data.coor.ILatLon;
    1212import org.openstreetmap.josm.gui.MapView;
    1313import org.openstreetmap.josm.gui.MapViewState;
     
    5757     * @return this for easy chaining.
    5858     */
    59     public MapViewPath moveTo(Node n) {
    60         moveTo(n.getEastNorth());
     59    public MapViewPath moveTo(ILatLon n) {
     60        moveTo(n.getEastNorth(state.getProjecting()));
    6161        return this;
    6262    }
     
    8585     * @return this for easy chaining.
    8686     */
    87     public MapViewPath lineTo(Node n) {
    88         lineTo(n.getEastNorth());
     87    public MapViewPath lineTo(ILatLon n) {
     88        lineTo(n.getEastNorth(state.getProjecting()));
    8989        return this;
    9090    }
     
    115115     * @return this for easy chaining.
    116116     */
    117     public MapViewPath shapeAround(Node p1, SymbolShape symbol, double size) {
    118         shapeAround(p1.getEastNorth(), symbol, size);
     117    public MapViewPath shapeAround(ILatLon p1, SymbolShape symbol, double size) {
     118        shapeAround(p1.getEastNorth(state.getProjecting()), symbol, size);
    119119        return this;
    120120    }
     
    144144     * @return this for easy chaining.
    145145     */
    146     public MapViewPath append(Iterable<Node> nodes, boolean connect) {
     146    public MapViewPath append(Iterable<? extends ILatLon> nodes, boolean connect) {
    147147        appendWay(nodes, connect, false);
    148148        return this;
     
    155155     * @return this for easy chaining.
    156156     */
    157     public MapViewPath appendClosed(Iterable<Node> nodes, boolean connect) {
     157    public MapViewPath appendClosed(Iterable<? extends ILatLon> nodes, boolean connect) {
    158158        appendWay(nodes, connect, true);
    159159        return this;
    160160    }
    161161
    162     private void appendWay(Iterable<Node> nodes, boolean connect, boolean close) {
     162    private void appendWay(Iterable<? extends ILatLon> nodes, boolean connect, boolean close) {
    163163        boolean useMoveTo = !connect;
    164         Node first = null;
    165         for (Node n : nodes) {
     164        ILatLon first = null;
     165        for (ILatLon n : nodes) {
    166166            if (useMoveTo) {
    167167                moveTo(n);
Note: See TracChangeset for help on using the changeset viewer.