Skip to content

Commit

Permalink
Merge pull request #38 from tsmock/pt-assistant-17177
Browse files Browse the repository at this point in the history
pt_assistant: recompile for compatibility with JOSM r17867
  • Loading branch information
simon04 authored May 18, 2021
2 parents 494d8ad + 4ad577e commit 1ff2e15
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) {
Map<Double, List<WaySegment>> nearestMap = new TreeMap<>();
private Map<Double, List<IWaySegment<Node, Way>>> getNearestWaySegmentsImpl(Point p) {
Map<Double, List<IWaySegment<Node, Way>>> nearestMap = new TreeMap<>();
DataSet ds = getCurrentDataSet();

if (ds != null) {
Expand Down Expand Up @@ -192,14 +193,14 @@ private Map<Double, List<WaySegment>> 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<WaySegment> wslist;
List<IWaySegment<Node, Way>> 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;
Expand All @@ -220,12 +221,12 @@ private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) {
protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) {
MapView mapView = MainApplication.getMap().mapView;
Point p = mapView.getPoint(platformCoord);
Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p);
for (Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet()) {
for (WaySegment waySegment : entry.getValue()) {
if (testWay(waySegment.way, stopArea)) {
Node n = waySegment.getFirstNode();
Node lastN = waySegment.getSecondNode();
Map<Double, List<IWaySegment<Node, Way>>> dist_waySegments = getNearestWaySegmentsImpl(p);
for (Map.Entry<Double, List<IWaySegment<Node, Way>>> entry : dist_waySegments.entrySet()) {
for (IWaySegment<Node, Way> 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));
Expand All @@ -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<?, Way> waySegment) {
UndoRedoHandler.getInstance().add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newStopNode));
List<Node> wayNodes = waySegment.way.getNodes();
wayNodes.add(waySegment.lowerIndex + 1, newStopNode);
Way newWay = new Way(waySegment.way);
List<Node> 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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,7 +18,7 @@ public class NearestWaySegment {
/**
* Way segment
*/
public WaySegment waySegment;
public IWaySegment<Node, Way> waySegment;
/**
* Node
*/
Expand All @@ -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<Node, Way> waySegment, Node newNode) {
this.distanceSq = distanceSq;
this.waySegment = waySegment;
this.newNode = newNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<?, Way> ws : wss) {
newHighlights.add(ws.getWay());
}
newCurs = CURSOR_JOIN_WAY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -636,8 +637,8 @@ public void mouseMoved(MouseEvent e) {
OsmPrimitive::isSelectable);

if (!wss.isEmpty()) {
for (WaySegment ws : wss) {
newHighlights.add(ws.way);
for (IWaySegment<?, Way> ws : wss) {
newHighlights.add(ws.getWay());
}
newCurs = cursorJoinWay;
}
Expand Down

0 comments on commit 1ff2e15

Please sign in to comment.