Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<property name="plugin.build.dir" value="build" />
<property name="plugin.src.dir" value="src" />
<property name="plugin.dist.dir" value="../../dist" />
<property name="plugin.dist.dir" value="dist" />
<property name="plugin.jar" value="${plugin.dist.dir}/CustomizePublicTransportStop.jar" />
<property name="josm" location="../../core/dist/josm-custom.jar"/>
<property name="josm" location="dist/josm-tested.jar"/>

<target name="init">
<available file="build.properties" property="build.properties.present" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.TreeMap;

import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.command.AddCommand;
import org.openstreetmap.josm.command.ChangeCommand;
import org.openstreetmap.josm.data.coor.EastNorth;
Expand Down Expand Up @@ -59,7 +60,7 @@ private Map<Double, List<Node>> getNearestNodesImpl(Point p) {
snapDistanceSq *= snapDistanceSq;

for (Node n : ds.searchNodes(getBBox(p, 200))) {
if ((dist = Main.map.mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq)
if ((dist = MainApplication.getMap().mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq)
{
List<Node> nlist;
if (nearestMap.containsKey(dist)) {
Expand All @@ -83,8 +84,8 @@ private Map<Double, List<Node>> getNearestNodesImpl(Point p) {
* @return Area
*/
private BBox getBBox(Point p, int snapDistance) {
return new BBox(Main.map.mapView.getLatLon(p.x - snapDistance, p.y - snapDistance),
Main.map.mapView.getLatLon(p.x + snapDistance, p.y + snapDistance));
return new BBox(MainApplication.getMap().mapView.getLatLon(p.x - snapDistance, p.y - snapDistance),
MainApplication.getMap().mapView.getLatLon(p.x + snapDistance, p.y + snapDistance));
}

/**
Expand All @@ -95,7 +96,7 @@ private BBox getBBox(Point p, int snapDistance) {
*/
public AbstractMap.SimpleEntry<Double, Node> getNearestNode(LatLon platformCoord, StopArea stopArea)
{
Point p = Main.map.mapView.getPoint(platformCoord);
Point p = MainApplication.getMap().mapView.getPoint(platformCoord);
Map<Double, List<Node>> dist_nodes = getNearestNodesImpl(p);
Double[] distances = dist_nodes.keySet().toArray(new Double[0]);
distances = sort(distances);
Expand Down Expand Up @@ -195,10 +196,10 @@ private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) {
DataSet ds = getCurrentDataSet();

if (ds != null) {
double snapDistanceSq = Main.pref.getInteger("mappaint.segment.snap-distance", 200);
double snapDistanceSq = Main.pref.getInt("mappaint.segment.snap-distance", 200);
snapDistanceSq *= snapDistanceSq;

for (Way w : ds.searchWays(getBBox(p, Main.pref.getInteger("mappaint.segment.snap-distance", 200)))) {
for (Way w : ds.searchWays(getBBox(p, Main.pref.getInt("mappaint.segment.snap-distance", 200)))) {
Node lastN = null;
int i = -2;
for (Node n : w.getNodes()) {
Expand All @@ -211,8 +212,8 @@ private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) {
continue;
}

Point2D A = Main.map.mapView.getPoint2D(lastN);
Point2D B = Main.map.mapView.getPoint2D(n);
Point2D A = MainApplication.getMap().mapView.getPoint2D(lastN);
Point2D B = MainApplication.getMap().mapView.getPoint2D(n);
double c = A.distanceSq(B);
double a = p.distanceSq(B);
double b = p.distanceSq(A);
Expand Down Expand Up @@ -254,7 +255,7 @@ private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) {
protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea)
{

Point p = Main.map.mapView.getPoint(platformCoord);
Point p = MainApplication.getMap().mapView.getPoint(platformCoord);
Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p);
for(Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet())
{
Expand All @@ -266,11 +267,11 @@ protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea
Node lastN = waySegment.getSecondNode();

EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(),
lastN.getEastNorth(), Projections.project(platformCoord));
LatLon newNodePosition = Projections.inverseProject(newPosition);
Point2D lastN2D = Main.map.mapView.getPoint2D(lastN);
Point2D n2D = Main.map.mapView.getPoint2D(n);
Point2D newNodePosition2D = Main.map.mapView.getPoint2D(newNodePosition);
lastN.getEastNorth(), Main.getProjection().latlon2eastNorth(platformCoord));
LatLon newNodePosition = Main.getProjection().eastNorth2latlon(newPosition);
Point2D lastN2D = MainApplication.getMap().mapView.getPoint2D(lastN);
Point2D n2D = MainApplication.getMap().mapView.getPoint2D(n);
Point2D newNodePosition2D = MainApplication.getMap().mapView.getPoint2D(newNodePosition);
Double distCurrenNodes =lastN2D.distance(n2D);
if((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes))
{
Expand All @@ -290,7 +291,7 @@ protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea
*/
protected Node createNodeOnWay(Node newStopNode, WaySegment waySegment)
{
Main.main.undoRedo.add(new AddCommand(newStopNode));
Main.main.undoRedo.add(new AddCommand(getCurrentDataSet(), newStopNode));
List<Node> wayNodes = waySegment.way.getNodes();
wayNodes.add(waySegment.lowerIndex + 1, newStopNode);
Way newWay = new Way(waySegment.way);
Expand Down Expand Up @@ -320,7 +321,7 @@ public StopArea performCustomizing(StopArea stopArea)
Node newStopPointNode = null;
if(nearestNode != null && nearestWaySegment != null)
{
Double segmentDist = Main.map.mapView.getPoint2D(platformCoord).distanceSq(Main.map.mapView.getPoint2D(nearestWaySegment.newNode));
Double segmentDist = MainApplication.getMap().mapView.getPoint2D(platformCoord).distanceSq(MainApplication.getMap().mapView.getPoint2D(nearestWaySegment.newNode));
Double nodeDistSq = nearestNode.getKey();
// nodeDistSq *= nodeDistSq - 2;
if(segmentDist < nodeDistSq - 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop;

import org.openstreetmap.josm.Main;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation;

Expand All @@ -24,7 +24,7 @@ public class CustomizePublicTransportStopPlugin extends Plugin
public CustomizePublicTransportStopPlugin(PluginInformation info) {
super(info);
stopAreaCreatorAction = CustomizeStopAction.createCustomizeStopAction();
Main.main.menu.toolsMenu.add(stopAreaCreatorAction);
MainApplication.getMenu().toolsMenu.add(stopAreaCreatorAction);
System.out.println(getPluginDir());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private List<Command> createStopAreaRelation(List<Command> commands, StopArea st
{
newRelation.addMember(new RelationMember("", otherMember));
}
Main.main.undoRedo.add(new AddCommand(newRelation));
Main.main.undoRedo.add(new AddCommand(getCurrentDataSet(), newRelation));
commands = generalTagAssign(newRelation, commands, stopArea);
commands = assignTag(commands, newRelation, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG);
commands = assignTag(commands, newRelation, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE);
Expand Down Expand Up @@ -484,7 +484,7 @@ protected List<Command> createSeparateBusStopNode(List<Command> commands, StopAr
{
Node newNode =new Node();
newNode.setCoor(centerOfPlatform);
Main.main.undoRedo.add(new AddCommand(newNode));
Main.main.undoRedo.add(new AddCommand(getCurrentDataSet(), newNode));
Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue));
commands = assignTag(commands, newNode, tag, tagValue);
stopArea.otherMembers.add(newNode);
Expand Down