From 01ce992d24faf811375f0b7e08bc76b159234822 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 7 Dec 2022 07:23:42 -0700 Subject: [PATCH] Update to non-deprecated methods Signed-off-by: Taylor Smock --- .github/workflows/ant-release.yml | 2 +- .github/workflows/ant.yml | 2 +- build.gradle | 1 + build.xml | 1 + gradle.properties | 4 ++-- .../plugins/mapwithai/backend/GetDataRunnable.java | 11 ++++++----- .../plugins/mapwithai/backend/MapWithAIDataUtils.java | 6 ++++-- .../plugins/mapwithai/commands/DuplicateCommand.java | 2 +- .../mapwithai/commands/MergeDuplicateWays.java | 5 ++--- .../commands/cleanup/MissingConnectionTags.java | 8 +++----- .../mapwithai/data/validation/tests/StubEndsTest.java | 7 ++----- .../gui/download/MapWithAIDownloadSourceType.java | 11 +++++++---- .../mapwithai/io/mapwithai/MapWithAISourceReader.java | 1 - 13 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ant-release.yml b/.github/workflows/ant-release.yml index 02678a4..981ae49 100644 --- a/.github/workflows/ant-release.yml +++ b/.github/workflows/ant-release.yml @@ -8,7 +8,7 @@ jobs: call-workflow: uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1 with: - josm-revision: "r18218" + josm-revision: "r18464" update-pluginssource: true plugin-jar-name: 'mapwithai' secrets: diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 5b5fb4e..3176beb 100644 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -18,7 +18,7 @@ jobs: call-workflow: strategy: matrix: - josm-revision: ["", "r18218"] + josm-revision: ["", "r18464"] uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v1 with: josm-revision: ${{ matrix.josm-revision }} diff --git a/build.gradle b/build.gradle index 39c82a3..3510434 100644 --- a/build.gradle +++ b/build.gradle @@ -212,6 +212,7 @@ spotless { josm { debugPort = 7055 manifest { + oldVersionDownloadLink 18218, "v1.9.20", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.9.20/mapwithai.jar") oldVersionDownloadLink 17903, "v1.8.7", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.8.7/mapwithai.jar") oldVersionDownloadLink 17084, "v1.7.1.6", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.7.1.6/mapwithai.jar") oldVersionDownloadLink 16645, "v1.6.8", new URL("https://github.com/JOSM/MapWithAI/releases/download/v1.6.8/mapwithai.jar") diff --git a/build.xml b/build.xml index c56d5d8..307aefd 100644 --- a/build.xml +++ b/build.xml @@ -31,6 +31,7 @@ + diff --git a/gradle.properties b/gradle.properties index df4d2e1..72a9ca7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ # The minimum JOSM version this plugin is compatible with (can be any numeric version -plugin.main.version = 18218 +plugin.main.version = 18464 # The JOSM version this plugin is currently compiled against # Please make sure this version is available at https://josm.openstreetmap.de/download # The special values "latest" and "tested" are also possible here, but not recommended. -plugin.compile.version = 18218 +plugin.compile.version = 18468 plugin.canloadatruntime = true plugin.author = Taylor Smock plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java index 29ae8ae..4e044bc 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnable.java @@ -359,14 +359,15 @@ public class GetDataRunnable extends RecursiveTask { twoMap.remove(MAPWITHAI_SOURCE_TAG_KEY); if (one.getClass().equals(two.getClass()) && oneMap.equals(twoMap)) { if (one instanceof Node) { - final LatLon coor1 = ((Node) one).getCoor(); - final LatLon coor2 = ((Node) two).getCoor(); - if (one.hasSameInterestingTags(two) && coor1 != null && coor2 != null && coor1.equalsEpsilon(coor2)) { + final ILatLon coor1 = ((Node) one); + final ILatLon coor2 = ((Node) two); + if (one.hasSameInterestingTags(two) && coor1.isLatLonKnown() && coor2.isLatLonKnown() + && coor1.equalsEpsilon(coor2)) { equivalent = true; } } else if (one instanceof Way) { - equivalent = ((Way) one).getNodes().stream().map(INode::getCoor).filter(Objects::nonNull).allMatch( - node1 -> ((Way) two).getNodes().stream().map(INode::getCoor).anyMatch(node1::equalsEpsilon)); + equivalent = ((Way) one).getNodes().stream().filter(Objects::nonNull) + .allMatch(node1 -> ((Way) two).getNodes().stream().anyMatch(node1::equalsEpsilon)); } else if (one instanceof Relation) { equivalent = ((Relation) one).getMembers().stream() .allMatch(member1 -> ((Relation) two).getMembers().stream() diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java index 448be08..2f6eff5 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java @@ -23,6 +23,7 @@ import java.util.stream.Collectors; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.UndoRedoHandler; +import org.openstreetmap.josm.data.coor.ILatLon; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.data.osm.Node; @@ -264,7 +265,7 @@ public final class MapWithAIDataUtils { final double minx = bottomLeft.getX(); final double maxY = topRight.getY(); final LatLon topLeft = new LatLon(maxY, minx); - return bottomLeft.greatCircleDistance(topLeft); + return bottomLeft.greatCircleDistance((ILatLon) topLeft); } /** @@ -380,7 +381,8 @@ public final class MapWithAIDataUtils { final double maxY = topRight.getY(); final LatLon bottomRight = new LatLon(minY, maxX); final LatLon topLeft = new LatLon(maxY, minX); - return Math.max(bottomLeft.greatCircleDistance(bottomRight), topLeft.greatCircleDistance(topRight)); + return Math.max(bottomLeft.greatCircleDistance((ILatLon) bottomRight), + topLeft.greatCircleDistance((ILatLon) topRight)); } /** diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommand.java index 96cffdd..5e572cc 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommand.java @@ -69,7 +69,7 @@ public class DuplicateCommand extends AbstractConflationCommand { */ public static Command replaceNode(Node original, Node newNode) { Command tCommand = null; - if (original.getCoor().equalsEpsilon(newNode.getCoor())) { + if (original.equalsEpsilon(newNode)) { tCommand = MergeNodesAction.mergeNodes(Collections.singletonList(original), newNode, newNode); } return tCommand; diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java index 013e633..68fc849 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java @@ -386,9 +386,8 @@ public class MergeDuplicateWays extends Command { final Node origNode = way1.getNode(j); for (int k = 0; k < way2.getNodesCount(); k++) { final Node possDupeNode = way2.getNode(k); - if (origNode.equals(possDupeNode) - || (origNode.getCoor().greatCircleDistance(possDupeNode.getCoor()) < MapWithAIPreferenceHelper - .getMaxNodeDistance())) { + if (origNode.equals(possDupeNode) || (origNode + .greatCircleDistance(possDupeNode) < MapWithAIPreferenceHelper.getMaxNodeDistance())) { final Pair origNodePair = new Pair<>(j, origNode); final Map dupeNodeMap = duplicateNodes.getOrDefault(origNodePair, new HashMap<>()); dupeNodeMap.put(k, possDupeNode); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/cleanup/MissingConnectionTags.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/cleanup/MissingConnectionTags.java index f0f65ca..f4d0839 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/cleanup/MissingConnectionTags.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/cleanup/MissingConnectionTags.java @@ -22,7 +22,6 @@ import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.SequenceCommand; import org.openstreetmap.josm.data.osm.BBox; import org.openstreetmap.josm.data.osm.DataSet; -import org.openstreetmap.josm.data.osm.INode; import org.openstreetmap.josm.data.osm.IPrimitive; import org.openstreetmap.josm.data.osm.IWaySegment; import org.openstreetmap.josm.data.osm.Node; @@ -212,10 +211,9 @@ public class MissingConnectionTags extends AbstractConflationCommand { Collection nodes = Geometry.addIntersections(error.getPrimitives().stream().filter(Way.class::isInstance) .map(Way.class::cast).filter(w -> w.hasKey(HIGHWAY)).collect(Collectors.toList()), false, new ArrayList<>()); - if (nodes.stream().filter(MissingConnectionTags::noConflationKey).map(INode::getCoor).filter(Objects::nonNull) - .anyMatch( - n -> way.getNodes().stream().filter(MissingConnectionTags::noConflationKey).map(INode::getCoor) - .filter(Objects::nonNull).anyMatch(wn -> n.greatCircleDistance(wn) < precision))) { + if (nodes.stream().filter(MissingConnectionTags::noConflationKey).filter(Objects::nonNull) + .anyMatch(n -> way.getNodes().stream().filter(MissingConnectionTags::noConflationKey) + .filter(Objects::nonNull).anyMatch(wn -> n.greatCircleDistance(wn) < precision))) { return () -> createIntersectionCommand(way, way.getNodes().stream().filter(MissingConnectionTags::noConflationKey) .filter(n1 -> nodes.stream().anyMatch(n2 -> Geometry.getDistance(n1, n2) < precision)) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTest.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTest.java index 5dd8a9b..0c543a6 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTest.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTest.java @@ -14,7 +14,6 @@ import java.util.stream.Collectors; import org.openstreetmap.josm.command.ChangeCommand; import org.openstreetmap.josm.command.DeleteCommand; import org.openstreetmap.josm.command.SequenceCommand; -import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.data.validation.Severity; @@ -123,10 +122,8 @@ public class StubEndsTest extends Test { List connectingWays = getConnectingWays(previous, way); if (!node.equals(previous) && connectingWays.isEmpty()) { nodesToConnection.add(previous); - final LatLon nodeCoor = node.getCoor(); - final LatLon prevCoor = previous.getCoor(); - if (nodeCoor != null && prevCoor != null) { - distance += nodeCoor.greatCircleDistance(prevCoor); + if (node.isLatLonKnown() && previous.isLatLonKnown()) { + distance += node.greatCircleDistance(previous); } previous = node; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceType.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceType.java index 4c4e4f1..2e6b823 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceType.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceType.java @@ -10,6 +10,7 @@ import java.util.stream.Stream; import org.openstreetmap.josm.actions.downloadtasks.AbstractDownloadTask; import org.openstreetmap.josm.data.Bounds; +import org.openstreetmap.josm.data.coor.ILatLon; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.preferences.BooleanProperty; import org.openstreetmap.josm.gui.download.IDownloadSourceType; @@ -64,10 +65,12 @@ public class MapWithAIDownloadSourceType implements IDownloadSourceType, LayerCh * @return {@code true} if the area is too large */ public static boolean isDownloadAreaTooLargeStatic(Bounds bound) { - double width = Math.max(bound.getMin().greatCircleDistance(new LatLon(bound.getMinLat(), bound.getMaxLon())), - bound.getMax().greatCircleDistance(new LatLon(bound.getMaxLat(), bound.getMinLon()))); - double height = Math.max(bound.getMin().greatCircleDistance(new LatLon(bound.getMaxLat(), bound.getMinLon())), - bound.getMax().greatCircleDistance(new LatLon(bound.getMinLat(), bound.getMaxLon()))); + double width = Math.max( + bound.getMin().greatCircleDistance((ILatLon) new LatLon(bound.getMinLat(), bound.getMaxLon())), + bound.getMax().greatCircleDistance((ILatLon) new LatLon(bound.getMaxLat(), bound.getMinLon()))); + double height = Math.max( + bound.getMin().greatCircleDistance((ILatLon) new LatLon(bound.getMaxLat(), bound.getMinLon())), + bound.getMax().greatCircleDistance((ILatLon) new LatLon(bound.getMinLat(), bound.getMaxLon()))); return height > MapWithAIDataUtils.MAXIMUM_SIDE_DIMENSIONS || width > MapWithAIDataUtils.MAXIMUM_SIDE_DIMENSIONS; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java index a945c0f..f7b487e 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReader.java @@ -8,7 +8,6 @@ import javax.json.JsonValue; import java.io.Closeable; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects;