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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.