Ignore:
Timestamp:
2022-06-14T20:11:21+02:00 (3 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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='")
Note: See TracChangeset for help on using the changeset viewer.