Index: /applications/editors/josm/plugins/opendata/build.xml
===================================================================
--- /applications/editors/josm/plugins/opendata/build.xml	(revision 33357)
+++ /applications/editors/josm/plugins/opendata/build.xml	(revision 33358)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <project name="opendata" default="dist" basedir=".">
-    <property name="plugin.main.version" value="11919"/>
+    <property name="plugin.main.version" value="12287"/>
     <property name="plugin.author" value="Don-vip"/>
     <property name="plugin.class" value="org.openstreetmap.josm.plugins.opendata.OdPlugin"/>
Index: /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/DataSetUpdater.java
===================================================================
--- /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/DataSetUpdater.java	(revision 33357)
+++ /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/DataSetUpdater.java	(revision 33358)
@@ -4,12 +4,21 @@
 import java.io.File;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.SimplifyWayAction;
+import org.openstreetmap.josm.actions.SplitWayAction;
+import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult;
 import org.openstreetmap.josm.command.SequenceCommand;
 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.Relation;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.plugins.opendata.core.OdConstants;
 
@@ -17,17 +26,44 @@
 
     public static final void updateDataSet(DataSet dataSet, AbstractDataSetHandler handler, File associatedFile) {
-        if (dataSet != null && handler != null) {
-            if (associatedFile != null) {
-                handler.setAssociatedFile(associatedFile);
-                long lastmodified = associatedFile.lastModified();
-                if (lastmodified > 0) {
-                    handler.setSourceDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date(lastmodified)));
+        if (dataSet != null) {
+            if (handler != null) {
+                if (associatedFile != null) {
+                    handler.setAssociatedFile(associatedFile);
+                    long lastmodified = associatedFile.lastModified();
+                    if (lastmodified > 0) {
+                        handler.setSourceDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date(lastmodified)));
+                    }
+                }
+                if (!Main.pref.getBoolean(OdConstants.PREF_RAWDATA)) {
+                    handler.updateDataSet(dataSet);
+                }
+                handler.checkDataSetSource(dataSet);
+                handler.checkNames(dataSet);
+            }
+            // Simplify ways geometries
+            for (Way w : dataSet.getWays()) {
+                SequenceCommand command = SimplifyWayAction.simplifyWay(w, 0.25);
+                if (command != null) {
+                    command.executeCommand();
                 }
             }
-            if (!Main.pref.getBoolean(OdConstants.PREF_RAWDATA)) {
-                handler.updateDataSet(dataSet);
+            // Split ways exceeding 90% of the API limit (currently 2000 nodes)
+            int max = (int) (0.9 * OsmApi.getOsmApi().getCapabilities().getMaxWayNodes());
+            for (Way w : dataSet.getWays().stream()
+                    .filter(w -> w.getNodesCount() > max)
+                    .collect(Collectors.toList())) {
+                List<Node> atNodes = new ArrayList<>();
+                if (w.isClosed()) {
+                    atNodes.add(w.getNode(0));
+                }
+                double n = Math.ceil(w.getNodesCount() / (double) max);
+                for (int i = 1; i < n; i++) {
+                    atNodes.add(w.getNode((int) ((i / n) * w.getNodesCount())));
+                }
+                SplitWayResult res = SplitWayAction.split(null, w, atNodes, Collections.emptyList());
+                if (res != null) {
+                    res.getCommand().executeCommand();
+                }
             }
-            handler.checkDataSetSource(dataSet);
-            handler.checkNames(dataSet);
             // Replace multipolygons with single untagged member by their sole member
             for (Relation r : dataSet.getRelations()) {
@@ -42,11 +78,4 @@
                 }
             }
-            // Simplify ways geometries
-            for (Way w : dataSet.getWays()) {
-                SequenceCommand command = Main.main.menu.simplifyWay.simplifyWay(w, 0.25);
-                if (command != null) {
-                    Main.main.undoRedo.addNoRedraw(command);
-                }
-            }
         }
     }
Index: /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
===================================================================
--- /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java	(revision 33357)
+++ /applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java	(revision 33358)
@@ -299,7 +299,16 @@
     }
 
+    private static InputStream getEsriWkidStream() {
+        InputStream in = GeographicReader.class.getResourceAsStream(OdConstants.ESRI_WKID);
+        if (in == null) {
+            // Setup different for unit tests
+            in = GeographicReader.class.getResourceAsStream(OdConstants.ESRI_WKID.replaceFirst("/resources", ""));
+        }
+        return in;
+    }
+
     private static void loadEsriWkid() throws IOException {
         Main.info("Loading ESRI WKID database...");
-        try (InputStream in = GeographicReader.class.getResourceAsStream(OdConstants.ESRI_WKID);
+        try (InputStream in = getEsriWkidStream();
             JsonReader json = JsonProvider.provider().createReader(in)) {
             JsonObject root = json.readObject();
Index: /applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java
===================================================================
--- /applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java	(revision 33358)
+++ /applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java	(revision 33358)
@@ -0,0 +1,48 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.plugins.opendata.core.io.datasets;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.function.Predicate;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openstreetmap.josm.TestUtils;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.io.OsmApi;
+import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater;
+import org.openstreetmap.josm.plugins.opendata.core.io.archive.ZipReader;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+/**
+ * Unit tests of {@link DataSetUpdater} class.
+ */
+public class DataSetUpdaterTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    public JOSMTestRules rules = new JOSMTestRules().preferences().projection().devAPI().timeout(60000);
+
+    /**
+     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/11166">#11166</a>
+     * @throws Exception if an error occurs during reading
+     */
+    @Test
+    public void testTicket11166() throws Exception {
+        File file = new File(TestUtils.getRegressionDataFile(11166, "raba760dissJosm.zip"));
+        try (InputStream is =   new FileInputStream(file)) {
+            Predicate<? super Way> p = w -> w.getNodesCount() >= 0.9 * OsmApi.getOsmApi().getCapabilities().getMaxWayNodes();
+            DataSet ds = ZipReader.parseDataSet(is, null, null, false);
+            assertTrue(ds.getWays().stream().filter(p).findAny().isPresent());
+            DataSetUpdater.updateDataSet(ds, null, file);
+            assertFalse(ds.getWays().stream().filter(p).findAny().isPresent());
+        }
+    }
+}
