Changeset 33811 in osm for applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru
- Timestamp:
- 2017-11-17T00:34:11+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java
r32840 r33811 19 19 import org.openstreetmap.josm.data.osm.Way; 20 20 import org.openstreetmap.josm.data.osm.WaySegment; 21 import org.openstreetmap.josm.data.projection.Projections; 21 import org.openstreetmap.josm.gui.MainApplication; 22 import org.openstreetmap.josm.gui.MapView; 22 23 import org.openstreetmap.josm.tools.Geometry; 23 24 import ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop.OSMTags;25 24 26 25 /** … … 60 59 61 60 for (Node n : ds.searchNodes(getBBox(p, 200))) { 62 if ((dist = Main .map.mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq)61 if ((dist = MainApplication.getMap().mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq) 63 62 { 64 63 List<Node> nlist; … … 84 83 */ 85 84 private BBox getBBox(Point p, int snapDistance) { 86 return new BBox(Main.map.mapView.getLatLon(p.x - snapDistance, p.y - snapDistance), 87 Main.map.mapView.getLatLon(p.x + snapDistance, p.y + snapDistance)); 85 MapView mapView = MainApplication.getMap().mapView; 86 return new BBox(mapView.getLatLon(p.x - snapDistance, p.y - snapDistance), 87 mapView.getLatLon(p.x + snapDistance, p.y + snapDistance)); 88 88 } 89 89 … … 96 96 public AbstractMap.SimpleEntry<Double, Node> getNearestNode(LatLon platformCoord, StopArea stopArea) 97 97 { 98 Point p = Main .map.mapView.getPoint(platformCoord);98 Point p = MainApplication.getMap().mapView.getPoint(platformCoord); 99 99 Map<Double, List<Node>> dist_nodes = getNearestNodesImpl(p); 100 100 Double[] distances = dist_nodes.keySet().toArray(new Double[0]); … … 196 196 197 197 if (ds != null) { 198 double snapDistanceSq = Main.pref.getInt eger("mappaint.segment.snap-distance", 200);198 double snapDistanceSq = Main.pref.getInt("mappaint.segment.snap-distance", 200); 199 199 snapDistanceSq *= snapDistanceSq; 200 200 201 for (Way w : ds.searchWays(getBBox(p, Main.pref.getInt eger("mappaint.segment.snap-distance", 200)))) {201 for (Way w : ds.searchWays(getBBox(p, Main.pref.getInt("mappaint.segment.snap-distance", 200)))) { 202 202 Node lastN = null; 203 203 int i = -2; … … 212 212 } 213 213 214 Point2D A = Main .map.mapView.getPoint2D(lastN);215 Point2D B = Main .map.mapView.getPoint2D(n);214 Point2D A = MainApplication.getMap().mapView.getPoint2D(lastN); 215 Point2D B = MainApplication.getMap().mapView.getPoint2D(n); 216 216 double c = A.distanceSq(B); 217 217 double a = p.distanceSq(B); … … 254 254 protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) 255 255 { 256 257 Point p = Main.map.mapView.getPoint(platformCoord);256 MapView mapView = MainApplication.getMap().mapView; 257 Point p = mapView.getPoint(platformCoord); 258 258 Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p); 259 259 for(Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet()) … … 267 267 268 268 EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(), 269 lastN.getEastNorth(), Projections.project(platformCoord));270 LatLon newNodePosition = Projections.inverseProject(newPosition);271 Point2D lastN2D = Main.map.mapView.getPoint2D(lastN);272 Point2D n2D = Main.map.mapView.getPoint2D(n);273 Point2D newNodePosition2D = Main.map.mapView.getPoint2D(newNodePosition);269 lastN.getEastNorth(), Main.getProjection().latlon2eastNorth(platformCoord)); 270 LatLon newNodePosition = Main.getProjection().eastNorth2latlon(newPosition); 271 Point2D lastN2D = mapView.getPoint2D(lastN); 272 Point2D n2D = mapView.getPoint2D(n); 273 Point2D newNodePosition2D = mapView.getPoint2D(newNodePosition); 274 274 Double distCurrenNodes =lastN2D.distance(n2D); 275 275 if((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes)) … … 291 291 protected Node createNodeOnWay(Node newStopNode, WaySegment waySegment) 292 292 { 293 Main.main.undoRedo.add(new AddCommand( newStopNode));293 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newStopNode)); 294 294 List<Node> wayNodes = waySegment.way.getNodes(); 295 295 wayNodes.add(waySegment.lowerIndex + 1, newStopNode); … … 321 321 if(nearestNode != null && nearestWaySegment != null) 322 322 { 323 Double segmentDist = Main.map.mapView.getPoint2D(platformCoord).distanceSq(Main.map.mapView.getPoint2D(nearestWaySegment.newNode)); 323 MapView mapView = MainApplication.getMap().mapView; 324 Double segmentDist = mapView.getPoint2D(platformCoord).distanceSq(mapView.getPoint2D(nearestWaySegment.newNode)); 324 325 Double nodeDistSq = nearestNode.getKey(); 325 326 // nodeDistSq *= nodeDistSq - 2; -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopPlugin.java
r32048 r33811 1 1 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 2 3 import org.openstreetmap.josm. Main;3 import org.openstreetmap.josm.gui.MainApplication; 4 4 import org.openstreetmap.josm.plugins.Plugin; 5 5 import org.openstreetmap.josm.plugins.PluginInformation; … … 25 25 super(info); 26 26 stopAreaCreatorAction = CustomizeStopAction.createCustomizeStopAction(); 27 Main.main.menu.toolsMenu.add(stopAreaCreatorAction); 28 System.out.println(getPluginDir()); 27 MainApplication.getMenu().toolsMenu.add(stopAreaCreatorAction); 29 28 } 30 29 -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java
r32840 r33811 19 19 import org.openstreetmap.josm.data.osm.RelationMember; 20 20 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 22 23 /** … … 274 275 newRelation.addMember(new RelationMember("", otherMember)); 275 276 } 276 Main.main.undoRedo.add(new AddCommand( newRelation));277 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 277 278 commands = generalTagAssign(newRelation, commands, stopArea); 278 279 commands = assignTag(commands, newRelation, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG); … … 485 486 Node newNode =new Node(); 486 487 newNode.setCoor(centerOfPlatform); 487 Main.main.undoRedo.add(new AddCommand( newNode));488 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newNode)); 488 489 Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue)); 489 490 commands = assignTag(commands, newNode, tag, tagValue);
Note:
See TracChangeset
for help on using the changeset viewer.