diff --git a/gradle.properties b/gradle.properties index 914aa89a..7ee98bd1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ plugin.canloadatruntime=true plugin.icon=images/bus.svg # Minimum JOSM version (any numeric version) -plugin.main.version=15238 +plugin.main.version=17903 # JOSM version to compile against (any numeric version available for download, or the special values "tested" or "latest") -plugin.compile.version=17084 +plugin.compile.version=17903 diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java index 4d81e231..6a22408e 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java @@ -18,9 +18,10 @@ import org.openstreetmap.josm.data.coor.LatLon; 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.IWaySegment; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.Way; -import org.openstreetmap.josm.data.osm.WaySegment; import org.openstreetmap.josm.data.projection.ProjectionRegistry; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.MapView; @@ -154,8 +155,8 @@ public Boolean testWay(final Way way, final StopArea stopArea) { * @return a sorted map with the keys representing the perpendicular distance of * their associated way segments to point p. */ - private Map> getNearestWaySegmentsImpl(Point p) { - Map> nearestMap = new TreeMap<>(); + private Map>> getNearestWaySegmentsImpl(Point p) { + Map>> nearestMap = new TreeMap<>(); DataSet ds = getCurrentDataSet(); if (ds != null) { @@ -192,14 +193,14 @@ private Map> getNearestWaySegmentsImpl(Point p) { Double.doubleToLongBits(a - (a - b + c) * (a - b + c) / 4 / c) >> 32 << 32); if (perDistSq < snapDistanceSq && a < c + snapDistanceSq && b < c + snapDistanceSq) { - List wslist; + List> wslist; if (nearestMap.containsKey(perDistSq)) { wslist = nearestMap.get(perDistSq); } else { wslist = new LinkedList<>(); nearestMap.put(perDistSq, wslist); } - wslist.add(new WaySegment(w, i)); + wslist.add(new IWaySegment<>(w, i)); } lastN = n; @@ -220,12 +221,12 @@ private Map> getNearestWaySegmentsImpl(Point p) { protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) { MapView mapView = MainApplication.getMap().mapView; Point p = mapView.getPoint(platformCoord); - Map> dist_waySegments = getNearestWaySegmentsImpl(p); - for (Map.Entry> entry : dist_waySegments.entrySet()) { - for (WaySegment waySegment : entry.getValue()) { - if (testWay(waySegment.way, stopArea)) { - Node n = waySegment.getFirstNode(); - Node lastN = waySegment.getSecondNode(); + Map>> dist_waySegments = getNearestWaySegmentsImpl(p); + for (Map.Entry>> entry : dist_waySegments.entrySet()) { + for (IWaySegment waySegment : entry.getValue()) { + if (testWay(waySegment.getWay(), stopArea)) { + INode n = waySegment.getFirstNode(); + INode lastN = waySegment.getSecondNode(); EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(), lastN.getEastNorth(), ProjectionRegistry.getProjection().latlon2eastNorth(platformCoord)); @@ -251,13 +252,13 @@ protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea * @param waySegment Way segment including stop position node * @return Stop position node */ - protected Node createNodeOnWay(Node newStopNode, WaySegment waySegment) { + protected Node createNodeOnWay(Node newStopNode, IWaySegment waySegment) { UndoRedoHandler.getInstance().add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newStopNode)); - List wayNodes = waySegment.way.getNodes(); - wayNodes.add(waySegment.lowerIndex + 1, newStopNode); - Way newWay = new Way(waySegment.way); + List wayNodes = waySegment.getWay().getNodes(); + wayNodes.add(waySegment.getUpperIndex(), newStopNode); + Way newWay = new Way(waySegment.getWay()); newWay.setNodes(wayNodes); - UndoRedoHandler.getInstance().add(new ChangeCommand(waySegment.way, newWay)); + UndoRedoHandler.getInstance().add(new ChangeCommand(waySegment.getWay(), newWay)); return newStopNode; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java index c779b4f2..3d5d1827 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java +++ b/src/main/java/org/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java @@ -1,8 +1,9 @@ // License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.customizepublictransportstop; +import org.openstreetmap.josm.data.osm.IWaySegment; import org.openstreetmap.josm.data.osm.Node; -import org.openstreetmap.josm.data.osm.WaySegment; +import org.openstreetmap.josm.data.osm.Way; /** * Distance from platform to ways @@ -17,7 +18,7 @@ public class NearestWaySegment { /** * Way segment */ - public WaySegment waySegment; + public IWaySegment waySegment; /** * Node */ @@ -30,7 +31,7 @@ public class NearestWaySegment { * @param waySegment Way segment * @param newNode Node */ - public NearestWaySegment(Double distanceSq, WaySegment waySegment, Node newNode) { + public NearestWaySegment(Double distanceSq, IWaySegment waySegment, Node newNode) { this.distanceSq = distanceSq; this.waySegment = waySegment; this.newNode = newNode; diff --git a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java index df40441f..11a390cb 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java +++ b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java @@ -24,6 +24,7 @@ import org.openstreetmap.josm.command.SequenceCommand; import org.openstreetmap.josm.command.SplitWayCommand; import org.openstreetmap.josm.data.UndoRedoHandler; +import org.openstreetmap.josm.data.osm.IWaySegment; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.OsmPrimitiveType; @@ -103,8 +104,8 @@ public void mouseMoved(MouseEvent e) { MainApplication.getMap().mapView.getNearestWaySegments(e.getPoint(), OsmPrimitive::isSelectable); if (!wss.isEmpty()) { - for (WaySegment ws : wss) { - newHighlights.add(ws.way); + for (IWaySegment ws : wss) { + newHighlights.add(ws.getWay()); } newCurs = CURSOR_JOIN_WAY; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java index 4361bbc0..276b80da 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java +++ b/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/DoubleSplitAction.java @@ -41,6 +41,7 @@ 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.IWaySegment; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.OsmPrimitiveType; @@ -636,8 +637,8 @@ public void mouseMoved(MouseEvent e) { OsmPrimitive::isSelectable); if (!wss.isEmpty()) { - for (WaySegment ws : wss) { - newHighlights.add(ws.way); + for (IWaySegment ws : wss) { + newHighlights.add(ws.getWay()); } newCurs = cursorJoinWay; }