Changeset 35976 in osm for applications/editors/josm


Ignore:
Timestamp:
2022-06-14T20:11:21+02:00 (2 years ago)
Author:
taylor.smock
Message:

see #22104: Remove usages of Node#getCoor where possible

This also accounts for cases where Node has the methods used later,
so a new LatLon is unnecessary.

Location:
applications/editors/josm/plugins
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/LengthAction.java

    r35942 r35976  
    137137        mousePos = e.getPoint();
    138138        if (nearestNode != null) {
    139             drawStartPos = MainApplication.getMap().mapView.getPoint(nearestNode.getCoor());
     139            drawStartPos = MainApplication.getMap().mapView.getPoint(nearestNode);
    140140        } else {
    141141            drawStartPos = mousePos;
     
    186186        MapFrame map = MainApplication.getMap();
    187187        if (nearestNode != null)
    188             drawEndPos = map.mapView.getPoint(nearestNode.getCoor());
     188            drawEndPos = map.mapView.getPoint(nearestNode);
    189189        else
    190190            drawEndPos = mousePos;
  • applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/PointAction.java

    r35297 r35976  
    7676        if (e.getButton() == MouseEvent.BUTTON1) {
    7777            if (isCtrlDown) {
    78                 if (pointList.size() > 0) {
     78                if (!pointList.isEmpty()) {
    7979                    pointList.remove(pointList.size() - 1);
    8080                    updateTextEdit();
     
    8888                    return;
    8989                }
    90                 LatLon coor = node.getCoor();
    91                 String point = String.valueOf(coor.getX()) + "," + String.valueOf(coor.getY());
     90                String point = node.lon() + "," + node.lat();
    9291                int maxInstances = parentPlugin.currentCommand.parameters.get(parentPlugin.currentCommand.currentParameterNum).maxInstances;
    9392                if (maxInstances == 1) {
  • applications/editors/josm/plugins/Create_grid_of_ways/src/CreateGridOfWaysPlugin/CreateGridOfWaysAction.java

    r35583 r35976  
    1616import org.openstreetmap.josm.command.SequenceCommand;
    1717import org.openstreetmap.josm.data.UndoRedoHandler;
     18import org.openstreetmap.josm.data.coor.ILatLon;
    1819import org.openstreetmap.josm.data.coor.LatLon;
    1920import org.openstreetmap.josm.data.osm.DataSet;
     
    8586        int c1=0,c2;
    8687        double latDif,lonDif;
    87         LatLon llc = nodeCommon.getCoor();
     88        ILatLon llc = nodeCommon;
    8889        for (Node n1 : nodesWay1) {
    89             LatLon ll1 = n1.getCoor();
    90             if (ll1 == null || llc == null) {
     90            ILatLon ll1 = n1;
     91            if (!ll1.isLatLonKnown() || !llc.isLatLonKnown()) {
    9192                Logging.warn("Null coordinates: {0} / {1}", n1, nodeCommon);
    9293                continue;
     
    106107                    continue;
    107108                }
    108                 LatLon ll2 = n2.getCoor();
     109                ILatLon ll2 = n2;
    109110                Node nodeOfGrid = new Node(new LatLon(ll2.lat()+latDif, ll2.lon()+lonDif));
    110111                cmds.add(new AddCommand(ds, nodeOfGrid));
  • applications/editors/josm/plugins/CustomizePublicTransportStop/src/org/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java

    r34501 r35976  
    115115        if (platform instanceof Way) {
    116116            // p = mapView.getPoint((Node) stopArea.selectedObject);
    117             Double sumLat = 0.0;
    118             Double sumLon = 0.0;
    119             Integer countNode = 0;
     117            double sumLat = 0.0;
     118            double sumLon = 0.0;
     119            final int countNode = ((Way) platform).getNodesCount();
    120120            for (Node node : ((Way) platform).getNodes()) {
    121                 LatLon coord = node.getCoor();
    122                 sumLat += coord.getX();
    123                 sumLon += coord.getY();
    124                 countNode++;
     121                sumLat += node.lat();
     122                sumLon += node.lon();
    125123            }
    126124            return new LatLon(sumLon / countNode, sumLat / countNode);
  • applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditDialog.java

    r34880 r35976  
    275275
    276276                for (Node node : way.getNodes()) {
    277                     mapViewer.addMapMarker(new MapMarkerDot(Color.GREEN, node.getCoor().lat(), node.getCoor().lon()));
     277                    mapViewer.addMapMarker(new MapMarkerDot(Color.GREEN, node.lat(), node.lon()));
    278278                }
    279279            }
  • applications/editors/josm/plugins/comfort0/build.xml

    r35765 r35976  
    33
    44    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    5     <property name="plugin.main.version" value="9229"/>
     5    <property name="plugin.main.version" value="12164"/>
    66    <property name="plugin.canloadatruntime" value="true"/>
    77
  • applications/editors/josm/plugins/comfort0/src/net/simon04/comfort0/OsmToLevel0L.java

    r35585 r35976  
    33import java.util.Collection;
    44
    5 import org.openstreetmap.josm.data.coor.LatLon;
     5import org.openstreetmap.josm.data.coor.ILatLon;
    66import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
    77import org.openstreetmap.josm.data.osm.KeyValueVisitor;
     
    7979        sb.append(p.getType().getAPIName()).append(" ").append(p.getUniqueId());
    8080        if (p instanceof Node) {
    81             final LatLon latLon = ((Node) p).getCoor();
    82             if (latLon != null) {
     81            final ILatLon latLon = (Node) p;
     82            if (latLon.isLatLonKnown()) {
    8383                sb.append(": ").append(latLon.lat()).append(", ").append(latLon.lon());
    8484            }
  • applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/data/JOSMDataSource.java

    r33842 r35976  
    2929    @Override
    3030    public double getLat(Node node) {
    31         return node.getCoor().lat();
     31        return node.lat();
    3232    }
    3333
    3434    @Override
    3535    public double getLon(Node node) {
    36         return node.getCoor().lon();
     36        return node.lon();
    3737    }
    3838
  • applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java

    r35723 r35976  
    2323import javax.swing.AbstractAction;
    2424
    25 import org.openstreetmap.josm.data.coor.LatLon;
     25import org.openstreetmap.josm.data.coor.ILatLon;
    2626import org.openstreetmap.josm.data.osm.BBox;
    2727import org.openstreetmap.josm.data.osm.IPrimitive;
     
    342342    }
    343343
    344     protected static final boolean areNodeListAndBboxEqual(List<Node> nodes, BBox bBox) {
     344    protected static boolean areNodeListAndBboxEqual(List<Node> nodes, BBox bBox) {
    345345        if (nodes.size() == 5) {
    346346            Map<Double, List<Integer>> latMap = new HashMap<>();
    347347            Map<Double, List<Integer>> lonMap = new HashMap<>();
    348348
    349             for (int i=0; i<4; i++) {
    350                 LatLon c = nodes.get(i).getCoor();
     349            for (int i = 0; i < 4; i++) {
     350                ILatLon c = nodes.get(i);
    351351                if (i > 1) {
    352                     LatLon b = nodes.get(i-1).getCoor();
     352                    ILatLon b = nodes.get(i - 1);
    353353                    if (b.lat() != c.lat() && b.lon() != c.lon()) {
    354354                        return false;
    355355                    }
    356356                }
    357                 List<Integer> latList = latMap.get(c.lat());
    358                 if (latList == null) {
    359                     latList = new ArrayList<>();
    360                     latMap.put(c.lat(), latList);
    361                 }
     357                List<Integer> latList = latMap.computeIfAbsent(c.lat(), lat -> new ArrayList<>(1));
    362358                latList.add(i);
    363                 List<Integer> lonList = lonMap.get(c.lon());
    364                 if (lonList == null) {
    365                     lonList = new ArrayList<>();
    366                     lonMap.put(c.lon(), lonList);
    367                 }
     359                List<Integer> lonList = lonMap.computeIfAbsent(c.lon(), lon -> new ArrayList<>(1));
    368360                lonList.add(i);
    369361            }
     
    392384    }
    393385
    394     protected static final String getNodeListShape(List<Node> nodes) {
     386    protected static String getNodeListShape(List<Node> nodes) {
    395387        StringBuilder result = new StringBuilder("            <shape>\n");
    396388        int size = nodes.size();
     
    402394            if (j == size)
    403395                j = 0;
    404             LatLon ll = nodes.get(i).getCoor();
     396            ILatLon ll = nodes.get(i);
    405397            result.append("<point lat='")
    406398                  .append(DF.format(ll.lat())).append("' lon='")
  • applications/editors/josm/plugins/importvec/src/org/openstreetmap/josm/plugins/importvec/SvgImportTask.java

    r35975 r35976  
    137137                        break;
    138138                    case PathIterator.SEG_CLOSE:
    139                         if (currentway.firstNode().getCoor().equalsEpsilon(nodes.getLast().getCoor(), ILatLon.MAX_SERVER_PRECISION)) {
     139                        if (currentway.firstNode().equalsEpsilon(nodes.getLast(), ILatLon.MAX_SERVER_PRECISION)) {
    140140                            currentway.removeNode(nodes.removeLast());
    141141                        }
  • applications/editors/josm/plugins/jts/build.xml

    r35884 r35976  
    44    <property name="commit.message" value="Commit message"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10580"/>
     6    <property name="plugin.main.version" value="12164"/>
    77   
    88    <property name="plugin.author" value="Josh Doe &lt;josh@joshdoe.com&gt;"/>
  • applications/editors/josm/plugins/jts/src/org/openstreetmap/josm/plugins/jts/JTSConverter.java

    r35122 r35976  
    7171            return new Coordinate(node.getEastNorth().getX(), node.getEastNorth().getY());
    7272        else
    73             return new Coordinate(node.getCoor().getX(), node.getCoor().getY());
     73            return new Coordinate(node.lon(), node.lat());
    7474    }
    7575
  • applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java

    r35579 r35976  
    209209                        } else {
    210210                            length += lastNode.getCoor().greatCircleDistance(n.getCoor());
    211                             segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor());
     211                            segAngle = MeasurementLayer.angleBetween(lastNode, n);
    212212                            lastNode = n;
    213213                        }
     
    235235                        wayArea += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor()))
    236236                                - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor()));
    237                         segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor());
     237                        segAngle = MeasurementLayer.angleBetween(lastN, n);
    238238                    }
    239239                    lastN = n;
  • applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java

    r35369 r35976  
    22package org.openstreetmap.josm.plugins.measurement;
    33/// @author Raphael Mack <ramack@raphael-mack.de>
     4
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    2829
    2930import org.openstreetmap.josm.data.Bounds;
     31import org.openstreetmap.josm.data.coor.ILatLon;
    3032import org.openstreetmap.josm.data.coor.LatLon;
    3133import org.openstreetmap.josm.data.gpx.IGpxTrack;
     
    171173    }
    172174
    173     public static double angleBetween(LatLon p1, LatLon p2){
     175    public static double angleBetween(ILatLon p1, ILatLon p2){
    174176        double lat1, lon1, lat2, lon2;
    175177        double dlon;
  • applications/editors/josm/plugins/namemanager/src/org/openstreetmap/josm/plugins/namemanager/utils/NameManagerUtils.java

    r34532 r35976  
    6060                }
    6161                pairs: for (Pair<Node, Node> pair : way.getNodePairs(false)) {
    62                     double x1Pair = pair.a.getCoor().getX();
    63                     double y1Pair = pair.a.getCoor().getY();
    64                     double x2Pair = pair.b.getCoor().getX();
    65                     double y2Pair = pair.b.getCoor().getY();
     62                    double x1Pair = pair.a.lon();
     63                    double y1Pair = pair.a.lat();
     64                    double x2Pair = pair.b.lon();
     65                    double y2Pair = pair.b.lat();
    6666                    double aPair = 0.0;
    6767                    double bPair = 0.0;
     
    7777                    int crossCount = 0;
    7878                    areaLine: for (Pair<Node, Node> areaLine : areaBorderLines) {
    79                         double x1Line = areaLine.a.getCoor().getX();
    80                         double y1Line = areaLine.a.getCoor().getY();
    81                         double x2Line = areaLine.b.getCoor().getX();
    82                         double y2Line = areaLine.b.getCoor().getY();
     79                        double x1Line = areaLine.a.lon();
     80                        double y1Line = areaLine.a.lat();
     81                        double x2Line = areaLine.b.lon();
     82                        double y2Line = areaLine.b.lat();
    8383                        boolean areaLinePerpendicular = false;
    8484                        double aLine = 0.0;
     
    178178                        }
    179179                        if (raySource != null) {
    180                             double rsX = raySource.getCoor().getX();
    181                             double rsY = raySource.getCoor().getY();
     180                            double rsX = raySource.lon();
     181                            double rsY = raySource.lat();
    182182                            if (areaLinePerpendicular) {
    183183                                if (x1Line == x2Line) {
     
    218218        List<Node> nodes = way.getNodes();
    219219        for (Node node : nodes) {
    220             if (node.getCoor().getX() < x) {
    221                 x = node.getCoor().getX();
    222             }
    223             if (node.getCoor().getY() > y) {
    224                 y = node.getCoor().getY();
     220            if (node.lon() < x) {
     221                x = node.lon();
     222            }
     223            if (node.lat() > y) {
     224                y = node.lat();
    225225            }
    226226        }
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java

    r35975 r35976  
    66import java.awt.Component;
    77import java.awt.GraphicsEnvironment;
    8 import java.awt.Point;
    98import java.io.IOException;
    109import java.io.InputStream;
     
    2524import javax.swing.Icon;
    2625import javax.swing.JOptionPane;
    27 import javax.xml.crypto.dsig.TransformException;
    2826
    2927import org.geotools.geometry.jts.JTS;
     
    3735import org.geotools.util.factory.Hints;
    3836import org.locationtech.jts.geom.LineString;
     37import org.locationtech.jts.geom.Point;
    3938import org.opengis.geometry.MismatchedDimensionException;
    4039import org.opengis.referencing.FactoryException;
     
    4443import org.opengis.referencing.crs.ProjectedCRS;
    4544import org.opengis.referencing.cs.CoordinateSystem;
     45import org.opengis.referencing.datum.Datum;
    4646import org.opengis.referencing.operation.MathTransform;
    4747import org.opengis.referencing.operation.OperationNotFoundException;
     48import org.opengis.referencing.operation.TransformException;
    4849import org.openstreetmap.josm.data.coor.ILatLon;
    4950import org.openstreetmap.josm.data.coor.LatLon;
     
    5455import org.openstreetmap.josm.data.osm.RelationMember;
    5556import org.openstreetmap.josm.data.osm.Way;
    56 import org.openstreetmap.josm.data.projection.datum.Datum;
    5757import org.openstreetmap.josm.data.validation.tests.DuplicateWay;
    5858import org.openstreetmap.josm.gui.ExtendedDialog;
     
    113113            LatLon ll = new LatLon(p.getY(), p.getX());
    114114            for (Node node : nodes.values()) {
    115                 if (node.getCoor().equalsEpsilon(ll, ILatLon.MAX_SERVER_PRECISION)) {
     115                if (node.equalsEpsilon(ll, ILatLon.MAX_SERVER_PRECISION)) {
    116116                    return node;
    117117                }
     
    261261        CoordinateSystem cs2 = crs2.getCoordinateSystem();
    262262        if (!compareDebug("cs", cs1, cs2)) {
    263             Integer dim1 = cs1.getDimension();
    264             Integer dim2 = cs2.getDimension();
     263            int dim1 = cs1.getDimension();
     264            int dim2 = cs2.getDimension();
    265265            if (compareDebug("cs.dim", dim1, dim2)) {
    266266                for (int i = 0; i < dim1; i++) {
     
    397397                }
    398398
    399                 if (candidates.size() > 0) {
     399                if (!candidates.isEmpty()) {
    400400                    CoordinateReferenceSystem newCRS = candidates.get(0);
    401401                    try {
  • applications/editors/josm/plugins/pdfimport/src/org/openstreetmap/josm/plugins/pdfimport/FilePlacement18.java

    r35817 r35976  
    2727
    2828import org.openstreetmap.josm.data.coor.EastNorth;
    29 import org.openstreetmap.josm.data.coor.LatLon;
     29import org.openstreetmap.josm.data.coor.ILatLon;
    3030import org.openstreetmap.josm.data.osm.Node;
    3131import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    307307            }
    308308
    309             LatLon ll = ((Node) selected.iterator().next()).getCoor();
     309            ILatLon ll = ((Node) selected.iterator().next());
    310310            return new EastNorth(ll.lon() * 1000, ll.lat() * 1000);
    311311        }
  • applications/editors/josm/plugins/poly/src/poly/PolyExporter.java

    r34991 r35976  
    102102
    103103        for (Node n : w.getNodes()) {
    104             writer.println(String.format(Locale.ENGLISH, "   %f   %f", n.getCoor().lon(), n.getCoor().lat()));
     104            writer.println(String.format(Locale.ENGLISH, "   %f   %f", n.lon(), n.lat()));
    105105        }
    106106        writer.println("END");
  • applications/editors/josm/plugins/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/RoutePatternAction.java

    r34718 r35976  
    18681868                    if ("backward".equals(itineraryData.getValueAt(i, 1))) {
    18691869                        for (int j = way.getNodesCount() - 2; j >= 0; --j) {
    1870                             SegmentMetric sm = new SegmentMetric(way.getNode(j + 1).getCoor().lat(),
    1871                                     way.getNode(j + 1).getCoor().lon(),
    1872                                     way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
     1870                            SegmentMetric sm = new SegmentMetric(way.getNode(j + 1).lat(),
     1871                                    way.getNode(j + 1).lon(),
     1872                                    way.getNode(j).lat(), way.getNode(j).lon(),
    18731873                                    distance);
    18741874                            segmentMetrics.add(sm);
     
    18771877                    } else {
    18781878                        for (int j = 0; j < way.getNodesCount() - 1; ++j) {
    1879                             SegmentMetric sm = new SegmentMetric(way.getNode(j).getCoor().lat(),
    1880                                     way.getNode(j).getCoor().lon(),
    1881                                     way.getNode(j + 1).getCoor().lat(),
    1882                                     way.getNode(j + 1).getCoor().lon(), distance);
     1879                            SegmentMetric sm = new SegmentMetric(way.getNode(j).lat(),
     1880                                    way.getNode(j).lon(),
     1881                                    way.getNode(j + 1).lat(),
     1882                                    way.getNode(j + 1).lon(), distance);
    18831883                            segmentMetrics.add(sm);
    18841884                            distance += sm.length;
     
    18941894    private StopReference detectMinDistance(Node node, Vector<SegmentMetric> segmentMetrics,
    18951895            boolean rhsPossible, boolean lhsPossible) {
    1896         if (node == null || node.getCoor() == null)
     1896        if (node == null || !node.isLatLonKnown())
    18971897            return null;
    18981898
     
    19001900        double position = -1.0;
    19011901        double distance = 180.0;
    1902         double lat = node.getCoor().lat();
    1903         double lon = node.getCoor().lon();
     1902        double lat = node.lat();
     1903        double lon = node.lon();
    19041904
    19051905        int curIndex = -2;
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java

    r35829 r35976  
    5252                return false;
    5353            for (Node n : way.getNodes()) {
    54                 LatLon ll = n.getCoor();
    55                 if (n.isIncomplete() || (a != null && !a.contains(ll.getX(), ll.getY())))
     54                if (n.isIncomplete() || (a != null && !a.contains(n.lon(), n.lat())))
    5655                    return false;
    5756            }
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r35846 r35976  
    499499        try {
    500500            for (Node n : nodes) {
    501                 if (!n.isDeleted() && n.getCoor() == null) {
     501                if (!n.isDeleted() && !n.isLatLonKnown()) {
    502502                    PrimitiveId id = n.getPrimitiveId();
    503503                    OsmPrimitive p = ds.getPrimitiveById(id);
  • applications/editors/josm/plugins/simplifyarea/src/org/openstreetmap/josm/plugins/simplifyarea/SimplifyAreaAction.java

    r35579 r35976  
    5656    private static boolean isInBounds(final Node node, final List<Bounds> bounds) {
    5757        for (final Bounds b : bounds) {
    58             if (b.contains(node.getCoor())) {
     58            if (b.contains(node)) {
    5959                return true;
    6060            }
  • applications/editors/josm/plugins/terracer/src/org/openstreetmap/josm/plugins/terracer/TerracerAction.java

    r35975 r35976  
    758758     */
    759759    private double calculateSideness(Node a, Node b, Node c, Node d) {
    760         final double ndx = b.getCoor().getX() - a.getCoor().getX();
    761         final double pdx = d.getCoor().getX() - c.getCoor().getX();
    762         final double ndy = b.getCoor().getY() - a.getCoor().getY();
    763         final double pdy = d.getCoor().getY() - c.getCoor().getY();
     760        final double ndx = b.lon() - a.lon();
     761        final double pdx = d.lon() - c.lon();
     762        final double ndy = b.lat() - a.lat();
     763        final double pdy = d.lat() - c.lat();
    764764
    765765        return (ndx * pdx + ndy * pdy)
     
    780780    private Node interpolateNode(Node a, Node b, double f) {
    781781        Node n = new Node(a.getEastNorth().interpolate(b.getEastNorth(), f));
    782         LatLon latLon = n.getCoor();
    783                 if (latLon.equalsEpsilon(a.getCoor(), ILatLon.MAX_SERVER_PRECISION))
     782                if (n.equalsEpsilon(a, ILatLon.MAX_SERVER_PRECISION))
    784783            return a;
    785         if (latLon.equalsEpsilon(b.getCoor(), ILatLon.MAX_SERVER_PRECISION))
     784        if (n.equalsEpsilon(b, ILatLon.MAX_SERVER_PRECISION))
    786785            return b;
    787786        return n;
  • applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/ConnectWays.java

    r35975 r35976  
    4949            LatLon ll = n.getCoor();
    5050            BBox bbox = new BBox(
    51                     ll.getX() - MIN_DISTANCE,
    52                     ll.getY() - MIN_DISTANCE,
    53                     ll.getX() + MIN_DISTANCE,
    54                     ll.getY() + MIN_DISTANCE);
     51                    n.lon() - MIN_DISTANCE,
     52                    n.lat() - MIN_DISTANCE,
     53                    n.lon() + MIN_DISTANCE,
     54                    n.lat() + MIN_DISTANCE);
    5555
    5656            // bude se node slucovat s jinym?
     
    129129        LatLon ll = node.getCoor();
    130130        BBox bbox = new BBox(
    131                 ll.getX() - MIN_DISTANCE_TW,
    132                 ll.getY() - MIN_DISTANCE_TW,
    133                 ll.getX() + MIN_DISTANCE_TW,
    134                 ll.getY() + MIN_DISTANCE_TW);
     131                node.lon() - MIN_DISTANCE_TW,
     132                node.lat() - MIN_DISTANCE_TW,
     133                node.lon() + MIN_DISTANCE_TW,
     134                node.lat() + MIN_DISTANCE_TW);
    135135
    136136        // node nebyl slouceny s jinym
     
    188188        while (i < way.getNodesCount()) {
    189189            // usecka n1, n2
    190             LatLon n1 = way.getNodes().get(i).getCoor();
    191             LatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount()).getCoor();
     190            Node n1 = way.getNodes().get(i);
     191            Node n2 = way.getNodes().get((i + 1) % way.getNodesCount());
    192192            System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount()));
    193193            double minDistanceSq = MIN_DISTANCE_SQ;
    194194            //double maxAngle = MAX_ANGLE;
    195195            List<Node> nodes = MainApplication.getLayerManager().getEditDataSet().searchNodes(new BBox(
    196                 Math.min(n1.getX(), n2.getX()) - minDistanceSq,
    197                 Math.min(n1.getY(), n2.getY()) - minDistanceSq,
    198                 Math.max(n1.getX(), n2.getX()) + minDistanceSq,
    199                 Math.max(n1.getY(), n2.getY()) + minDistanceSq
     196                Math.min(n1.lon(), n2.lon()) - minDistanceSq,
     197                Math.min(n1.lat(), n2.lat()) - minDistanceSq,
     198                Math.max(n1.lon(), n2.lon()) + minDistanceSq,
     199                Math.max(n1.lat(), n2.lat()) + minDistanceSq
    200200            ));
    201201            Node nearestNode = null;
     
    204204                    continue;
    205205                }
    206                 LatLon nn = nod.getCoor();
    207                 double dist = TracerGeometry.distanceFromSegment(nn, n1, n2);
    208                 double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2);
     206                double dist = TracerGeometry.distanceFromSegment(nod, n1, n2);
     207                double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2);
    209208                System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod);
    210                 if (!n1.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION)
    211                  && !n2.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
     209                if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION)
     210                 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
    212211                    //maxAngle = angle;
    213212                    nearestNode = nod;
  • applications/editors/josm/plugins/tracer/src/org/openstreetmap/josm/plugins/tracer/TracerGeometry.java

    r19881 r35976  
    77package org.openstreetmap.josm.plugins.tracer;
    88
    9 import org.openstreetmap.josm.data.coor.LatLon;
     9import org.openstreetmap.josm.data.coor.ILatLon;
    1010
    11 public class TracerGeometry {
     11public final class TracerGeometry {
     12    private TracerGeometry() {
     13        // Hide constructor
     14    }
    1215
    1316    /**
     
    1922     * @return Angle in degrees.
    2023     */
    21     static public double angleOfLines(LatLon a, LatLon b, LatLon c, LatLon d) {
     24    public static double angleOfLines(ILatLon a, ILatLon b, ILatLon c, ILatLon d) {
    2225        return (Math.abs(
    2326                    Math.atan2(a.lat() - b.lat(), a.lon() - b.lon()) -
     
    3336     * @return Distance.
    3437     */
    35     static public double distanceFromSegment(LatLon c, LatLon a, LatLon b) {
     38    public static double distanceFromSegment(ILatLon c, ILatLon a, ILatLon b) {
    3639        return distanceFromSegment(
    37                 c.getX(), c.getY(),
    38                 a.getX(), a.getY(),
    39                 b.getX(), b.getY()
     40                c.lon(), c.lat(),
     41                a.lon(), a.lat(),
     42                b.lon(), b.lat()
    4043        );
    4144    }
    4245
    43     static private double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) {
     46    private static double distanceFromSegment(double cx, double cy, double ax, double ay, double bx, double by) {
    4447        double r_numerator = (cx - ax) * (bx - ax) + (cy - ay) * (by - ay);
    4548        double r_denomenator = (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
  • applications/editors/josm/plugins/tracer2/src/org/openstreetmap/josm/plugins/tracer2/ConnectWays.java

    r35975 r35976  
    8282        }
    8383
    84         private static double calcAlpha(LatLon oP1, Node n) {
    85                 LatLon oP2 = n.getCoor();
    86 
    87                 double dAlpha = Math.atan((oP2.getY() - oP1.getY()) / (oP2.getX() - oP1.getX())) * 180 / Math.PI + (oP1.getX() > oP2.getX() ? 180 : 0);
     84        private static double calcAlpha(LatLon oP1, Node oP2) {
     85
     86                double dAlpha = Math.atan((oP2.lat() - oP1.lat()) / (oP2.lon() - oP1.lon())) * 180 / Math.PI + (oP1.lon() > oP2.lon() ? 180 : 0);
    8887                return checkAlpha(dAlpha);
    8988        }
     
    333332                //List<Command> cmds = new LinkedList<Command>();
    334333
    335                 LatLon ll = node.getCoor();
     334                //LatLon ll = node.getCoor();
    336335                //BBox bbox = new BBox(
    337336                //        ll.getX() - MIN_DISTANCE_TW,
     
    358357                        for (Pair<Node, Node> np : ww.getNodePairs(false)) {
    359358                                //double dist1 = TracerGeometry.distanceFromSegment(ll, np.a.getCoor(), np.b.getCoor());
    360                                 double dist = distanceFromSegment2(ll, np.a.getCoor(), np.b.getCoor());
     359                                double dist = distanceFromSegment2(node, np.a, np.b);
    361360                                //System.out.println(" distance: " + dist1 + "  " + dist);
    362361
     
    381380        }
    382381
    383         private static double distanceFromSegment2(LatLon c, LatLon a, LatLon b) {
     382        private static double distanceFromSegment2(ILatLon c, ILatLon a, ILatLon b) {
    384383                double x;
    385384                double y;
    386385
    387386                StraightLine oStraightLine1 = new StraightLine(
    388                                 new Point2D.Double(a.getX(), a.getY()),
    389                                 new Point2D.Double(b.getX(), b.getY()));
     387                                new Point2D.Double(a.lon(), a.lat()),
     388                                new Point2D.Double(b.lon(), b.lat()));
    390389                StraightLine oStraightLine2 = new StraightLine(
    391                                 new Point2D.Double(c.getX(), c.getY()),
    392                                 new Point2D.Double(c.getX() + (a.getY()-b.getY()), c.getY() - (a.getX()-b.getX())));
     390                                new Point2D.Double(c.lon(), c.lat()),
     391                                new Point2D.Double(c.lon() + (a.lat()-b.lat()), c.lat() - (a.lon()-b.lon())));
    393392                Point2D.Double oPoint = oStraightLine1.GetIntersectionPoint(oStraightLine2);
    394393
    395                 if ((oPoint.x > a.getX() && oPoint.x > b.getX()) || (oPoint.x < a.getX() && oPoint.x < b.getX()) ||
    396                                 (oPoint.y > a.getY() && oPoint.y > b.getY()) || (oPoint.y < a.getY() && oPoint.y < b.getY())) {
     394                if ((oPoint.x > a.lon() && oPoint.x > b.lon()) || (oPoint.x < a.lon() && oPoint.x < b.lon()) ||
     395                                (oPoint.y > a.lat() && oPoint.y > b.lat()) || (oPoint.y < a.lat() && oPoint.y < b.lat())) {
    397396                        return 100000;
    398397                }
    399398
    400                 x = c.getX()-oPoint.getX();
    401                 y = c.getY()-oPoint.getY();
     399                x = c.lon()-oPoint.getX();
     400                y = c.lat()-oPoint.getY();
    402401
    403402                return Math.sqrt((x*x)+(y*y));
     
    421420                while (i < way.getNodesCount()) {
    422421                        // usecka n1, n2
    423                         LatLon n1 = way.getNodes().get(i).getCoor();
    424                         LatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount()).getCoor();
     422                        ILatLon n1 = way.getNodes().get(i);
     423                        ILatLon n2 = way.getNodes().get((i + 1) % way.getNodesCount());
    425424                        System.out.println(way.getNodes().get(i) + "-----" + way.getNodes().get((i + 1) % way.getNodesCount()));
    426425                        double minDistanceSq = Double.MAX_VALUE;
     
    438437                                        continue;
    439438                                }
    440                                 LatLon nn = nod.getCoor();
    441                                 //double dist = TracerGeometry.distanceFromSegment(nn, n1, n2);
    442                                 double dist = distanceFromSegment2(nn, n1, n2);
    443                                 //                double angle = TracerGeometry.angleOfLines(n1, nn, nn, n2);
     439                                //double dist = TracerGeometry.distanceFromSegment(nod, n1, n2);
     440                                double dist = distanceFromSegment2(nod, n1, n2);
     441                                //                double angle = TracerGeometry.angleOfLines(n1, nod, nod, n2);
    444442                                //System.out.println("Angle: " + angle + " distance: " + dist + " Node: " + nod);
    445                                 if (!n1.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION)
    446                                  && !n2.equalsEpsilon(nn, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
     443                                if (!n1.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION)
     444                                 && !n2.equalsEpsilon(nod, ILatLon.MAX_SERVER_PRECISION) && dist < minDistanceSq) { // && Math.abs(angle) < maxAngle) {
    447445                                        minDistanceSq = dist;
    448446                                        //                    maxAngle = angle;
  • applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/data/TrustNode.java

    r33869 r35976  
    2525
    2626    public static String generateNodeSigtext(Node node) {
    27         LatLon point = node.getCoor();
    2827        String sigtext = node.getUniqueId() + "(";
    29         sigtext += DecimalDegreesCoordinateFormat.INSTANCE.latToString(point) + ",";
    30         sigtext += DecimalDegreesCoordinateFormat.INSTANCE.lonToString(point) + ")";
     28        sigtext += DecimalDegreesCoordinateFormat.INSTANCE.latToString(node) + ",";
     29        sigtext += DecimalDegreesCoordinateFormat.INSTANCE.lonToString(node) + ")";
    3130        return sigtext;
    3231    }
  • applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/GuiUtil.java

    r34566 r35976  
    134134
    135135    public static Point2D loc(Node node) {
    136         final EastNorth loc = ProjectionRegistry.getProjection().latlon2eastNorth(node.getCoor());
     136        final EastNorth loc = node.getEastNorth();
    137137        return new Point2D.Double(loc.getX(), -loc.getY());
    138138    }
  • applications/editors/josm/plugins/turnrestrictions/src/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilder.java

    r34976 r35976  
    6464        Node n1 = nodes.get(1);
    6565
    66         double x = n1.getCoor().getX() - n0.getCoor().getX();
    67         double y = n1.getCoor().getY() - n0.getCoor().getY();
     66        double x = n1.lon() - n0.lon();
     67        double y = n1.lat() - n0.lat();
    6868        return Math.atan2(y, x);
    6969    }
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java

    r35681 r35976  
    450450
    451451    static boolean isInArea(Node node, Area area) {
    452         LatLon ll = node.getCoor();
    453         return node.isNewOrUndeleted() || area == null || ll == null || area.contains(ll.getX(), ll.getY());
     452        return node.isNewOrUndeleted() || area == null || !node.isLatLonKnown() || area.contains(node.lon(), node.lat());
    454453    }
    455454
  • applications/editors/josm/plugins/waydownloader/src/org/openstreetmap/josm/plugins/waydownloader/WayDownloaderPlugin.java

    r34976 r35976  
    2222import org.openstreetmap.josm.data.DataSource;
    2323import org.openstreetmap.josm.data.UndoRedoHandler;
    24 import org.openstreetmap.josm.data.coor.LatLon;
     24import org.openstreetmap.josm.data.coor.ILatLon;
    2525import org.openstreetmap.josm.data.osm.DataSet;
    2626import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     
    111111            DownloadOsmTask downloadTask = new DownloadOsmTask();
    112112            final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor();
    113             LatLon ll = selectedNode.getCoor();
     113            ILatLon ll = selectedNode;
    114114            final Future<?> future = downloadTask.download(
    115115                    new DownloadParams(),
     
    308308        for (DataSource datasource : MainApplication.getLayerManager().getEditDataSet().getDataSources()) {
    309309            Bounds bounds = datasource.bounds;
    310             if (bounds != null && bounds.contains(node.getCoor())) return true;
     310            if (bounds != null && bounds.contains(node)) return true;
    311311        }
    312312        return false;
Note: See TracChangeset for help on using the changeset viewer.