Index: src/org/openstreetmap/josm/actions/AlignInCircleAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(revision 17386)
+++ src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(working copy)
@@ -29,6 +29,7 @@
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon;
 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay;
+import org.openstreetmap.josm.data.validation.tests.CrossingWays;
 import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay;
 import org.openstreetmap.josm.gui.Notification;
 import org.openstreetmap.josm.tools.Geometry;
@@ -42,6 +43,7 @@
  * @author Petr Dlouhý
  * @author Teemu Koskinen
  * @author Alain Delplanque
+ * @author Gerd Petermann
  *
  * @since 146
  */
@@ -146,7 +148,7 @@
      */
     public static Command buildCommand(DataSet ds) throws InvalidSelection {
         Collection<OsmPrimitive> sel = ds.getSelected();
-        List<Node> nodes = new LinkedList<>();
+        List<Node> selectedNodes = new LinkedList<>();
         // fixNodes: All nodes for which the angle relative to center should not be modified
         Set<Node> fixNodes = new HashSet<>();
         List<Way> ways = new LinkedList<>();
@@ -155,79 +157,81 @@
 
         for (OsmPrimitive osm : sel) {
             if (osm instanceof Node) {
-                nodes.add((Node) osm);
+                selectedNodes.add((Node) osm);
             } else if (osm instanceof Way) {
                 ways.add((Way) osm);
             }
         }
 
+        final List<Node> nodes;
         if (ways.size() == 1 && !ways.get(0).isClosed()) {
             // Case 1
             Way w = ways.get(0);
-            if (SelfIntersectingWay.isSelfIntersecting(w)) {
-                throw new InvalidSelection(tr("Self-intersecting way"));
-            }
-
             fixNodes.add(w.firstNode());
             fixNodes.add(w.lastNode());
-            fixNodes.addAll(nodes);
-            fixNodes.addAll(collectNodesWithExternReferrers(ways));
+            fixNodes.addAll(selectedNodes);
             // Temporary closed way used to reorder nodes
             Way closedWay = new Way(w);
-            closedWay.addNode(w.firstNode());
-            nodes = collectNodesAnticlockwise(Collections.singletonList(closedWay));
-            closedWay.setNodes(null); // see #19885
-        } else if (!ways.isEmpty() && checkWaysArePolygon(ways)) {
+            try {
+                closedWay.addNode(w.firstNode());
+                nodes = collectNodesAnticlockwise(Collections.singletonList(closedWay));
+            } finally {
+                closedWay.setNodes(null); // see #19885
+            }
+        } else if (Multipolygon.joinWays(ways).size() == 1) {
             // Case 2
+
+            // nodes on selected ways
             List<Node> inside = new ArrayList<>();
             List<Node> outside = new ArrayList<>();
 
-            for (Node n: nodes) {
-                boolean isInside = ways.stream().anyMatch(w -> w.getNodes().contains(n));
-                if (isInside)
+            for (Node n: selectedNodes) {
+                if (ways.stream().anyMatch(w -> w.containsNode(n)))
                     inside.add(n);
                 else
                     outside.add(n);
             }
+            if (outside.size() == 1) {
+                // center is given
+                center = outside.get(0).getEastNorth();
+                if (inside.size() == 1) {
+                    radius = center.distance(inside.get(0).getEastNorth());
+                }
+            } else if (outside.size() > 1) {
+                throw new InvalidSelection();
+            }
 
-            if (outside.size() == 1 && inside.isEmpty()) {
-                center = outside.get(0).getEastNorth();
-            } else if (outside.size() == 1 && inside.size() == 1) {
-                center = outside.get(0).getEastNorth();
-                radius = center.distance(inside.get(0).getEastNorth());
-            } else if (inside.size() == 2 && outside.isEmpty()) {
+            if (inside.size() == 2) {
                 // 2 nodes inside, define diameter
                 EastNorth en0 = inside.get(0).getEastNorth();
                 EastNorth en1 = inside.get(1).getEastNorth();
-                center = new EastNorth((en0.east() + en1.east()) / 2, (en0.north() + en1.north()) / 2);
                 radius = en0.distance(en1) / 2;
+                if (center == null) {
+                    center= en0.getCenter(en1);
+                }
             }
-
             fixNodes.addAll(inside);
-            fixNodes.addAll(collectNodesWithExternReferrers(ways));
             nodes = collectNodesAnticlockwise(ways);
-            if (nodes.size() < 4) {
-                throw new InvalidSelection(tr("Not enough nodes in selected ways."));
-            }
-        } else if (ways.isEmpty() && nodes.size() > 3) {
-            // Case 3
-            fixNodes.addAll(nodes);
-            // No need to reorder nodes since all are fix
         } else {
-            if (ways.isEmpty() && nodes.size() <= 3)
-                throw new InvalidSelection(tr("Please select at least four nodes."));
             throw new InvalidSelection();
         }
+        fixNodes.addAll(collectNodesWithExternReferrers(ways));
 
+        if (nodes.size() < 4) {
+            throw new InvalidSelection(tr("Not enough nodes in selected ways."));
+        }
         // Check if one or more nodes are outside of download area
         if (nodes.stream().anyMatch(Node::isOutsideDownloadArea))
             throw new InvalidSelection(tr("One or more nodes involved in this action is outside of the downloaded area."));
 
+
         if (center == null) {
-            // Compute the center of nodes
-            center = Geometry.getCenter(nodes);
+            if (validateGeometry(nodes)) {
+                // Compute the center of nodes
+                center = Geometry.getCenter(nodes);
+            }
             if (center == null) {
-                throw new InvalidSelection(tr("Cannot determine center of selected nodes."));
+                throw new InvalidSelection(tr("Cannot determine center of circle for this geometry."));
             }
         }
 
@@ -285,6 +289,22 @@
         return new SequenceCommand(tr("Align Nodes in Circle"), cmds);
     }
 
+    private static boolean validateGeometry(List<Node> nodes) {
+        Way test = new Way();
+        test.setNodes(nodes);
+        if (!test.isClosed()) {
+            test.addNode(test.firstNode());
+        }
+
+        try {
+            if (CrossingWays.isSelfCrossing(test))
+                return false;
+            return !SelfIntersectingWay.isSelfIntersecting(test);
+        } finally {
+            test.setNodes(null); // see #19855
+        }
+    }
+
     /**
      * Collect all nodes with more than one referrer.
      * @param ways Ways from witch nodes are selected
@@ -303,9 +323,9 @@
     private static List<Node> collectNodesAnticlockwise(List<Way> ways) throws InvalidSelection {
         Collection<JoinedWay> rings = Multipolygon.joinWays(ways);
         if (rings.size() != 1)
-            throw new InvalidSelection();
+            throw new InvalidSelection(); // we should never get here
         List<Node> nodes = new ArrayList<>(rings.iterator().next().getNodes());
-        if (nodes.get(0) != nodes.get(nodes.size()-1))
+        if (nodes.get(0) != nodes.get(nodes.size() - 1))
             throw new InvalidSelection();
         if (Geometry.isClockwise(nodes))
             Collections.reverse(nodes);
@@ -323,25 +343,4 @@
     protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
         updateEnabledStateOnModifiableSelection(selection);
     }
-
-    /**
-     * Determines if ways can be joined into a single polygon.
-     * @param ways The ways collection to check
-     * @return true if all ways can be joined into a single polygon
-     */
-    private static boolean checkWaysArePolygon(Collection<Way> ways) {
-        if (Multipolygon.joinWays(ways).size() != 1)
-            return false;
-        // For each way, nodes strictly between first and last should't be reference by an other way
-        for (Way way: ways) {
-            for (Node node: way.getNodes()) {
-                if (way.isFirstLastNode(node)) continue;
-                if (ways.stream().filter(wayOther -> way != wayOther).anyMatch(wayOther -> node.getReferrers().contains(wayOther))) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
 }
Index: src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
===================================================================
--- src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java	(revision 17386)
+++ src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java	(working copy)
@@ -26,6 +26,7 @@
 import org.openstreetmap.josm.data.validation.TestError;
 import org.openstreetmap.josm.data.validation.util.ValUtil;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.Logging;
 
 /**
@@ -468,4 +469,17 @@
         }
     }
 
+    /**
+     * Check if the given way is self crossing
+     * @param way the way to check
+     * @return {@code true} if one or more segments of the way are crossing
+     * @see SelfIntersectingWay
+     * @since xxx
+     */
+    public static boolean isSelfCrossing(Way way) {
+        CheckParameterUtil.ensureParameterNotNull(way, "way");
+        SelfCrossing test = new SelfCrossing();
+        test.visit(way);
+        return !test.getErrors().isEmpty();
+    }
 }
Index: test/data/alignCircleCases.osm
===================================================================
--- test/data/alignCircleCases.osm	(nonexistent)
+++ test/data/alignCircleCases.osm	(working copy)
@@ -0,0 +1,956 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' upload='never' generator='JOSM'>
+  <node id='-102878' action='modify' lat='37.55691419926' lon='14.46148123867' />
+  <node id='-102879' action='modify' lat='37.55684485074' lon='14.46155150259' />
+  <node id='-102880' action='modify' lat='37.55687312689' lon='14.46152268691'>
+    <tag k='sel' v='1' />
+  </node>
+  <node id='-102881' action='modify' lat='37.55686036859' lon='14.4615670012' />
+  <node id='-102882' action='modify' lat='37.5568796806' lon='14.46157247181' />
+  <node id='-102883' action='modify' lat='37.55689896179' lon='14.46156683088' />
+  <node id='-102884' action='modify' lat='37.55691439329' lon='14.46155119569' />
+  <node id='-102885' action='modify' lat='37.55692291869' lon='14.46152866297' />
+  <node id='-102886' action='modify' lat='37.55692284944' lon='14.4615036956' />
+  <node id='-102887' action='modify' lat='37.55689868142' lon='14.46146574006' />
+  <node id='-102888' action='modify' lat='37.55687936941' lon='14.46146026946' />
+  <node id='-102889' action='modify' lat='37.55686008821' lon='14.46146591038' />
+  <node id='-102890' action='modify' lat='37.55684465671' lon='14.46148154557' />
+  <node id='-102891' action='modify' lat='37.5568361313' lon='14.4615040783' />
+  <node id='-102892' action='modify' lat='37.55683620055' lon='14.46152904567' />
+  <node id='-102893' action='modify' lat='37.55691716886' lon='14.46163544625'>
+    <tag k='sel' v='2' />
+  </node>
+  <node id='-102894' action='modify' lat='37.55684048956' lon='14.4617253193' />
+  <node id='-102895' action='modify' lat='37.55685600743' lon='14.46174081791' />
+  <node id='-102896' action='modify' lat='37.55687531944' lon='14.46174628852' />
+  <node id='-102897' action='modify' lat='37.55689460063' lon='14.46174064759' />
+  <node id='-102898' action='modify' lat='37.55691003212' lon='14.4617250124' />
+  <node id='-102899' action='modify' lat='37.55691855752' lon='14.46170247968' />
+  <node id='-102900' action='modify' lat='37.55691848827' lon='14.46167751231' />
+  <node id='-102901' action='modify' lat='37.5569098381' lon='14.46165505538' />
+  <node id='-102902' action='modify' lat='37.55689432026' lon='14.46163955677' />
+  <node id='-102903' action='modify' lat='37.55687500825' lon='14.46163408617' />
+  <node id='-102904' action='modify' lat='37.55685572705' lon='14.46163972709' />
+  <node id='-102905' action='modify' lat='37.55684029554' lon='14.46165536228' />
+  <node id='-102906' action='modify' lat='37.55683177013' lon='14.46167789501' />
+  <node id='-102907' action='modify' lat='37.55683183938' lon='14.46170286238' />
+  <node id='-102908' action='modify' lat='37.55674469778' lon='14.46135781442'>
+    <tag k='sel' v='3' />
+  </node>
+  <node id='-102909' action='modify' lat='37.55671642158' lon='14.4613866301' />
+  <node id='-102910' action='modify' lat='37.55673193945' lon='14.46140212871' />
+  <node id='-102911' action='modify' lat='37.5567512515' lon='14.46140759931' />
+  <node id='-102912' action='modify' lat='37.55677053272' lon='14.46140195839' />
+  <node id='-102913' action='modify' lat='37.55678596424' lon='14.4613863232' />
+  <node id='-102914' action='modify' lat='37.55679448966' lon='14.46136379047'>
+    <tag k='sel' v='3' />
+  </node>
+  <node id='-102915' action='modify' lat='37.55679442042' lon='14.4613388231' />
+  <node id='-102916' action='modify' lat='37.55678577022' lon='14.46131636618' />
+  <node id='-102917' action='modify' lat='37.55677025235' lon='14.46130086757' />
+  <node id='-102918' action='modify' lat='37.55675094031' lon='14.46129539696' />
+  <node id='-102919' action='modify' lat='37.55673165908' lon='14.46130103789' />
+  <node id='-102920' action='modify' lat='37.55671622756' lon='14.46131667308' />
+  <node id='-102921' action='modify' lat='37.55670770212' lon='14.4613392058' />
+  <node id='-102922' action='modify' lat='37.55670777137' lon='14.46136417318' />
+  <node id='-102923' action='modify' lat='37.55653956697' lon='14.46209010402' />
+  <node id='-102924' action='modify' lat='37.55658630124' lon='14.46210554382' />
+  <node id='-102925' action='modify' lat='37.55665195171' lon='14.46208519136' />
+  <node id='-102926' action='modify' lat='37.55675376546' lon='14.46201079963' />
+  <node id='-102927' action='modify' lat='37.55655681414' lon='14.46216660118' />
+  <node id='-102928' action='modify' lat='37.55660354841' lon='14.46218204098' />
+  <node id='-102929' action='modify' lat='37.55666919885' lon='14.46216168852' />
+  <node id='-102930' action='modify' lat='37.55671148217' lon='14.4621280017' />
+  <node id='-102931' action='modify' lat='37.55677101258' lon='14.46208729679' />
+  <node id='-102932' action='modify' lat='37.55683731449' lon='14.46239008267' />
+  <node id='-102933' action='modify' lat='37.5566402416' lon='14.46279572753' />
+  <node id='-102934' action='modify' lat='37.55671231689' lon='14.46237870724' />
+  <node id='-102935' action='modify' lat='37.55671347821' lon='14.46241863738' />
+  <node id='-102936' action='modify' lat='37.55671081506' lon='14.46245223115' />
+  <node id='-102937' action='modify' lat='37.55668951053' lon='14.46251269911' />
+  <node id='-102938' action='modify' lat='37.55666953692' lon='14.46255133196' />
+  <node id='-102939' action='modify' lat='37.55663624754' lon='14.46258492574' />
+  <node id='-102940' action='modify' lat='37.5565822772' lon='14.46260879036' />
+  <node id='-102941' action='modify' lat='37.5568586203' lon='14.46265715236' />
+  <node id='-102942' action='modify' lat='37.55657189412' lon='14.46236592807' />
+  <node id='-102943' action='modify' lat='37.55644583135' lon='14.46235648889' />
+  <node id='-102944' action='modify' lat='37.55644733048' lon='14.46237908049' />
+  <node id='-102945' action='modify' lat='37.55645381458' lon='14.4624002242' />
+  <node id='-102946' action='modify' lat='37.55646475836' lon='14.4624182071' />
+  <node id='-102947' action='modify' lat='37.55647927522' lon='14.4624315723' />
+  <node id='-102948' action='modify' lat='37.55649618907' lon='14.46243923705' />
+  <node id='-102949' action='modify' lat='37.55651412967' lon='14.46244058038' />
+  <node id='-102950' action='modify' lat='37.55652895376' lon='14.46243682061' />
+  <node id='-102951' action='modify' lat='37.55654731191' lon='14.46242438845' />
+  <node id='-102952' action='modify' lat='37.55656092621' lon='14.46240612819' />
+  <node id='-102953' action='modify' lat='37.55656828681' lon='14.46238813732' />
+  <node id='-102954' action='modify' lat='37.556570395' lon='14.46234333647' />
+  <node id='-102955' action='modify' lat='37.55656391091' lon='14.46232219276' />
+  <node id='-102956' action='modify' lat='37.55655296714' lon='14.46230420986' />
+  <node id='-102957' action='modify' lat='37.5565384503' lon='14.46229084466' />
+  <node id='-102958' action='modify' lat='37.55652153645' lon='14.46228317991' />
+  <node id='-102959' action='modify' lat='37.55650359584' lon='14.46228183658' />
+  <node id='-102960' action='modify' lat='37.55648608194' lon='14.46228692348' />
+  <node id='-102961' action='modify' lat='37.55647041359' lon='14.46229802851' />
+  <node id='-102962' action='modify' lat='37.55645786016' lon='14.46231425201' />
+  <node id='-102963' action='modify' lat='37.55644943867' lon='14.46233427964' />
+  <node id='-102964' action='modify' lat='37.55677883754' lon='14.46238476096' />
+  <node id='-102965' action='modify' lat='37.55678338581' lon='14.46246734835' />
+  <node id='-102966' action='modify' lat='37.55675262917' lon='14.46256661489' />
+  <node id='-102967' action='modify' lat='37.55671281242' lon='14.46262355942' />
+  <node id='-102968' action='modify' lat='37.55667952306' lon='14.46265211413' />
+  <node id='-102969' action='modify' lat='37.55664894294' lon='14.46267308698'>
+    <tag k='highway' v='turning_circle' />
+  </node>
+  <node id='-102970' action='modify' lat='37.5566230771' lon='14.46274037141' />
+  <node id='-102971' action='modify' lat='37.55644192824' lon='14.46154801513' />
+  <node id='-102972' action='modify' lat='37.55635456852' lon='14.46128700605' />
+  <node id='-102973' action='modify' lat='37.55646581605' lon='14.46148487984' />
+  <node id='-102974' action='modify' lat='37.55648104734' lon='14.46176525798' />
+  <node id='-102975' action='modify' lat='37.55637416104' lon='14.46139356747' />
+  <node id='-102976' action='modify' lat='37.55648073615' lon='14.46165305563' />
+  <node id='-102977' action='modify' lat='37.5565285776' lon='14.46152266506' />
+  <node id='-102978' action='modify' lat='37.55633528719' lon='14.46129264697' />
+  <node id='-102979' action='modify' lat='37.55643749781' lon='14.46169686447' />
+  <node id='-102980' action='modify' lat='37.55631139935' lon='14.46135578226' />
+  <node id='-102981' action='modify' lat='37.55650032863' lon='14.46175961706' />
+  <node id='-102982' action='modify' lat='37.55650468982' lon='14.46158580035' />
+  <node id='-102983' action='modify' lat='37.55647885479' lon='14.46154165637'>
+    <tag k='sel' v='11' />
+  </node>
+  <node id='-102984' action='modify' lat='37.55638959263' lon='14.46137793228' />
+  <node id='-102985' action='modify' lat='37.55652421641' lon='14.46169648177' />
+  <node id='-102986' action='modify' lat='37.55638939861' lon='14.46130797526' />
+  <node id='-102987' action='modify' lat='37.55644621729' lon='14.46174428876' />
+  <node id='-102988' action='modify' lat='37.556441859' lon='14.46152304776' />
+  <node id='-102989' action='modify' lat='37.55643756705' lon='14.46172183184' />
+  <node id='-102990' action='modify' lat='37.55648509734' lon='14.46147923892' />
+  <node id='-102991' action='modify' lat='37.55633556756' lon='14.46139373779' />
+  <node id='-102992' action='modify' lat='37.55652864684' lon='14.46154763243' />
+  <node id='-102993' action='modify' lat='37.55651556618' lon='14.46167402484' />
+  <node id='-102994' action='modify' lat='37.55637388066' lon='14.46129247665' />
+  <node id='-102995' action='modify' lat='37.55646173522' lon='14.46175978737' />
+  <node id='-102996' action='modify' lat='37.55651992737' lon='14.46150020813' />
+  <node id='-102997' action='modify' lat='37.55646145485' lon='14.46165869655' />
+  <node id='-102998' action='modify' lat='37.55631985558' lon='14.46130828216' />
+  <node id='-102999' action='modify' lat='37.55648540853' lon='14.46159144127' />
+  <node id='-103000' action='modify' lat='37.55635487971' lon='14.4613992084' />
+  <node id='-103001' action='modify' lat='37.55651576021' lon='14.46174398186' />
+  <node id='-103002' action='modify' lat='37.5563981181' lon='14.46135539956'>
+    <tag k='sel' v='13' />
+  </node>
+  <node id='-103003' action='modify' lat='37.55634832596' lon='14.4613494235'>
+    <tag k='sel' v='13' />
+  </node>
+  <node id='-103004' action='modify' lat='37.55645057848' lon='14.46157047206' />
+  <node id='-103005' action='modify' lat='37.55645038446' lon='14.46150051503' />
+  <node id='-103006' action='modify' lat='37.55644602327' lon='14.46167433174' />
+  <node id='-103007' action='modify' lat='37.55650440945' lon='14.46148470952' />
+  <node id='-103008' action='modify' lat='37.5563113301' lon='14.46133081489' />
+  <node id='-103009' action='modify' lat='37.55652428566' lon='14.46172144914' />
+  <node id='-103010' action='modify' lat='37.55652012139' lon='14.46157016515' />
+  <node id='-103011' action='modify' lat='37.55639804885' lon='14.46133043219' />
+  <node id='-103012' action='modify' lat='37.55650004826' lon='14.46165852623' />
+  <node id='-103013' action='modify' lat='37.55652289699' lon='14.46165441572'>
+    <tag k='sel' v='12' />
+  </node>
+  <node id='-103014' action='modify' lat='37.55646609642' lon='14.46158597066' />
+  <node id='-103015' action='modify' lat='37.5563200496' lon='14.46137823918' />
+  <node id='-103016' action='modify' lat='37.5558815644' lon='14.46196208882' />
+  <node id='-103017' action='modify' lat='37.55599395013' lon='14.46195717616' />
+  <node id='-103018' action='modify' lat='37.55609576478' lon='14.46188278442' />
+  <node id='-103019' action='modify' lat='37.55601820525' lon='14.46153058085' />
+  <node id='-103021' action='modify' lat='37.55603372327' lon='14.46154607946' />
+  <node id='-103022' action='modify' lat='37.55601801123' lon='14.46146062383' />
+  <node id='-103023' action='modify' lat='37.5560530355' lon='14.46155155006' />
+  <node id='-103024' action='modify' lat='37.55608755454' lon='14.46146031692' />
+  <node id='-103025' action='modify' lat='37.55605272431' lon='14.46143934771' />
+  <node id='-103026' action='modify' lat='37.5560723169' lon='14.46154590914' />
+  <node id='-103027' action='modify' lat='37.5560334429' lon='14.46144498863' />
+  <node id='-103028' action='modify' lat='37.55609620482' lon='14.46148277385' />
+  <node id='-103029' action='modify' lat='37.55600955497' lon='14.46150812392' />
+  <node id='-103030' action='modify' lat='37.55607203653' lon='14.46144481831' />
+  <node id='-103032' action='modify' lat='37.55600948572' lon='14.46148315655' />
+  <node id='-103076' action='modify' lat='37.5568426502' lon='14.46139296031' />
+  <node id='-103077' action='modify' lat='37.55685816805' lon='14.46140845892' />
+  <node id='-103078' action='modify' lat='37.55687748006' lon='14.46141392953' />
+  <node id='-103079' action='modify' lat='37.55689676126' lon='14.4614082886' />
+  <node id='-103080' action='modify' lat='37.55691219275' lon='14.46139265341' />
+  <node id='-103081' action='modify' lat='37.55692071815' lon='14.46137012069' />
+  <node id='-103082' action='modify' lat='37.55691474499' lon='14.46134763579' />
+  <node id='-103083' action='modify' lat='37.55691199872' lon='14.46132269639' />
+  <node id='-103084' action='modify' lat='37.55689648089' lon='14.46130719778' />
+  <node id='-103085' action='modify' lat='37.55687716887' lon='14.46130172718' />
+  <node id='-103086' action='modify' lat='37.55685788768' lon='14.4613073681' />
+  <node id='-103087' action='modify' lat='37.55684245617' lon='14.46132300329' />
+  <node id='-103088' action='modify' lat='37.55683393076' lon='14.46134553602' />
+  <node id='-103089' action='modify' lat='37.55683400001' lon='14.46137050339' />
+  <node id='-103119' action='modify' lat='37.55587222611' lon='14.46211553776' />
+  <node id='-103120' action='modify' lat='37.555954882' lon='14.46205099363' />
+  <node id='-103121' action='modify' lat='37.55604737777' lon='14.46209319556' />
+  <node id='-103122' action='modify' lat='37.55611035355' lon='14.4620013443' />
+  <node id='-103130' action='modify' lat='37.55611232154' lon='14.46220242409' />
+  <node id='-103131' action='modify' lat='37.55591158607' lon='14.46251769735' />
+  <node id='-103132' action='modify' lat='37.55589190609' lon='14.46220490656' />
+  <node id='-103133' action='modify' lat='37.55613987343' lon='14.46239853895' />
+  <node id='-103138' action='modify' lat='37.55613003347' lon='14.46261327231' />
+  <node id='-103139' action='modify' lat='37.55592929804' lon='14.46292854557' />
+  <node id='-103140' action='modify' lat='37.55590961807' lon='14.46261575478' />
+  <node id='-103141' action='modify' lat='37.55615758535' lon='14.46280938717' />
+  <node id='-103150' action='modify' lat='37.55605578204' lon='14.46272989105' />
+  <node id='-103156' action='modify' lat='37.55582893013' lon='14.46268029891' />
+  <node id='-103157' action='modify' lat='37.55575467839' lon='14.46279691764' />
+  <node id='-103158' action='modify' lat='37.55562819389' lon='14.46299557217' />
+  <node id='-103159' action='modify' lat='37.55560851384' lon='14.46268278138' />
+  <node id='-103160' action='modify' lat='37.55585648212' lon='14.46287641377' />
+  <node id='-103187' action='modify' lat='37.55578760212' lon='14.46224090232' />
+  <node id='-103188' action='modify' lat='37.55558686577' lon='14.46255617558' />
+  <node id='-103189' action='modify' lat='37.55556718571' lon='14.46224338479' />
+  <node id='-103190' action='modify' lat='37.55581515413' lon='14.46243701719' />
+  <node id='-103243' action='modify' lat='37.55644611869' lon='14.46138381242' />
+  <node id='-103244' action='modify' lat='37.55646163663' lon='14.46139931103' />
+  <node id='-103245' action='modify' lat='37.55648094875' lon='14.46140478164' />
+  <node id='-103246' action='modify' lat='37.55650023004' lon='14.46139914071' />
+  <node id='-103247' action='modify' lat='37.55651566162' lon='14.46138350552' />
+  <node id='-103248' action='modify' lat='37.55652418706' lon='14.4613609728' />
+  <node id='-103249' action='modify' lat='37.55651821387' lon='14.46133848789' />
+  <node id='-103250' action='modify' lat='37.55651546759' lon='14.4613135485' />
+  <node id='-103251' action='modify' lat='37.55649994967' lon='14.46129804989' />
+  <node id='-103252' action='modify' lat='37.55648063755' lon='14.46129257929' />
+  <node id='-103253' action='modify' lat='37.55646135625' lon='14.46129822021' />
+  <node id='-103254' action='modify' lat='37.55644592466' lon='14.4613138554' />
+  <node id='-103255' action='modify' lat='37.55643739921' lon='14.46133638813' />
+  <node id='-103256' action='modify' lat='37.55643746846' lon='14.4613613555' />
+  <node id='-103272' action='modify' lat='37.556716745' lon='14.46156434474' />
+  <node id='-103273' action='modify' lat='37.55673226287' lon='14.46157984335' />
+  <node id='-103274' action='modify' lat='37.55675157492' lon='14.46158531395' />
+  <node id='-103275' action='modify' lat='37.55677085614' lon='14.46157967303' />
+  <node id='-103276' action='modify' lat='37.55678628766' lon='14.46156403784' />
+  <node id='-103277' action='modify' lat='37.55679481308' lon='14.46154150511'>
+    <tag k='sel' v='4' />
+  </node>
+  <node id='-103278' action='modify' lat='37.55679474384' lon='14.46151653774' />
+  <node id='-103279' action='modify' lat='37.55678012633' lon='14.46150160818' />
+  <node id='-103280' action='modify' lat='37.55677057577' lon='14.46147858221' />
+  <node id='-103281' action='modify' lat='37.55675126373' lon='14.4614731116' />
+  <node id='-103282' action='modify' lat='37.5567319825' lon='14.46147875253' />
+  <node id='-103283' action='modify' lat='37.55671655098' lon='14.46149438772' />
+  <node id='-103284' action='modify' lat='37.55670802555' lon='14.46151692044'>
+    <tag k='sel' v='4' />
+  </node>
+  <node id='-103285' action='modify' lat='37.5567080948' lon='14.46154188782' />
+  <node id='-103349' action='modify' lat='37.55640207453' lon='14.46151110796' />
+  <node id='-103350' action='modify' lat='37.5563867939' lon='14.46149617839' />
+  <node id='-103351' action='modify' lat='37.55637790634' lon='14.46147315242' />
+  <node id='-103352' action='modify' lat='37.55635859419' lon='14.46146768182' />
+  <node id='-103353' action='modify' lat='37.55633931287' lon='14.46147332274' />
+  <node id='-103354' action='modify' lat='37.55632388126' lon='14.46148895793' />
+  <node id='-103355' action='modify' lat='37.55631535579' lon='14.46151149066'>
+    <tag k='sel' v='14' />
+  </node>
+  <node id='-103356' action='modify' lat='37.55637818671' lon='14.46157424325' />
+  <node id='-103357' action='modify' lat='37.55639361831' lon='14.46155860805' />
+  <node id='-103358' action='modify' lat='37.55640214377' lon='14.46153607533'>
+    <tag k='sel' v='14' />
+  </node>
+  <node id='-103359' action='modify' lat='37.55631542503' lon='14.46153645803' />
+  <node id='-103360' action='modify' lat='37.55632407528' lon='14.46155891496' />
+  <node id='-103361' action='modify' lat='37.55633959324' lon='14.46157441356' />
+  <node id='-103362' action='modify' lat='37.55635890538' lon='14.46157988417' />
+  <node id='-103378' action='modify' lat='37.55605448327' lon='14.4613042381'>
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='20' />
+  </node>
+  <node id='-103409' action='modify' lat='37.5558489401' lon='14.46128918337' />
+  <node id='-103410' action='modify' lat='37.55584363576' lon='14.46140293022' />
+  <node id='-103411' action='modify' lat='37.55578130964' lon='14.4614129667' />
+  <node id='-103412' action='modify' lat='37.55577335312' lon='14.46129420161' />
+  <node id='-103497' action='modify' lat='37.55571746794' lon='14.46144177661' />
+  <node id='-103498' action='modify' lat='37.5555167314' lon='14.46175704987' />
+  <node id='-103499' action='modify' lat='37.55549705132' lon='14.46144425908' />
+  <node id='-103500' action='modify' lat='37.55574501997' lon='14.46163789148' />
+  <node id='-103501' action='modify' lat='37.55575879599' lon='14.4618811732' />
+  <node id='-103502' action='modify' lat='37.55568454418' lon='14.46199779193' />
+  <node id='-103503' action='modify' lat='37.55555805956' lon='14.46219644646' />
+  <node id='-103504' action='modify' lat='37.55553837949' lon='14.46188365567' />
+  <node id='-103505' action='modify' lat='37.555786348' lon='14.46207728806' />
+  <node id='-103638' action='modify' lat='37.55675310861' lon='14.46175472442' />
+  <node id='-103639' action='modify' lat='37.55671827868' lon='14.46173375521' />
+  <node id='-103640' action='modify' lat='37.55673379656' lon='14.46174925382' />
+  <node id='-103641' action='modify' lat='37.55678782135' lon='14.46173344831' />
+  <node id='-103642' action='modify' lat='37.55677238983' lon='14.4617490835' />
+  <node id='-103643' action='modify' lat='37.55670962848' lon='14.46171129829' />
+  <node id='-103644' action='modify' lat='37.55679627752' lon='14.46168594821'>
+    <tag k='sel' v='5' />
+  </node>
+  <node id='-103645' action='modify' lat='37.55673351619' lon='14.461648163' />
+  <node id='-103646' action='modify' lat='37.55679634676' lon='14.46171091558'>
+    <tag k='sel' v='5' />
+  </node>
+  <node id='-103647' action='modify' lat='37.55675279742' lon='14.46164252207' />
+  <node id='-103648' action='modify' lat='37.55677210946' lon='14.46164799268'>
+    <tag k='sel' v='5' />
+  </node>
+  <node id='-103649' action='modify' lat='37.55670955923' lon='14.46168633091'>
+    <tag k='sel' v='5' />
+  </node>
+  <node id='-103650' action='modify' lat='37.55678166001' lon='14.46167101866' />
+  <node id='-103651' action='modify' lat='37.55671808466' lon='14.46166379819' />
+  <node id='-103724' action='modify' lat='37.55635782999' lon='14.46164914107' />
+  <node id='-103725' action='modify' lat='37.55632311706' lon='14.46167041719' />
+  <node id='-103726' action='modify' lat='37.55637742251' lon='14.4617557025' />
+  <node id='-103727' action='modify' lat='37.55633882903' lon='14.46175587282' />
+  <node id='-103728' action='modify' lat='37.55639285411' lon='14.46174006731' />
+  <node id='-103729' action='modify' lat='37.55632331108' lon='14.46174037421' />
+  <node id='-103730' action='modify' lat='37.55640131033' lon='14.46169256721'>
+    <tag k='sel' v='15' />
+  </node>
+  <node id='-103731' action='modify' lat='37.55631466083' lon='14.46171791729' />
+  <node id='-103732' action='modify' lat='37.55640137957' lon='14.46171753458'>
+    <tag k='sel' v='15' />
+  </node>
+  <node id='-103733' action='modify' lat='37.55638669274' lon='14.46167763766' />
+  <node id='-103734' action='modify' lat='37.55633854866' lon='14.461654782' />
+  <node id='-103735' action='modify' lat='37.55631459158' lon='14.46169294991'>
+    <tag k='sel' v='15' />
+  </node>
+  <node id='-103736' action='modify' lat='37.55637714213' lon='14.46165461168'>
+    <tag k='sel' v='15' />
+  </node>
+  <node id='-103737' action='modify' lat='37.55635814118' lon='14.46176134342' />
+  <node id='-103819' action='modify' lat='37.55660656928' lon='14.46128015712' />
+  <node id='-103820' action='modify' lat='37.55657229559' lon='14.46130125895' />
+  <node id='-103821' action='modify' lat='37.55662591633' lon='14.4613853016' />
+  <node id='-103822' action='modify' lat='37.55658790494' lon='14.4613854776' />
+  <node id='-103823' action='modify' lat='37.55664112636' lon='14.4613699233' />
+  <node id='-103824' action='modify' lat='37.55657260581' lon='14.46137024057' />
+  <node id='-103825' action='modify' lat='37.55664952202' lon='14.46132307658' />
+  <node id='-103826' action='modify' lat='37.5565640487' lon='14.4613481477' />
+  <node id='-103827' action='modify' lat='37.55665273282' lon='14.46135042447'>
+    <tag k='sel' v='7' />
+  </node>
+  <node id='-103828' action='modify' lat='37.55664099118' lon='14.46130087148' />
+  <node id='-103829' action='modify' lat='37.55658751983' lon='14.46128576501' />
+  <node id='-103830' action='modify' lat='37.55655624194' lon='14.46133124339'>
+    <tag k='sel' v='7' />
+  </node>
+  <node id='-103831' action='modify' lat='37.55662565772' lon='14.46128554989' />
+  <node id='-103832' action='modify' lat='37.55660692653' lon='14.46139085149' />
+  <node id='-103856' action='modify' lat='37.55660676548' lon='14.46133550421'>
+    <tag k='sel' v='7' />
+  </node>
+  <node id='-103930' action='modify' lat='37.55590697927' lon='14.46138712673' />
+  <node id='-103931' action='modify' lat='37.55597507195' lon='14.46131728109' />
+  <node id='-103932' action='modify' lat='37.55597559287' lon='14.46138630275' />
+  <node id='-103933' action='modify' lat='37.55598389844' lon='14.46136400694' />
+  <node id='-103934' action='modify' lat='37.55590645835' lon='14.46131810506' />
+  <node id='-103935' action='modify' lat='37.55589815277' lon='14.46134040087' />
+  <node id='-103936' action='modify' lat='37.55594060788' lon='14.46129685283' />
+  <node id='-103937' action='modify' lat='37.5559216104' lon='14.46130256294' />
+  <node id='-103938' action='modify' lat='37.55594144336' lon='14.46140755499' />
+  <node id='-103939' action='modify' lat='37.55595968808' lon='14.46130210567' />
+  <node id='-103940' action='modify' lat='37.55592236315' lon='14.46140230214' />
+  <node id='-103941' action='modify' lat='37.55589833868' lon='14.46136503442' />
+  <node id='-103942' action='modify' lat='37.5559282237' lon='14.46134925932'>
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='28' />
+  </node>
+  <node id='-103943' action='modify' lat='37.55596044083' lon='14.46140184487' />
+  <node id='-103944' action='modify' lat='37.55598371253' lon='14.46133937339' />
+  <node id='-103949' action='modify' lat='37.55595147095' lon='14.46137426998'>
+    <tag k='sel' v='28' />
+  </node>
+  <node id='-104045' action='modify' lat='37.55599573207' lon='14.46172257931' />
+  <node id='-104046' action='modify' lat='37.55601125009' lon='14.46173807792' />
+  <node id='-104047' action='modify' lat='37.55603056233' lon='14.46174354852' />
+  <node id='-104048' action='modify' lat='37.55604984374' lon='14.4617379076' />
+  <node id='-104049' action='modify' lat='37.55606527541' lon='14.46172227241' />
+  <node id='-104050' action='modify' lat='37.5560738009' lon='14.46169973968' />
+  <node id='-104051' action='modify' lat='37.55607373166' lon='14.46167477231' />
+  <node id='-104052' action='modify' lat='37.55605911401' lon='14.46165984275' />
+  <node id='-104053' action='modify' lat='37.55604956336' lon='14.46163681678' />
+  <node id='-104054' action='modify' lat='37.55603025114' lon='14.46163134617' />
+  <node id='-104055' action='modify' lat='37.55601096972' lon='14.4616369871' />
+  <node id='-104056' action='modify' lat='37.55599553805' lon='14.46165262229' />
+  <node id='-104057' action='modify' lat='37.55598701253' lon='14.46167515501' />
+  <node id='-104058' action='modify' lat='37.55598708178' lon='14.46170012239' />
+  <node id='-104059' action='modify' lat='37.55601928253' lon='14.46166005296' />
+  <node id='-104060' action='modify' lat='37.55605106444' lon='14.46168343898' />
+  <node id='-104061' action='modify' lat='37.55603305469' lon='14.46171551124' />
+  <node id='-104062' action='modify' lat='37.55601398554' lon='14.46171751576' />
+  <way id='-102697' action='modify'>
+    <nd ref='-102879' />
+    <nd ref='-102881' />
+    <nd ref='-102882' />
+    <nd ref='-102883' />
+    <nd ref='-102884' />
+    <nd ref='-102885' />
+    <nd ref='-102886' />
+    <nd ref='-102878' />
+    <nd ref='-102887' />
+    <nd ref='-102888' />
+    <nd ref='-102889' />
+    <nd ref='-102890' />
+    <nd ref='-102891' />
+    <nd ref='-102892' />
+    <nd ref='-102879' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='1' />
+  </way>
+  <way id='-102698' action='modify'>
+    <nd ref='-102894' />
+    <nd ref='-102895' />
+    <nd ref='-102896' />
+    <nd ref='-102897' />
+    <nd ref='-102898' />
+    <nd ref='-102899' />
+    <nd ref='-102900' />
+    <nd ref='-102901' />
+    <nd ref='-102902' />
+    <nd ref='-102903' />
+    <nd ref='-102904' />
+    <nd ref='-102905' />
+    <nd ref='-102906' />
+    <nd ref='-102907' />
+    <nd ref='-102894' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='2' />
+  </way>
+  <way id='-102699' action='modify'>
+    <nd ref='-102909' />
+    <nd ref='-102910' />
+    <nd ref='-102911' />
+    <nd ref='-102912' />
+    <nd ref='-102913' />
+    <nd ref='-102914' />
+    <nd ref='-102915' />
+    <nd ref='-102916' />
+    <nd ref='-102917' />
+    <nd ref='-102918' />
+    <nd ref='-102919' />
+    <nd ref='-102920' />
+    <nd ref='-102921' />
+    <nd ref='-102922' />
+    <nd ref='-102909' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='3' />
+  </way>
+  <way id='-102700' action='modify'>
+    <nd ref='-102923' />
+    <nd ref='-102924' />
+    <nd ref='-102925' />
+    <nd ref='-102926' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='40' />
+  </way>
+  <way id='-102701' action='modify'>
+    <nd ref='-102927' />
+    <nd ref='-102928' />
+    <nd ref='-102929' />
+    <nd ref='-102930' />
+    <nd ref='-102931' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='41' />
+  </way>
+  <way id='-102702' action='modify'>
+    <nd ref='-102933' />
+    <nd ref='-102970' />
+    <nd ref='-102940' />
+    <nd ref='-102950' />
+    <tag k='highway' v='unclassified' />
+  </way>
+  <way id='-102703' action='modify'>
+    <nd ref='-102934' />
+    <nd ref='-102935' />
+    <nd ref='-102936' />
+    <nd ref='-102937' />
+    <nd ref='-102938' />
+    <nd ref='-102939' />
+    <nd ref='-102940' />
+    <tag k='highway' v='unclassified' />
+    <tag k='name' v='case1' />
+    <tag k='sel' v='42' />
+  </way>
+  <way id='-102704' action='modify'>
+    <nd ref='-102952' />
+    <nd ref='-102937' />
+    <nd ref='-102966' />
+    <nd ref='-102941' />
+    <tag k='highway' v='unclassified' />
+  </way>
+  <way id='-102705' action='modify'>
+    <nd ref='-102943' />
+    <nd ref='-102944' />
+    <nd ref='-102945' />
+    <nd ref='-102946' />
+    <nd ref='-102947' />
+    <nd ref='-102948' />
+    <nd ref='-102949' />
+    <nd ref='-102950' />
+    <nd ref='-102951' />
+    <nd ref='-102952' />
+    <nd ref='-102953' />
+    <nd ref='-102942' />
+    <nd ref='-102954' />
+    <nd ref='-102955' />
+    <nd ref='-102956' />
+    <nd ref='-102957' />
+    <nd ref='-102958' />
+    <nd ref='-102959' />
+    <nd ref='-102960' />
+    <nd ref='-102961' />
+    <nd ref='-102962' />
+    <nd ref='-102963' />
+    <nd ref='-102943' />
+    <tag k='highway' v='unclassified' />
+  </way>
+  <way id='-102706' action='modify'>
+    <nd ref='-102942' />
+    <nd ref='-102934' />
+    <nd ref='-102964' />
+    <nd ref='-102932' />
+    <tag k='highway' v='unclassified' />
+  </way>
+  <way id='-102707' action='modify'>
+    <nd ref='-102964' />
+    <nd ref='-102965' />
+    <nd ref='-102966' />
+    <nd ref='-102967' />
+    <nd ref='-102968' />
+    <nd ref='-102969' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='43' />
+  </way>
+  <way id='-102708' action='modify'>
+    <nd ref='-102979' />
+    <nd ref='-102989' />
+    <nd ref='-102987' />
+    <nd ref='-102995' />
+    <nd ref='-102974' />
+    <nd ref='-102981' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='12' />
+  </way>
+  <way id='-102709' action='modify'>
+    <nd ref='-102988' />
+    <nd ref='-102971' />
+    <nd ref='-103004' />
+    <nd ref='-103014' />
+    <nd ref='-102999' />
+    <nd ref='-102982' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='11' />
+  </way>
+  <way id='-102710' action='modify'>
+    <nd ref='-103008' />
+    <nd ref='-102980' />
+    <nd ref='-103015' />
+    <nd ref='-102991' />
+    <nd ref='-103000' />
+    <nd ref='-102975' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='13' />
+  </way>
+  <way id='-102711' action='modify'>
+    <nd ref='-102977' />
+    <nd ref='-102996' />
+    <nd ref='-103007' />
+    <nd ref='-102990' />
+    <nd ref='-102973' />
+    <nd ref='-103005' />
+    <nd ref='-102988' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='11' />
+  </way>
+  <way id='-102712' action='modify'>
+    <nd ref='-102985' />
+    <nd ref='-102993' />
+    <nd ref='-103012' />
+    <nd ref='-102976' />
+    <nd ref='-102997' />
+    <nd ref='-103006' />
+    <nd ref='-102979' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='12' />
+  </way>
+  <way id='-102713' action='modify'>
+    <nd ref='-103011' />
+    <nd ref='-102986' />
+    <nd ref='-102994' />
+    <nd ref='-102972' />
+    <nd ref='-102978' />
+    <nd ref='-102998' />
+    <nd ref='-103008' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='13' />
+  </way>
+  <way id='-102714' action='modify'>
+    <nd ref='-103016' />
+    <nd ref='-103017' />
+    <nd ref='-103018' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='25' />
+  </way>
+  <way id='-102715' action='modify'>
+    <nd ref='-102975' />
+    <nd ref='-102984' />
+    <nd ref='-103002' />
+    <nd ref='-103011' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='13' />
+  </way>
+  <way id='-102716' action='modify'>
+    <nd ref='-102982' />
+    <nd ref='-103010' />
+    <nd ref='-102992' />
+    <nd ref='-102977' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='11' />
+  </way>
+  <way id='-102717' action='modify'>
+    <nd ref='-102981' />
+    <nd ref='-103001' />
+    <nd ref='-103009' />
+    <nd ref='-102985' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='12' />
+  </way>
+  <way id='-102718' action='modify'>
+    <nd ref='-103032' />
+    <nd ref='-103029' />
+    <nd ref='-103019' />
+    <nd ref='-103021' />
+    <nd ref='-103023' />
+    <nd ref='-103026' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='21' />
+  </way>
+  <way id='-102720' action='modify'>
+    <nd ref='-103028' />
+    <nd ref='-103024' />
+    <nd ref='-103030' />
+    <nd ref='-103025' />
+    <nd ref='-103027' />
+    <nd ref='-103022' />
+    <nd ref='-103032' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='21' />
+  </way>
+  <way id='-102730' action='modify'>
+    <nd ref='-103076' />
+    <nd ref='-103089' />
+    <nd ref='-103088' />
+    <nd ref='-103087' />
+    <nd ref='-103086' />
+    <nd ref='-103085' />
+    <nd ref='-103084' />
+    <nd ref='-103083' />
+    <nd ref='-103082' />
+    <nd ref='-103081' />
+    <nd ref='-103080' />
+    <nd ref='-103079' />
+    <nd ref='-103078' />
+    <nd ref='-103077' />
+    <nd ref='-103076' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='0' />
+  </way>
+  <way id='-102764' action='modify'>
+    <nd ref='-103119' />
+    <nd ref='-103120' />
+    <nd ref='-103121' />
+    <nd ref='-103122' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='31' />
+  </way>
+  <way id='-102786' action='modify'>
+    <nd ref='-103130' />
+    <nd ref='-103131' />
+    <nd ref='-103132' />
+    <nd ref='-103133' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='32' />
+  </way>
+  <way id='-102802' action='modify'>
+    <nd ref='-103138' />
+    <nd ref='-103150' />
+    <nd ref='-103139' />
+    <nd ref='-103140' />
+    <nd ref='-103150' />
+    <nd ref='-103141' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='33' />
+  </way>
+  <way id='-102814' action='modify'>
+    <nd ref='-103156' />
+    <nd ref='-103157' />
+    <nd ref='-103158' />
+    <nd ref='-103159' />
+    <nd ref='-103157' />
+    <nd ref='-103160' />
+    <nd ref='-103156' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='35' />
+  </way>
+  <way id='-102848' action='modify'>
+    <nd ref='-103187' />
+    <nd ref='-103188' />
+    <nd ref='-103189' />
+    <nd ref='-103190' />
+    <nd ref='-103187' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='34' />
+  </way>
+  <way id='-102898' action='modify'>
+    <nd ref='-103255' />
+    <nd ref='-103254' />
+    <nd ref='-103253' />
+    <nd ref='-103252' />
+    <nd ref='-103251' />
+    <nd ref='-103250' />
+    <nd ref='-103249' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='10' />
+  </way>
+  <way id='-102899' action='modify'>
+    <nd ref='-103246' />
+    <nd ref='-103245' />
+    <nd ref='-103244' />
+    <nd ref='-103243' />
+    <nd ref='-103256' />
+    <nd ref='-103255' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='10' />
+  </way>
+  <way id='-102900' action='modify'>
+    <nd ref='-103249' />
+    <nd ref='-103248' />
+    <nd ref='-103247' />
+    <nd ref='-103246' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='10' />
+  </way>
+  <way id='-102903' action='modify'>
+    <nd ref='-103272' />
+    <nd ref='-103273' />
+    <nd ref='-103274' />
+    <nd ref='-103275' />
+    <nd ref='-103276' />
+    <nd ref='-103277' />
+    <nd ref='-103278' />
+    <nd ref='-103279' />
+    <nd ref='-103280' />
+    <nd ref='-103281' />
+    <nd ref='-103282' />
+    <nd ref='-103283' />
+    <nd ref='-103284' />
+    <nd ref='-103285' />
+    <nd ref='-103272' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='4' />
+  </way>
+  <way id='-102982' action='modify'>
+    <nd ref='-103349' />
+    <nd ref='-103350' />
+    <nd ref='-103351' />
+    <nd ref='-103352' />
+    <nd ref='-103353' />
+    <nd ref='-103354' />
+    <nd ref='-103355' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='14' />
+  </way>
+  <way id='-102983' action='modify'>
+    <nd ref='-103356' />
+    <nd ref='-103357' />
+    <nd ref='-103358' />
+    <nd ref='-103349' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='14' />
+  </way>
+  <way id='-102984' action='modify'>
+    <nd ref='-103355' />
+    <nd ref='-103359' />
+    <nd ref='-103360' />
+    <nd ref='-103361' />
+    <nd ref='-103362' />
+    <nd ref='-103356' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='14' />
+  </way>
+  <way id='-103005' action='modify'>
+    <nd ref='-103409' />
+    <nd ref='-103410' />
+    <nd ref='-103411' />
+    <nd ref='-103412' />
+    <nd ref='-103409' />
+  </way>
+  <way id='-103211' action='modify'>
+    <nd ref='-103500' />
+    <nd ref='-103497' />
+    <nd ref='-103498' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='36' />
+  </way>
+  <way id='-103212' action='modify'>
+    <nd ref='-103505' />
+    <nd ref='-103501' />
+    <nd ref='-103502' />
+    <nd ref='-103503' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='37' />
+  </way>
+  <way id='-103214' action='modify'>
+    <nd ref='-103498' />
+    <nd ref='-103499' />
+    <nd ref='-103500' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='36' />
+  </way>
+  <way id='-103217' action='modify'>
+    <nd ref='-103503' />
+    <nd ref='-103504' />
+    <nd ref='-103502' />
+    <nd ref='-103505' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='37' />
+  </way>
+  <way id='-103327' action='modify'>
+    <nd ref='-103639' />
+    <nd ref='-103640' />
+    <nd ref='-103638' />
+    <nd ref='-103642' />
+    <nd ref='-103641' />
+    <nd ref='-103646' />
+    <nd ref='-103644' />
+    <nd ref='-103650' />
+    <nd ref='-103648' />
+    <nd ref='-103647' />
+    <nd ref='-103645' />
+    <nd ref='-103651' />
+    <nd ref='-103649' />
+    <nd ref='-103643' />
+    <nd ref='-103639' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='5' />
+  </way>
+  <way id='-103364' action='modify'>
+    <nd ref='-103729' />
+    <nd ref='-103727' />
+    <nd ref='-103737' />
+    <nd ref='-103726' />
+    <nd ref='-103728' />
+    <nd ref='-103732' />
+    <nd ref='-103730' />
+    <nd ref='-103733' />
+    <nd ref='-103736' />
+    <nd ref='-103724' />
+    <nd ref='-103734' />
+    <nd ref='-103725' />
+    <nd ref='-103735' />
+    <nd ref='-103731' />
+    <nd ref='-103729' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='15' />
+  </way>
+  <way id='-103383' action='modify'>
+    <nd ref='-103824' />
+    <nd ref='-103822' />
+    <nd ref='-103832' />
+    <nd ref='-103821' />
+    <nd ref='-103823' />
+    <nd ref='-103827' />
+    <nd ref='-103825' />
+    <nd ref='-103828' />
+    <nd ref='-103831' />
+    <nd ref='-103819' />
+    <nd ref='-103829' />
+    <nd ref='-103820' />
+    <nd ref='-103830' />
+    <nd ref='-103826' />
+    <nd ref='-103824' />
+    <tag k='highway' v='unclassified' />
+    <tag k='sel' v='7' />
+  </way>
+  <way id='-103411' action='modify'>
+    <nd ref='-103930' />
+    <nd ref='-103940' />
+    <nd ref='-103938' />
+    <nd ref='-103943' />
+    <nd ref='-103932' />
+    <nd ref='-103933' />
+    <nd ref='-103944' />
+    <nd ref='-103931' />
+    <nd ref='-103939' />
+    <nd ref='-103936' />
+    <nd ref='-103937' />
+    <nd ref='-103934' />
+    <nd ref='-103935' />
+    <nd ref='-103941' />
+    <nd ref='-103930' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='28' />
+  </way>
+  <way id='-103467' action='modify'>
+    <nd ref='-104058' />
+    <nd ref='-104045' />
+    <nd ref='-104046' />
+    <nd ref='-104047' />
+    <nd ref='-104048' />
+    <nd ref='-104049' />
+    <nd ref='-104050' />
+    <nd ref='-104051' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='29' />
+  </way>
+  <way id='-103468' action='modify'>
+    <nd ref='-104059' />
+    <nd ref='-104060' />
+    <nd ref='-104061' />
+    <nd ref='-104062' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='29' />
+  </way>
+  <way id='-103471' action='modify'>
+    <nd ref='-104059' />
+    <nd ref='-104062' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='29' />
+  </way>
+  <way id='-103494' action='modify'>
+    <nd ref='-104051' />
+    <nd ref='-104052' />
+    <nd ref='-104053' />
+    <nd ref='-104054' />
+    <nd ref='-104055' />
+    <nd ref='-104056' />
+    <nd ref='-104057' />
+    <nd ref='-104058' />
+    <tag k='highway' v='unclassified' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='sel' v='29' />
+  </way>
+  <relation id='-99748' action='modify'>
+    <member type='way' ref='-103005' role='outer' />
+    <tag k='invalid-selection' v='yes' />
+    <tag k='natural' v='water' />
+    <tag k='sel' v='50' />
+    <tag k='type' v='multipolygon' />
+  </relation>
+</osm>
Index: test/data/regress/20041/circle-action.osm
===================================================================
--- test/data/regress/20041/circle-action.osm	(nonexistent)
+++ test/data/regress/20041/circle-action.osm	(working copy)
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<osm version='0.6' generator='JOSM'>
+  <node id='3353142168' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90029704945' lon='8.44321406009' />
+  <node id='3353142170' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90031807489' lon='8.44326193915' />
+  <node id='3353142171' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90030468523' lon='8.44306677855' />
+  <node id='3353142174' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90033729149' lon='8.44301884234' />
+  <node id='3353142175' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90034976283' lon='8.44329321571' />
+  <node id='3353142183' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90040118461' lon='8.44329685665' />
+  <node id='3353142184' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.9004078959' lon='8.44300955386' />
+  <node id='3353142189' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90046511808' lon='8.44319779138' />
+  <node id='3353142190' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90044790476' lon='8.44305434646' />
+  <node id='3353142192' action='modify' timestamp='2015-02-15T23:33:27Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323' lat='52.90046284581' lon='8.44309505092' />
+  <way id='-104527' action='modify' visible='true'>
+    <nd ref='3353142171' />
+    <nd ref='3353142168' />
+    <nd ref='3353142170' />
+    <nd ref='3353142175' />
+    <nd ref='3353142183' />
+    <nd ref='3353142189' />
+    <nd ref='3353142192' />
+    <nd ref='3353142190' />
+    <nd ref='3353142184' />
+    <nd ref='3353142174' />
+    <nd ref='3353142171' />
+    <tag k='barrier' v='fence' />
+  </way>
+  <way id='328483730' timestamp='2015-02-15T23:33:35Z' uid='715371' user='715371' visible='true' version='1' changeset='28875323'>
+    <nd ref='3353142174' />
+    <nd ref='3353142184' />
+    <nd ref='3353142190' />
+    <nd ref='3353142192' />
+    <nd ref='3353142189' />
+    <nd ref='3353142183' />
+    <nd ref='3353142175' />
+    <nd ref='3353142170' />
+    <nd ref='3353142168' />
+    <nd ref='3353142171' />
+    <nd ref='3353142174' />
+    <tag k='natural' v='water' />
+  </way>
+</osm>
Index: test/unit/org/openstreetmap/josm/actions/AlignInCircleActionTest.java
===================================================================
--- test/unit/org/openstreetmap/josm/actions/AlignInCircleActionTest.java	(revision 17386)
+++ test/unit/org/openstreetmap/josm/actions/AlignInCircleActionTest.java	(working copy)
@@ -4,6 +4,7 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -13,9 +14,11 @@
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.actions.AlignInCircleAction.InvalidSelection;
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.io.OsmReader;
 import org.openstreetmap.josm.testutils.JOSMTestRules;
@@ -92,40 +95,6 @@
     }
 
     /**
-     * Test case: way with several nodes selected
-     * @throws Exception if an error occurs
-     */
-    @Test
-    void testNodesSelected() throws Exception {
-        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleBefore.osm")), null);
-        DataSet ds2 = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleAfter2.osm")), null);
-
-        Way circularWay = null;
-        for (Way w : ds.getWays()) {
-            if ("roundabout".equals(w.get("junction"))) {
-                circularWay = w;
-                break;
-            }
-        }
-        assertNotNull(circularWay);
-        if (circularWay != null) {
-            ds.setSelected(circularWay.getNodes());
-            Command c = AlignInCircleAction.buildCommand(ds);
-            assertNotNull(c);
-            c.executeCommand();
-            Way expected = (Way) ds2.getPrimitiveById(circularWay);
-            assertNotNull(expected);
-            assertEquals(expected, circularWay);
-            assertEquals(expected.getNodesCount(), circularWay.getNodesCount());
-            for (Node n1 : circularWay.getNodes()) {
-                Node n2 = (Node) ds2.getPrimitiveById(n1);
-                assertEquals(n1.lat(), n2.lat(), 1e-5);
-                assertEquals(n1.lon(), n2.lon(), 1e-5);
-            }
-        }
-    }
-
-    /**
      * Test case: original roundabout was split, two ways selected, they build a closed ring
      * @throws Exception if an error occurs
      */
@@ -149,4 +118,29 @@
         }
     }
 
+    /**
+     * Various cases of selections in file
+     * @throws Exception if an error occurs
+     */
+    @Test
+    void testSelectionEvaluation() throws Exception {
+        DataSet ds = OsmReader.parseDataSet(
+                Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "alignCircleCases.osm")), null);
+
+        for (int i = 0; i < 60; i++) {
+            final String selVal = Integer.toString(i);
+            Set<OsmPrimitive> sel = ds.allPrimitives().stream().filter(p -> p.hasTag("sel", selVal))
+                    .collect(Collectors.toSet());
+            if (sel.isEmpty())
+                continue;
+            ds.setSelected(sel);
+            boolean selValid = sel.stream().noneMatch(p -> p.hasKey("invalid-selection"));
+            try {
+                assertNotNull(AlignInCircleAction.buildCommand(ds), "sel=" + selVal);
+                assertTrue (selValid, "sel=" + selVal + " should be valid ");
+            } catch (InvalidSelection e) {
+                assertTrue (!selValid, "sel=" + selVal + " should be invalid ");
+            }
+        }
+    }
 }
