Changeset 3596 in josm for trunk/src/org


Ignore:
Timestamp:
2010-10-09T07:57:01+02:00 (14 years ago)
Author:
bastiK
Message:

applied #5531 (patch by Martin Ždila) - There should be way to merge nodes by averaging their position

File:
1 edited

Legend:

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

    r3530 r3596  
    2626import org.openstreetmap.josm.command.DeleteCommand;
    2727import org.openstreetmap.josm.command.SequenceCommand;
     28import org.openstreetmap.josm.data.coor.LatLon;
    2829import org.openstreetmap.josm.data.osm.Node;
    2930import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    8889     */
    8990    public static Node selectTargetLocationNode(LinkedHashSet<Node> candidates) {
    90         Node targetNode = null;
    91         for (Node n : candidates) { // pick last one
    92             targetNode = n;
    93         }
    94         return targetNode;
     91        if (! Main.pref.getBoolean("merge-nodes.average-location", false)) {
     92            Node targetNode = null;
     93            for (final Node n : candidates) { // pick last one
     94                targetNode = n;
     95            }
     96            return targetNode;
     97        }
     98
     99        double lat = 0, lon = 0;
     100        for (final Node n : candidates) {
     101            lat += n.getCoor().lat();
     102            lon += n.getCoor().lon();
     103        }
     104
     105        return new Node(new LatLon(lat / candidates.size(), lon / candidates.size()));
    95106    }
    96107
Note: See TracChangeset for help on using the changeset viewer.