Changeset 12161 in josm for trunk/src


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

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

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

Legend:

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

    r11381 r12161  
    3131        StringBuilder s = new StringBuilder();
    3232        for (Node n : getSelectedNodes()) {
    33             s.append(n.getCoor().lat());
     33            s.append(n.lat());
    3434            s.append(", ");
    35             s.append(n.getCoor().lon());
     35            s.append(n.lon());
    3636            s.append('\n');
    3737        }
  • trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java

    r11488 r12161  
    245245            Node n = wnew.get(i);
    246246            double xte = Math.abs(Ellipsoid.WGS84.a
    247                     * xtd(fromN.getCoor().lat() * Math.PI / 180, fromN.getCoor().lon() * Math.PI / 180, toN.getCoor().lat() * Math.PI
    248                             / 180, toN.getCoor().lon() * Math.PI / 180, n.getCoor().lat() * Math.PI / 180, n.getCoor().lon() * Math.PI
    249                             / 180));
     247                    * xtd(fromN.lat() * Math.PI / 180, fromN.lon() * Math.PI / 180, toN.lat() * Math.PI / 180,
     248                            toN.lon() * Math.PI / 180,     n.lat() * Math.PI / 180,   n.lon() * Math.PI / 180));
    250249            if (xte > xtemax) {
    251250                xtemax = xte;
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r11747 r12161  
    1010import java.util.function.Consumer;
    1111
     12import org.openstreetmap.josm.data.coor.ILatLon;
    1213import org.openstreetmap.josm.data.coor.LatLon;
    1314import org.openstreetmap.josm.data.osm.BBox;
     
    1819 * This is a simple data class for "rectangular" areas of the world, given in
    1920 * lat/lon min/max values.  The values are rounded to LatLon.OSM_SERVER_PRECISION
     21 *
     22 * @see BBox to represent invalid areas.
    2023 *
    2124 * @author imi
     
    390393    /**
    391394     * Determines if the given point {@code ll} is within these bounds.
     395     * <p>
     396     * Points with unknown coordinates are always outside the coordinates.
    392397     * @param ll The lat/lon to check
    393398     * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise
    394399     */
    395400    public boolean contains(LatLon ll) {
     401        // binary compatibility
     402        return contains((ILatLon) ll);
     403    }
     404
     405    /**
     406     * Determines if the given point {@code ll} is within these bounds.
     407     * <p>
     408     * Points with unknown coordinates are always outside the coordinates.
     409     * @param ll The lat/lon to check
     410     * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise
     411     * @since xxx
     412     */
     413    public boolean contains(ILatLon ll) {
     414        if (!ll.isLatLonKnown()) {
     415            return false;
     416        }
    396417        if (ll.lat() < minLat || ll.lat() > maxLat)
    397418            return false;
  • trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java

    r10334 r12161  
    55
    66import org.openstreetmap.josm.Main;
     7import org.openstreetmap.josm.data.projection.Projecting;
    78import org.openstreetmap.josm.data.projection.Projection;
    89
     
    2021
    2122    private EastNorth eastNorth;
    22     private transient Projection proj;
     23    private transient Object cacheKey;
    2324
    2425    /**
     
    3738    public CachedLatLon(LatLon coor) {
    3839        super(coor.lat(), coor.lon());
    39         proj = null;
     40        cacheKey = null;
    4041    }
    4142
     
    4546     */
    4647    public CachedLatLon(EastNorth eastNorth) {
    47         super(Main.getProjection().eastNorth2latlon(eastNorth));
    48         proj = Main.getProjection();
     48        this(eastNorth, Main.getProjection());
     49    }
     50
     51    private CachedLatLon(EastNorth eastNorth, Projection projection) {
     52        super(projection.eastNorth2latlon(eastNorth));
     53        cacheKey = projection.getCacheKey();
    4954        this.eastNorth = eastNorth;
    5055    }
     
    5560     * @return the internally cached east/north coordinates. null, if the globally defined projection is null
    5661     */
    57     public final EastNorth getEastNorth() {
    58         if (!Objects.equals(proj, Main.getProjection())) {
    59             proj = Main.getProjection();
    60             eastNorth = proj.latlon2eastNorth(this);
     62    @Override
     63    public final EastNorth getEastNorth(Projecting projecting) {
     64        if (!Objects.equals(cacheKey, projecting.getCacheKey())) {
     65            cacheKey = projecting.getCacheKey();
     66            eastNorth = projecting.latlon2eastNorth(this);
    6167        }
    6268        return eastNorth;
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r12131 r12161  
    4343 * @author Imi
    4444 */
    45 public class LatLon extends Coordinate {
     45public class LatLon extends Coordinate implements ILatLon {
    4646
    4747    private static final long serialVersionUID = 1L;
     
    251251    }
    252252
    253     protected LatLon(LatLon coor) {
     253    /**
     254     * Creates a new LatLon object for the given coordinate
     255     * @param coor The coordinates to copy from.
     256     */
     257    public LatLon(ILatLon coor) {
    254258        super(coor.lon(), coor.lat());
    255259    }
     
    263267    }
    264268
    265     /**
    266      * Returns the latitude, i.e., the north-south position in degrees.
    267      * @return the latitude
    268      */
     269    @Override
    269270    public double lat() {
    270271        return y;
     
    286287    }
    287288
    288     /**
    289      * Returns the longitude, i.e., the east-west position in degrees.
    290      * @return the longitude
    291      */
     289    @Override
    292290    public double lon() {
    293291        return x;
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r11452 r12161  
    77
    88import org.openstreetmap.josm.data.Bounds;
     9import org.openstreetmap.josm.data.coor.ILatLon;
    910import org.openstreetmap.josm.data.coor.LatLon;
    1011import org.openstreetmap.josm.data.coor.QuadTiling;
     
    8586     */
    8687    public BBox(Way w) {
    87         w.getNodes().forEach(n -> add(n.getCoor()));
     88        w.getNodes().forEach(this::add);
    8889    }
    8990
     
    9394     */
    9495    public BBox(Node n) {
    95         if (n.isLatLonKnown()) {
    96             add(n.getCoor());
    97         }
     96        this((ILatLon) n);
     97    }
     98
     99    /**
     100     * Create BBox for a given latlon. An invalid BBox is returned if the coordinates are not known.
     101     * @param ll The lat lon position
     102     */
     103    public BBox(ILatLon ll) {
     104        add(ll);
     105    }
     106
     107    /**
     108     * Add a point to an existing BBox. Extends this bbox if necessary so that this.bounds(c) will return true
     109     * if c is a valid LatLon instance.
     110     * Kept for binary compatibility
     111     * @param c a LatLon point
     112     */
     113    public final void add(LatLon c) {
     114        add((ILatLon) c);
    98115    }
    99116
     
    103120     * @param c a LatLon point
    104121     */
    105     public final void add(LatLon c) {
    106         if (c != null && c.isValid()) {
    107             add(c.lon(), c.lat());
    108         }
     122    public final void add(ILatLon c) {
     123        add(c.lon(), c.lat());
    109124    }
    110125
  • trunk/src/org/openstreetmap/josm/data/osm/INode.java

    r9460 r12161  
    33
    44import org.openstreetmap.josm.data.coor.EastNorth;
     5import org.openstreetmap.josm.data.coor.ILatLon;
    56import org.openstreetmap.josm.data.coor.LatLon;
    67
     
    910 * @since 4098
    1011 */
    11 public interface INode extends IPrimitive {
     12public interface INode extends IPrimitive, ILatLon {
    1213
    1314    /**
     
    2425
    2526    /**
    26      * Returns east/north coordinates of this node.
    27      * @return east/north coordinates of this node
    28      */
    29     EastNorth getEastNorth();
    30 
    31     /**
    3227     * Sets east/north coordinates of this node.
    3328     * @param eastNorth east/north coordinates of this node
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r12031 r12161  
    1515import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    1616import org.openstreetmap.josm.data.osm.visitor.Visitor;
    17 import org.openstreetmap.josm.data.projection.Projection;
     17import org.openstreetmap.josm.data.projection.Projecting;
    1818import org.openstreetmap.josm.data.projection.Projections;
    1919import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    4848     * @since 7828
    4949     */
     50    @Override
    5051    public boolean isLatLonKnown() {
     52        // We cannot use default implementation - if we remove this implementation, we will break binary compatibility.
    5153        return !Double.isNaN(lat) && !Double.isNaN(lon);
    5254    }
     
    8183    @Override
    8284    public LatLon getCoor() {
    83         if (!isLatLonKnown()) return null;
    84         return new LatLon(lat, lon);
    85     }
    86 
    87     /**
    88      * <p>Replies the projected east/north coordinates.</p>
    89      *
    90      * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.
    91      * Internally caches the projected coordinates.</p>
    92      *
    93      * <p>Replies {@code null} if this node doesn't know lat/lon-coordinates, i.e. because it is an incomplete node.
    94      *
    95      * @return the east north coordinates or {@code null}
    96      * @see #invalidateEastNorthCache()
    97      *
    98      */
    99     @Override
    100     public EastNorth getEastNorth() {
    101         return getEastNorth(Main.getProjection());
    102     }
    103 
    104     /**
    105      * Replies the projected east/north coordinates.
    106      * <p>
    107      * The result of the last conversion is cached. The cache object is used as cache key.
    108      * @param projection The projection to use.
    109      * @return The projected east/north coordinates
    110      * @since 10827
    111      */
    112     public EastNorth getEastNorth(Projection projection) {
     85        if (!isLatLonKnown()) {
     86            return null;
     87        } else {
     88            return new LatLon(lat, lon);
     89        }
     90    }
     91
     92    @Override
     93    public double lat() {
     94        return lat;
     95    }
     96
     97    @Override
     98    public double lon() {
     99        return lon;
     100    }
     101
     102    @Override
     103    public EastNorth getEastNorth(Projecting projection) {
    113104        if (!isLatLonKnown()) return null;
    114105
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r12017 r12161  
    4141    }
    4242
    43     private boolean isLatLonKnown() {
     43    @Override
     44    public double lat() {
     45        return lat;
     46    }
     47
     48    @Override
     49    public double lon() {
     50        return lon;
     51    }
     52
     53    @Override
     54    public boolean isLatLonKnown() {
    4455        return !Double.isNaN(lat) && !Double.isNaN(lon);
    4556    }
  • trunk/src/org/openstreetmap/josm/data/osm/NodePositionComparator.java

    r9880 r12161  
    2020            return 0;
    2121
    22         int dLat = Double.compare(n1.getCoor().lat(), n2.getCoor().lat());
    23         return dLat != 0 ? dLat : Double.compare(n1.getCoor().lon(), n2.getCoor().lon());
     22        int dLat = Double.compare(n1.lat(), n2.lat());
     23        return dLat != 0 ? dLat : Double.compare(n1.lon(), n2.lon());
    2424    }
    2525}
  • trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java

    r12149 r12161  
    1010import org.openstreetmap.josm.data.ProjectionBounds;
    1111import org.openstreetmap.josm.data.coor.EastNorth;
     12import org.openstreetmap.josm.data.coor.ILatLon;
    1213import org.openstreetmap.josm.data.coor.LatLon;
    1314import org.openstreetmap.josm.data.projection.datum.Datum;
     
    114115
    115116    @Override
    116     public EastNorth latlon2eastNorth(LatLon ll) {
    117         ll = datum.fromWGS84(ll);
     117    public EastNorth latlon2eastNorth(ILatLon toConvert) {
     118        // TODO: Use ILatLon in datum, so we don't need to wrap it here.
     119        LatLon ll = datum.fromWGS84(new LatLon(toConvert));
    118120        double[] en = proj.project(Utils.toRadians(ll.lat()), Utils.toRadians(LatLon.normalizeLon(ll.lon() - lon0 - pm)));
    119121        return new EastNorth((ellps.a * k0 * en[0] + x0) / toMeter, (ellps.a * k0 * en[1] + y0) / toMeter);
     
    122124    @Override
    123125    public LatLon eastNorth2latlon(EastNorth en) {
     126        // We know it is a latlon. Nice would be to change this method return type to ILatLon
    124127        return eastNorth2latlon(en, LatLon::normalizeLon);
    125128    }
     
    127130    @Override
    128131    public LatLon eastNorth2latlonClamped(EastNorth en) {
    129         LatLon ll = eastNorth2latlon(en, lon -> Utils.clamp(lon, -180, 180));
     132        ILatLon ll = eastNorth2latlon(en, lon -> Utils.clamp(lon, -180, 180));
    130133        Bounds bounds = getWorldBoundsLatLon();
    131134        return new LatLon(Utils.clamp(ll.lat(), bounds.getMinLat(), bounds.getMaxLat()),
  • trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java

    r12013 r12161  
    77package org.openstreetmap.josm.data.projection;
    88
     9import org.openstreetmap.josm.data.coor.ILatLon;
    910import org.openstreetmap.josm.data.coor.LatLon;
    1011import org.openstreetmap.josm.tools.Utils;
  • trunk/src/org/openstreetmap/josm/data/projection/Projecting.java

    r10805 r12161  
    66import org.openstreetmap.josm.data.ProjectionBounds;
    77import org.openstreetmap.josm.data.coor.EastNorth;
     8import org.openstreetmap.josm.data.coor.ILatLon;
    89import org.openstreetmap.josm.data.coor.LatLon;
    910
     
    1920    /**
    2021     * Convert from lat/lon to easting/northing.
     22     * <p>
     23     * This method exists to not break binary compatibility with old plugins
    2124     *
    2225     * @param ll the geographical point to convert (in WGS84 lat/lon)
    2326     * @return the corresponding east/north coordinates
    2427     */
    25     EastNorth latlon2eastNorth(LatLon ll);
     28    default EastNorth latlon2eastNorth(LatLon ll) {
     29        return latlon2eastNorth((ILatLon) ll);
     30    }
     31
     32    /**
     33     * Convert from lat/lon to easting/northing. This method uses the newer {@link ILatLon} interface.
     34     *
     35     * @param ll the geographical point to convert (in WGS84 lat/lon)
     36     * @return the corresponding east/north coordinates
     37     * @since xxx
     38     */
     39    EastNorth latlon2eastNorth(ILatLon ll);
    2640
    2741    /**
     
    4862     */
    4963    Map<ProjectionBounds, Projecting> getProjectingsForArea(ProjectionBounds area);
     64
     65    /**
     66     * Gets the object used as cache identifier when caching results of this projection.
     67     * @return The object to use as cache key
     68     * @since 10827
     69     */
     70    default Object getCacheKey() {
     71        return this;
     72    }
    5073}
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r11858 r12161  
    119119     */
    120120    boolean switchXY();
    121 
    122     /**
    123      * Gets the object used as cache identifier when caching results of this projection.
    124      * @return The object to use as cache key
    125      * @since 10827
    126      */
    127     default Object getCacheKey() {
    128         return this;
    129     }
    130121}
  • trunk/src/org/openstreetmap/josm/data/projection/ShiftedProjecting.java

    r10836 r12161  
    77import org.openstreetmap.josm.data.ProjectionBounds;
    88import org.openstreetmap.josm.data.coor.EastNorth;
     9import org.openstreetmap.josm.data.coor.ILatLon;
    910import org.openstreetmap.josm.data.coor.LatLon;
    1011
     
    2930
    3031    @Override
    31     public EastNorth latlon2eastNorth(LatLon ll) {
     32    public EastNorth latlon2eastNorth(ILatLon ll) {
    3233        return base.latlon2eastNorth(ll).add(offset);
    3334    }
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r12131 r12161  
    33
    44import java.awt.Color;
    5 import java.awt.Graphics;
     5import java.awt.Graphics2D;
    66import java.awt.Point;
    77import java.util.HashSet;
     
    1818import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
    1919import org.openstreetmap.josm.gui.MapView;
     20import org.openstreetmap.josm.gui.draw.MapViewPath;
     21import org.openstreetmap.josm.gui.draw.SymbolShape;
    2022import org.openstreetmap.josm.tools.Utils;
    2123
     
    2729public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {
    2830    /** The graphics */
    29     private final Graphics g;
     31    private final Graphics2D g;
    3032    /** The MapView */
    3133    private final MapView mv;
     
    4446     * @param mv The Mapview
    4547     */
    46     public PaintVisitor(Graphics g, MapView mv) {
     48    public PaintVisitor(Graphics2D g, MapView mv) {
    4749        this.g = g;
    4850        this.mv = mv;
     
    121123
    122124        if (!paintedPoints.contains(pp)) {
    123             Point p = mv.getPoint(n);
     125            MapViewPath circle = new MapViewPath(mv.getState()).shapeAround(n, SymbolShape.CIRCLE, 10);
    124126
    125127            if (selected) {
    126128                g.setColor(getHighlightColor(color));
    127                 g.fillOval(p.x - 5, p.y - 5, 10, 10);
     129                g.fill(circle);
    128130            }
    129131            g.setColor(color);
    130             g.drawOval(p.x - 5, p.y - 5, 10, 10);
     132            g.draw(circle);
    131133            paintedPoints.add(pp);
    132134        }
  • 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);
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r11779 r12161  
    2222import org.openstreetmap.josm.command.Command;
    2323import org.openstreetmap.josm.data.coor.EastNorth;
    24 import org.openstreetmap.josm.data.coor.LatLon;
    2524import org.openstreetmap.josm.data.osm.BBox;
    2625import org.openstreetmap.josm.data.osm.DataSet;
     
    224223        BBox bounds = new BBox(nodes.get(0));
    225224        for (Node n: nodes) {
    226             bounds.add(n.getCoor());
     225            bounds.add(n);
    227226        }
    228227        return bounds;
     
    417416            return p2;
    418417        else
    419             return new EastNorth(p1.getX() + ldx * offset, p1.getY() + ldy * offset);
     418            return p1.interpolate(p2, offset);
    420419    }
    421420
     
    513512        for (Node n : polygon) {
    514513            if (begin) {
    515                 path.moveTo(n.getCoor().lon(), n.getCoor().lat());
     514                path.moveTo(n.lon(), n.lat());
    516515                begin = false;
    517516            } else {
    518                 path.lineTo(n.getCoor().lon(), n.getCoor().lat());
     517                path.lineTo(n.lon(), n.lat());
    519518            }
    520519        }
     
    728727
    729728        for (int node = 1; node <= /*sic! consider last-first as well*/ nodesCount; node++) {
    730             LatLon coorPrev = nodes.get(node - 1).getCoor();
    731             LatLon coorCurr = nodes.get(node % nodesCount).getCoor();
     729            Node coorPrev = nodes.get(node - 1);
     730            Node coorCurr = nodes.get(node % nodesCount);
    732731            area2 += coorPrev.lon() * coorCurr.lat();
    733732            area2 -= coorCurr.lon() * coorPrev.lat();
     
    988987        double area = 0;
    989988        double perimeter = 0;
     989        Projection useProjection = projection == null ? Main.getProjection() : projection;
     990
    990991        if (!nodes.isEmpty()) {
    991992            boolean closed = nodes.get(0) == nodes.get(nodes.size() - 1);
    992993            int numSegments = closed ? nodes.size() - 1 : nodes.size();
    993             EastNorth p1 = projection == null ? nodes.get(0).getEastNorth() : projection.latlon2eastNorth(nodes.get(0).getCoor());
     994            EastNorth p1 = nodes.get(0).getEastNorth(useProjection);
    994995            for (int i = 1; i <= numSegments; i++) {
    995996                final Node node = nodes.get(i == numSegments ? 0 : i);
    996                 final EastNorth p2 = projection == null ? node.getEastNorth() : projection.latlon2eastNorth(node.getCoor());
     997                final EastNorth p2 = node.getEastNorth(useProjection);
    997998                if (p1 != null && p2 != null) {
    998999                    area += p1.east() * p2.north() - p2.east() * p1.north();
Note: See TracChangeset for help on using the changeset viewer.