Changeset 14120 in josm
- Timestamp:
- 2018-08-11T17:29:48+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 68 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.groovy
r14119 r14120 33 33 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 34 34 import org.openstreetmap.josm.data.preferences.JosmUrls 35 import org.openstreetmap.josm.data.projection.ProjectionRegistry 35 36 import org.openstreetmap.josm.data.projection.Projections 36 37 import org.openstreetmap.josm.gui.NavigatableComponent … … 418 419 Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance()) 419 420 Config.setUrlsProvider(JosmUrls.getInstance()) 420 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"))421 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")) 421 422 Path tmpdir = Files.createTempDirectory(FileSystems.getDefault().getPath(base_dir), "pref") 422 423 tmpdir.toFile().deleteOnExit() -
trunk/src/org/openstreetmap/josm/Main.java
r14119 r14120 7 7 import java.awt.GraphicsEnvironment; 8 8 import java.io.IOException; 9 import java.lang.ref.WeakReference;10 9 import java.net.URL; 11 10 import java.nio.file.InvalidPathException; … … 16 15 import java.util.List; 17 16 import java.util.Map; 18 import java.util.Objects;19 17 import java.util.Set; 20 18 import java.util.concurrent.Callable; 21 import java.util.concurrent.CopyOnWriteArrayList;22 19 import java.util.concurrent.ExecutionException; 23 20 import java.util.concurrent.ExecutorService; … … 25 22 import java.util.concurrent.Future; 26 23 27 import org.openstreetmap.josm.data.Bounds;28 24 import org.openstreetmap.josm.data.Preferences; 29 25 import org.openstreetmap.josm.data.UndoRedoHandler; … … 38 34 import org.openstreetmap.josm.data.projection.Projection; 39 35 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 36 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 40 37 import org.openstreetmap.josm.io.FileWatcher; 41 38 import org.openstreetmap.josm.io.OnlineResource; … … 364 361 } 365 362 366 /* ----------------------------------------------------------------------------------------- */367 /* projection handling - Main is a registry for a single, global projection instance */368 /* */369 /* TODO: For historical reasons the registry is implemented by Main. An alternative approach */370 /* would be a singleton org.openstreetmap.josm.data.projection.ProjectionRegistry class. */371 /* ----------------------------------------------------------------------------------------- */372 /**373 * The projection method used.374 * Use {@link #getProjection()} and {@link #setProjection(Projection)} for access.375 * Use {@link #setProjection(Projection)} in order to trigger a projection change event.376 */377 private static volatile Projection proj;378 379 363 /** 380 364 * Replies the current projection. 381 365 * 382 366 * @return the currently active projection 383 */ 367 * @deprecated Use {@link ProjectionRegistry#getProjection} 368 */ 369 @Deprecated 384 370 public static Projection getProjection() { 385 return proj;371 return ProjectionRegistry.getProjection(); 386 372 } 387 373 … … 390 376 * 391 377 * @param p the projection 392 */ 378 * @deprecated Use {@link ProjectionRegistry#setProjection} 379 */ 380 @Deprecated 393 381 public static void setProjection(Projection p) { 394 CheckParameterUtil.ensureParameterNotNull(p); 395 Projection oldValue = proj; 396 Bounds b = main != null ? main.getRealBounds() : null; 397 proj = p; 398 fireProjectionChanged(oldValue, proj, b); 399 } 400 401 /** 402 * Returns the bounds for the current projection. Used for projection events. 403 * @return the bounds for the current projection 404 * @see #restoreOldBounds 405 */ 406 protected Bounds getRealBounds() { 407 // To be overriden 408 return null; 409 } 410 411 /** 412 * Restore clean state corresponding to old bounds after a projection change event. 413 * @param oldBounds bounds previously returned by {@link #getRealBounds}, before the change of projection 414 * @see #getRealBounds 415 */ 416 protected void restoreOldBounds(Bounds oldBounds) { 417 // To be overriden 418 } 419 420 /* 421 * Keep WeakReferences to the listeners. This relieves clients from the burden of 422 * explicitly removing the listeners and allows us to transparently register every 423 * created dataset as projection change listener. 424 */ 425 private static final List<WeakReference<ProjectionChangeListener>> listeners = new CopyOnWriteArrayList<>(); 426 427 private static void fireProjectionChanged(Projection oldValue, Projection newValue, Bounds oldBounds) { 428 if ((newValue == null ^ oldValue == null) 429 || (newValue != null && oldValue != null && !Objects.equals(newValue.toCode(), oldValue.toCode()))) { 430 listeners.removeIf(x -> x.get() == null); 431 listeners.stream().map(WeakReference::get).filter(Objects::nonNull).forEach(x -> x.projectionChanged(oldValue, newValue)); 432 if (newValue != null && oldBounds != null && main != null) { 433 main.restoreOldBounds(oldBounds); 434 } 435 /* TODO - remove layers with fixed projection */ 436 } 382 ProjectionRegistry.setProjection(p); 437 383 } 438 384 … … 442 388 * 443 389 * @param listener the listener. Ignored if <code>null</code>. 444 */ 390 * @deprecated Use {@link ProjectionRegistry#addProjectionChangeListener} 391 */ 392 @Deprecated 445 393 public static void addProjectionChangeListener(ProjectionChangeListener listener) { 446 if (listener == null) return; 447 for (WeakReference<ProjectionChangeListener> wr : listeners) { 448 // already registered ? => abort 449 if (wr.get() == listener) return; 450 } 451 listeners.add(new WeakReference<>(listener)); 394 ProjectionRegistry.addProjectionChangeListener(listener); 452 395 } 453 396 … … 456 399 * 457 400 * @param listener the listener. Ignored if <code>null</code>. 458 */ 401 * @deprecated Use {@link ProjectionRegistry#removeProjectionChangeListener} 402 */ 403 @Deprecated 459 404 public static void removeProjectionChangeListener(ProjectionChangeListener listener) { 460 if (listener == null) return; 461 // remove the listener - and any other listener which got garbage collected in the meantime 462 listeners.removeIf(wr -> wr.get() == null || wr.get() == listener); 405 ProjectionRegistry.removeProjectionChangeListener(listener); 463 406 } 464 407 … … 466 409 * Remove all projection change listeners. For testing purposes only. 467 410 * @since 13322 468 */ 411 * @deprecated Use {@link ProjectionRegistry#clearProjectionChangeListeners} 412 */ 413 @Deprecated 469 414 public static void clearProjectionChangeListeners() { 470 listeners.clear();415 ProjectionRegistry.clearProjectionChangeListeners(); 471 416 } 472 417 -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r13434 r14120 18 18 import javax.swing.JOptionPane; 19 19 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.command.AddCommand; 22 21 import org.openstreetmap.josm.command.ChangeCommand; … … 30 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 30 import org.openstreetmap.josm.data.osm.Way; 31 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 32 import org.openstreetmap.josm.gui.MainApplication; 33 33 import org.openstreetmap.josm.gui.Notification; … … 180 180 181 181 // see #10777 182 LatLon ll1 = Main.getProjection().eastNorth2latlon(n1);183 LatLon ll2 = Main.getProjection().eastNorth2latlon(center);182 LatLon ll1 = ProjectionRegistry.getProjection().eastNorth2latlon(n1); 183 LatLon ll2 = ProjectionRegistry.getProjection().eastNorth2latlon(center); 184 184 185 185 double radiusInMeters = ll1.greatCircleDistance(ll2); … … 218 218 double x = center.east() + r*Math.cos(alpha); 219 219 double y = center.north() + r*Math.sin(alpha); 220 LatLon ll = Main.getProjection().eastNorth2latlon(new EastNorth(x, y));220 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(new EastNorth(x, y)); 221 221 if (ll.isOutSideWorld()) { 222 222 notifyNodesNotOnCircle(); -
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r13867 r14120 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 27 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 28 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 28 29 import org.openstreetmap.josm.gui.ExtendedDialog; 29 30 import org.openstreetmap.josm.gui.MainApplication; … … 74 75 } 75 76 old = layer.getDisplaySettings().getOffsetBookmark(); 76 EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement( Main.getProjection());77 EastNorth curOff = old == null ? EastNorth.ZERO : old.getDisplacement(ProjectionRegistry.getProjection()); 77 78 LatLon center; 78 79 if (MainApplication.isDisplayingMapView()) { 79 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());80 center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 80 81 } else { 81 82 center = LatLon.ZERO; 82 83 } 83 84 tempOffset = new OffsetBookmark( 84 Main.getProjection().toCode(),85 ProjectionRegistry.getProjection().toCode(), 85 86 layer.getInfo().getId(), 86 87 layer.getInfo().getName(), … … 258 259 "You can also enter east and north offset in the {0} coordinates.\n" + 259 260 "If you want to save the offset as bookmark, enter the bookmark name below", 260 Main.getProjection().toString())), GBC.eop());261 ProjectionRegistry.getProjection().toString())), GBC.eop()); 261 262 pnl.add(new JLabel(tr("Offset:")), GBC.std()); 262 263 pnl.add(tOffset, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 0, 0, 5)); … … 313 314 if (layer != null) { 314 315 // Support projections with very small numbers (e.g. 4326) 315 int precision = Main.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7;316 int precision = ProjectionRegistry.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7; 316 317 // US locale to force decimal separator to be '.' 317 318 try (Formatter us = new Formatter(Locale.US)) { -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r13434 r14120 19 19 import java.util.TreeSet; 20 20 21 import org.openstreetmap.josm.Main;22 21 import org.openstreetmap.josm.command.ChangeCommand; 23 22 import org.openstreetmap.josm.command.Command; … … 30 29 import org.openstreetmap.josm.data.osm.Way; 31 30 import org.openstreetmap.josm.data.osm.WaySegment; 31 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 32 import org.openstreetmap.josm.gui.MainApplication; 33 33 import org.openstreetmap.josm.gui.MapView; … … 143 143 node.getEastNorth()); 144 144 MoveCommand c = new MoveCommand( 145 node, Main.getProjection().eastNorth2latlon(newPosition));145 node, ProjectionRegistry.getProjection().eastNorth2latlon(newPosition)); 146 146 // Avoid moving a given node several times at the same position in case of overlapping ways 147 147 if (!cmds.contains(c)) { -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r13712 r14120 30 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 31 import org.openstreetmap.josm.data.osm.Way; 32 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 33 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 33 34 import org.openstreetmap.josm.gui.MainApplication; … … 148 149 if (!isEnabled()) 149 150 return; 150 if ("EPSG:4326".equals( Main.getProjection().toString())) {151 if ("EPSG:4326".equals(ProjectionRegistry.getProjection().toString())) { 151 152 String msg = tr("<html>You are using the EPSG:4326 projection which might lead<br>" + 152 153 "to undesirable results when doing rectangular alignments.<br>" + … … 307 308 throw new InvalidUserInputException("Unable to orthogonalize " + singleNode); 308 309 } 309 return new MoveCommand(singleNode, Main.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions)));310 return new MoveCommand(singleNode, ProjectionRegistry.getProjection().eastNorth2latlon(Geometry.getCentroidEN(rightAnglePositions))); 310 311 } 311 312 -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r13437 r14120 20 20 21 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 22 23 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 23 24 import org.openstreetmap.josm.gui.MainApplication; … … 147 148 } 148 149 if (noMap && viewport != null) { 149 MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport( Main.getProjection()));150 MainApplication.getMap().mapView.scheduleZoomTo(viewport.getEastNorthViewport(ProjectionRegistry.getProjection())); 150 151 } 151 152 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r13434 r14120 29 29 import javax.swing.JMenuItem; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.actions.JosmAction; 33 32 import org.openstreetmap.josm.actions.MergeNodesAction; … … 46 45 import org.openstreetmap.josm.data.osm.WaySegment; 47 46 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 47 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 48 48 import org.openstreetmap.josm.gui.MainApplication; 49 49 import org.openstreetmap.josm.gui.MainMenu; … … 655 655 //move existing node 656 656 Node n1Old = selectedSegment.getFirstNode(); 657 cmds.add(new MoveCommand(n1Old, Main.getProjection().eastNorth2latlon(newN1en)));657 cmds.add(new MoveCommand(n1Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN1en))); 658 658 changedNodes.add(n1Old); 659 659 } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) { 660 660 // replace shared node with new one 661 661 Node n1Old = selectedSegment.getFirstNode(); 662 Node n1New = new Node( Main.getProjection().eastNorth2latlon(newN1en));662 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 663 663 wnew.addNode(insertionPoint, n1New); 664 664 wnew.removeNode(n1Old); … … 668 668 } else { 669 669 //introduce new node 670 Node n1New = new Node( Main.getProjection().eastNorth2latlon(newN1en));670 Node n1New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN1en)); 671 671 wnew.addNode(insertionPoint, n1New); 672 672 wayWasModified = true; … … 685 685 //move existing node 686 686 Node n2Old = selectedSegment.getSecondNode(); 687 cmds.add(new MoveCommand(n2Old, Main.getProjection().eastNorth2latlon(newN2en)));687 cmds.add(new MoveCommand(n2Old, ProjectionRegistry.getProjection().eastNorth2latlon(newN2en))); 688 688 changedNodes.add(n2Old); 689 689 } else if (ignoreSharedNodes && segmentAngleZero && !alwaysCreateNodes && hasOtherWays) { 690 690 // replace shared node with new one 691 691 Node n2Old = selectedSegment.getSecondNode(); 692 Node n2New = new Node( Main.getProjection().eastNorth2latlon(newN2en));692 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 693 693 wnew.addNode(insertionPoint, n2New); 694 694 wnew.removeNode(n2Old); … … 698 698 } else { 699 699 //introduce new node 700 Node n2New = new Node( Main.getProjection().eastNorth2latlon(newN2en));700 Node n2New = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(newN2en)); 701 701 wnew.addNode(insertionPoint, n2New); 702 702 wayWasModified = true; … … 937 937 938 938 // find out the movement distance, in metres 939 double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance(940 Main.getProjection().eastNorth2latlon(n1movedEn));939 double distance = ProjectionRegistry.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance( 940 ProjectionRegistry.getProjection().eastNorth2latlon(n1movedEn)); 941 941 MainApplication.getMap().statusLine.setDist(distance); 942 942 updateStatusLine(); -
trunk/src/org/openstreetmap/josm/command/MoveCommand.java
r12778 r14120 14 14 import javax.swing.Icon; 15 15 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.data.coor.EastNorth; 18 17 import org.openstreetmap.josm.data.coor.LatLon; … … 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 21 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 23 23 import org.openstreetmap.josm.tools.ImageProvider; 24 24 … … 73 73 public MoveCommand(Node node, LatLon position) { 74 74 this(Collections.singleton((OsmPrimitive) node), 75 Main.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth()));75 ProjectionRegistry.getProjection().latlon2eastNorth(position).subtract(node.getEastNorth())); 76 76 } 77 77 -
trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java
r12161 r14120 4 4 import java.util.Objects; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.projection.Projecting; 8 7 import org.openstreetmap.josm.data.projection.Projection; 8 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 9 9 10 10 /** … … 46 46 */ 47 47 public CachedLatLon(EastNorth eastNorth) { 48 this(eastNorth, Main.getProjection());48 this(eastNorth, ProjectionRegistry.getProjection()); 49 49 } 50 50 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r14091 r14120 17 17 import java.util.Objects; 18 18 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.data.Bounds; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.tools.Logging; 22 22 import org.openstreetmap.josm.tools.Utils; … … 195 195 */ 196 196 public boolean isOutSideWorld() { 197 Bounds b = Main.getProjection().getWorldBoundsLatLon();197 Bounds b = ProjectionRegistry.getProjection().getWorldBoundsLatLon(); 198 198 return lat() < b.getMinLat() || lat() > b.getMaxLat() || 199 199 lon() < b.getMinLon() || lon() > b.getMaxLon(); -
trunk/src/org/openstreetmap/josm/data/coor/conversion/ProjectedCoordinateFormat.java
r12741 r14120 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.coor.ILatLon; 7 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 8 9 9 /** … … 25 25 @Override 26 26 public String latToString(ILatLon ll) { 27 return cDdFormatter.format(ll.getEastNorth( Main.getProjection()).north());27 return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).north()); 28 28 } 29 29 30 30 @Override 31 31 public String lonToString(ILatLon ll) { 32 return cDdFormatter.format(ll.getEastNorth( Main.getProjection()).east());32 return cDdFormatter.format(ll.getEastNorth(ProjectionRegistry.getProjection()).east()); 33 33 } 34 34 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r13257 r14120 20 20 import java.util.stream.Stream; 21 21 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.data.Bounds; 24 23 import org.openstreetmap.josm.data.Data; … … 26 25 import org.openstreetmap.josm.data.coor.EastNorth; 27 26 import org.openstreetmap.josm.data.gpx.GpxTrack.GpxTrackChangeListener; 27 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 28 28 import org.openstreetmap.josm.gui.MainApplication; 29 29 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 539 539 WayPoint r = null; 540 540 for (WayPoint wpSeg : seg.getWayPoints()) { 541 EastNorth en = wpSeg.getEastNorth( Main.getProjection());541 EastNorth en = wpSeg.getEastNorth(ProjectionRegistry.getProjection()); 542 542 if (r == null) { 543 543 r = wpSeg; … … 586 586 } 587 587 if (r != null) { 588 EastNorth c = r.getEastNorth( Main.getProjection());588 EastNorth c = r.getEastNorth(ProjectionRegistry.getProjection()); 589 589 /* if there is only one point in the seg, it will do this twice, but no matter */ 590 590 rx = c.east(); … … 603 603 if (bestEN == null) 604 604 return null; 605 WayPoint best = new WayPoint( Main.getProjection().eastNorth2latlon(bestEN));605 WayPoint best = new WayPoint(ProjectionRegistry.getProjection().eastNorth2latlon(bestEN)); 606 606 best.time = bestTime; 607 607 return best; -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r13798 r14120 10 10 import java.util.stream.Collectors; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.StructUtils; 14 13 import org.openstreetmap.josm.data.StructUtils.StructEntry; … … 18 17 import org.openstreetmap.josm.data.coor.LatLon; 19 18 import org.openstreetmap.josm.data.projection.Projection; 19 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 20 20 import org.openstreetmap.josm.data.projection.Projections; 21 21 import org.openstreetmap.josm.gui.MainApplication; … … 49 49 public boolean isUsable(ImageryLayer layer) { 50 50 if (projection_code == null) return false; 51 if (! Main.getProjection().toCode().equals(projection_code) && !hasCenter()) return false;51 if (!ProjectionRegistry.getProjection().toCode().equals(projection_code) && !hasCenter()) return false; 52 52 ImageryInfo info = layer.getInfo(); 53 53 return imagery_id != null ? Objects.equals(info.getId(), imagery_id) : Objects.equals(info.getName(), imagery_name); … … 363 363 LatLon center; 364 364 if (MainApplication.isDisplayingMapView()) { 365 center = Main.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter());365 center = ProjectionRegistry.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 366 366 } else { 367 367 center = LatLon.ZERO; 368 368 } 369 369 OffsetBookmark nb = new OffsetBookmark( 370 Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(),370 ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), 371 371 name, layer.getDisplaySettings().getDisplacement(), center); 372 372 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) { -
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r13733 r14120 16 16 17 17 import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource; 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.coor.EastNorth; 20 19 import org.openstreetmap.josm.data.projection.Projection; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.gui.layer.WMSLayer; 22 22 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 108 108 } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) { 109 109 // assume WMS 1.3.0 110 switchLatLon = Main.getProjection().switchXY();110 switchLatLon = ProjectionRegistry.getProjection().switchXY(); 111 111 } 112 112 String bbox = getBbox(zoom, tilex, tiley, switchLatLon); -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r13879 r14120 50 50 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 51 51 import org.openstreetmap.josm.data.projection.Projection; 52 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 52 53 import org.openstreetmap.josm.data.projection.Projections; 53 54 import org.openstreetmap.josm.gui.ExtendedDialog; … … 346 347 List<Layer> ls = layerById.entrySet().iterator().next().getValue() 347 348 .stream().filter( 348 u -> u.tileMatrixSet.crs.equals( Main.getProjection().toCode()))349 u -> u.tileMatrixSet.crs.equals(ProjectionRegistry.getProjection().toCode())) 349 350 .collect(Collectors.toList()); 350 351 if (ls.size() == 1) { … … 631 632 private static TileMatrix parseTileMatrix(XMLStreamReader reader, String matrixCrs) throws XMLStreamException { 632 633 Projection matrixProj = Optional.ofNullable(Projections.getProjectionByCode(matrixCrs)) 633 .orElseGet( Main::getProjection); // use current projection if none found. Maybe user is using custom string634 .orElseGet(ProjectionRegistry::getProjection); // use current projection if none found. Maybe user is using custom string 634 635 TileMatrix ret = new TileMatrix(); 635 636 for (int event = reader.getEventType(); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r14119 r14120 25 25 import java.util.stream.Stream; 26 26 27 import org.openstreetmap.josm.Main;28 27 import org.openstreetmap.josm.data.APIDataSet.APIOperation; 29 28 import org.openstreetmap.josm.data.Bounds; … … 54 53 import org.openstreetmap.josm.data.projection.Projection; 55 54 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 55 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 56 56 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 57 57 import org.openstreetmap.josm.spi.preferences.Config; … … 175 175 // Transparently register as projection change listener. No need to explicitly remove 176 176 // the listener, projection change listeners are managed as WeakReferences. 177 Main.addProjectionChangeListener(this);177 ProjectionRegistry.addProjectionChangeListener(this); 178 178 addSelectionListener((DataSelectionListener) e -> fireSelectionChange(e.getSelection())); 179 179 } … … 1045 1045 */ 1046 1046 public void invalidateEastNorthCache() { 1047 if ( Main.getProjection() == null)1047 if (ProjectionRegistry.getProjection() == null) 1048 1048 return; // sanity check 1049 1049 beginUpdate(); -
trunk/src/org/openstreetmap/josm/data/osm/INode.java
r13669 r14120 6 6 import org.openstreetmap.josm.data.coor.ILatLon; 7 7 import org.openstreetmap.josm.data.coor.LatLon; 8 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 9 9 10 /** … … 34 35 */ 35 36 default EastNorth getEastNorth() { 36 return getEastNorth( Main.getProjection());37 return getEastNorth(ProjectionRegistry.getProjection()); 37 38 } 38 39 -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r13669 r14120 10 10 import java.util.function.Predicate; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.coor.EastNorth; 14 13 import org.openstreetmap.josm.data.coor.LatLon; … … 16 15 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 17 16 import org.openstreetmap.josm.data.projection.Projecting; 17 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 18 18 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 19 import org.openstreetmap.josm.tools.Utils; … … 114 114 invalidateEastNorthCache(); 115 115 } else if (eastNorth != null) { 116 LatLon ll = Main.getProjection().eastNorth2latlon(eastNorth);116 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth); 117 117 this.lat = ll.lat(); 118 118 this.lon = ll.lon(); 119 119 this.east = eastNorth.east(); 120 120 this.north = eastNorth.north(); 121 this.eastNorthCacheKey = Main.getProjection().getCacheKey();121 this.eastNorthCacheKey = ProjectionRegistry.getProjection().getCacheKey(); 122 122 } else { 123 123 this.lat = Double.NaN; -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r13764 r14120 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.Main;5 4 import org.openstreetmap.josm.data.coor.EastNorth; 6 5 import org.openstreetmap.josm.data.coor.LatLon; 7 6 import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; 7 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 8 8 9 9 /** … … 77 77 @Override 78 78 public void setEastNorth(EastNorth eastNorth) { 79 setCoor( Main.getProjection().eastNorth2latlon(eastNorth));79 setCoor(ProjectionRegistry.getProjection().eastNorth2latlon(eastNorth)); 80 80 } 81 81 -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r14098 r14120 23 23 import java.util.stream.Collectors; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.data.Bounds; 27 26 import org.openstreetmap.josm.data.coor.LatLon; … … 36 35 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Range; 37 36 import org.openstreetmap.josm.data.osm.search.PushbackTokenizer.Token; 37 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 38 38 import org.openstreetmap.josm.gui.mappaint.Environment; 39 39 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; … … 1895 1895 protected Collection<Bounds> getBounds(OsmPrimitive primitive) { 1896 1896 final Collection<Bounds> bounds = super.getBounds(primitive); 1897 return bounds == null || bounds.isEmpty() ? Collections.singleton(Main.getProjection().getWorldBoundsLatLon()) : bounds; 1897 return bounds == null || bounds.isEmpty() ? 1898 Collections.singleton(ProjectionRegistry.getProjection().getWorldBoundsLatLon()) : bounds; 1898 1899 } 1899 1900 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r13906 r14120 4 4 import java.util.Collection; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.Bounds; 8 7 import org.openstreetmap.josm.data.ProjectionBounds; … … 19 18 import org.openstreetmap.josm.data.osm.Relation; 20 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.gui.MainApplication; 22 22 import org.openstreetmap.josm.gui.MapFrame; … … 76 76 public void visit(Bounds b) { 77 77 if (b != null) { 78 Main.getProjection().visitOutline(b, this::visit);78 ProjectionRegistry.getProjection().visitOutline(b, this::visit); 79 79 } 80 80 } … … 98 98 public void visit(ILatLon latlon) { 99 99 if (latlon != null) { 100 visit(latlon.getEastNorth( Main.getProjection()));100 visit(latlon.getEastNorth(ProjectionRegistry.getProjection())); 101 101 } 102 102 } … … 159 159 if (bounds == null) 160 160 return; 161 LatLon minLatlon = Main.getProjection().eastNorth2latlon(bounds.getMin());162 LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax());161 LatLon minLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMin()); 162 LatLon maxLatlon = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMax()); 163 163 bounds = new ProjectionBounds(new LatLon( 164 164 Math.max(-90, minLatlon.lat() - enlargeDegree), 165 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth( Main.getProjection()),165 Math.max(-180, minLatlon.lon() - enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection()), 166 166 new LatLon( 167 167 Math.min(90, maxLatlon.lat() + enlargeDegree), 168 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth( Main.getProjection()));168 Math.min(180, maxLatlon.lon() + enlargeDegree)).getEastNorth(ProjectionRegistry.getProjection())); 169 169 } 170 170 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java
r14000 r14120 9 9 import java.util.concurrent.ConcurrentHashMap; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.DataSelectionListener; 13 12 import org.openstreetmap.josm.data.osm.DataSet; … … 29 28 import org.openstreetmap.josm.data.projection.Projection; 30 29 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.gui.MainApplication; 32 32 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; … … 49 49 50 50 private MultipolygonCache() { 51 Main.addProjectionChangeListener(this);51 ProjectionRegistry.addProjectionChangeListener(this); 52 52 SelectionEventManager.getInstance().addSelectionListener(this); 53 53 MainApplication.getLayerManager().addLayerChangeListener(this); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r13672 r14120 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 33 34 import org.openstreetmap.josm.data.validation.tests.Addresses; 34 35 import org.openstreetmap.josm.data.validation.tests.ApiCapabilitiesTest; … … 352 353 */ 353 354 public static void initializeGridDetail() { 354 String code = Main.getProjection().toCode();355 String code = ProjectionRegistry.getProjection().toCode(); 355 356 if (Arrays.asList(ProjectionPreference.wgs84.allCodes()).contains(code)) { 356 357 OsmValidator.griddetail = 10_000; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14119 r14120 102 102 import org.openstreetmap.josm.data.preferences.JosmUrls; 103 103 import org.openstreetmap.josm.data.preferences.sources.SourceType; 104 import org.openstreetmap.josm.data.projection.ProjectionBoundsProvider; 104 105 import org.openstreetmap.josm.data.projection.ProjectionCLI; 106 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 105 107 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileSource; 106 108 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; … … 258 260 }; 259 261 262 private static final ProjectionBoundsProvider mainBoundsProvider = new ProjectionBoundsProvider() { 263 @Override 264 public Bounds getRealBounds() { 265 return isDisplayingMapView() ? map.mapView.getRealBounds() : null; 266 } 267 268 @Override 269 public void restoreOldBounds(Bounds oldBounds) { 270 if (isDisplayingMapView()) { 271 map.mapView.zoomTo(oldBounds); 272 } 273 } 274 }; 275 260 276 private static final List<CLIModule> cliModules = new ArrayList<>(); 261 277 … … 341 357 undoRedo = super.undoRedo; 342 358 getLayerManager().addLayerChangeListener(undoRedoCleaner); 359 ProjectionRegistry.setboundsProvider(mainBoundsProvider); 343 360 } 344 361 … … 511 528 } catch (SecurityException e) { 512 529 Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e); 513 }514 }515 516 @Override517 protected Bounds getRealBounds() {518 return isDisplayingMapView() ? map.mapView.getRealBounds() : null;519 }520 521 @Override522 protected void restoreOldBounds(Bounds oldBounds) {523 if (isDisplayingMapView()) {524 map.mapView.zoomTo(oldBounds);525 530 } 526 531 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r13890 r14120 37 37 import javax.swing.SwingUtilities; 38 38 39 import org.openstreetmap.josm.Main;40 39 import org.openstreetmap.josm.actions.mapmode.MapMode; 41 40 import org.openstreetmap.josm.data.Bounds; … … 48 47 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 49 48 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 49 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 50 50 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; 51 51 import org.openstreetmap.josm.gui.autofilter.AutoFilterManager; … … 358 358 359 359 layer.addPropertyChangeListener(this); 360 Main.addProjectionChangeListener(layer);360 ProjectionRegistry.addProjectionChangeListener(layer); 361 361 invalidatedListener.addTo(layer); 362 362 AudioPlayer.reset(); … … 398 398 } 399 399 painter.detachFromMapView(new MapViewEvent(this, false)); 400 Main.removeProjectionChangeListener(layer);400 ProjectionRegistry.removeProjectionChangeListener(layer); 401 401 layer.removePropertyChangeListener(this); 402 402 invalidatedListener.removeFrom(layer); -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r14052 r14120 16 16 import javax.swing.JComponent; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.Bounds; 20 19 import org.openstreetmap.josm.data.ProjectionBounds; … … 25 24 import org.openstreetmap.josm.data.projection.Projecting; 26 25 import org.openstreetmap.josm.data.projection.Projection; 26 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 27 27 import org.openstreetmap.josm.gui.download.DownloadDialog; 28 28 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 394 394 */ 395 395 public static MapViewState createDefaultState(int width, int height) { 396 Projection projection = Main.getProjection();396 Projection projection = ProjectionRegistry.getProjection(); 397 397 double scale = projection.getDefaultZoomInPPD(); 398 398 MapViewState state = new MapViewState(projection, width, height, scale, new EastNorth(0, 0)); … … 403 403 private static EastNorth calculateDefaultCenter() { 404 404 Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet( 405 () -> Main.getProjection().getWorldBoundsLatLon());406 return b.getCenter().getEastNorth( Main.getProjection());405 () -> ProjectionRegistry.getProjection().getWorldBoundsLatLon()); 406 return b.getCenter().getEastNorth(ProjectionRegistry.getProjection()); 407 407 } 408 408 -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r14052 r14120 32 32 import javax.swing.SwingUtilities; 33 33 34 import org.openstreetmap.josm.Main;35 34 import org.openstreetmap.josm.data.Bounds; 36 35 import org.openstreetmap.josm.data.ProjectionBounds; … … 53 52 import org.openstreetmap.josm.data.projection.Projection; 54 53 import org.openstreetmap.josm.data.projection.ProjectionChangeListener; 54 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 55 55 import org.openstreetmap.josm.gui.help.Helpful; 56 56 import org.openstreetmap.josm.gui.layer.NativeScaleLayer; … … 188 188 setLayout(null); 189 189 state = MapViewState.createDefaultState(getWidth(), getHeight()); 190 Main.addProjectionChangeListener(projectionChangeListener);190 ProjectionRegistry.addProjectionChangeListener(projectionChangeListener); 191 191 } 192 192 … … 334 334 */ 335 335 public void fixProjection() { 336 state = state.usingProjection( Main.getProjection());336 state = state.usingProjection(ProjectionRegistry.getProjection()); 337 337 repaint(); 338 338 } … … 492 492 */ 493 493 public Bounds getLatLonBounds(Rectangle r) { 494 return Main.getProjection().getLatLonBoundsBox(getProjectionBounds(r));494 return ProjectionRegistry.getProjection().getLatLonBoundsBox(getProjectionBounds(r)); 495 495 } 496 496 … … 525 525 return new Point(); 526 526 } else { 527 return getPoint2D(latlon.getEastNorth( Main.getProjection()));527 return getPoint2D(latlon.getEastNorth(ProjectionRegistry.getProjection())); 528 528 } 529 529 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
r13907 r14120 23 23 import org.openstreetmap.josm.data.osm.RelationMemberData; 24 24 import org.openstreetmap.josm.data.osm.WayData; 25 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 25 26 import org.openstreetmap.josm.gui.ExtendedDialog; 26 27 import org.openstreetmap.josm.gui.MainApplication; … … 73 74 if (data instanceof NodeData) { 74 75 NodeData nodeData = (NodeData) data; 75 nodeData.setEastNorth(nodeData.getEastNorth( Main.getProjection()).add(offset));76 nodeData.setEastNorth(nodeData.getEastNorth(ProjectionRegistry.getProjection()).add(offset)); 76 77 } else if (data instanceof WayData) { 77 78 updateNodes(newIds.get(OsmPrimitiveType.NODE), data); -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java
r13953 r14120 8 8 import java.util.List; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.conflict.Conflict; 12 11 import org.openstreetmap.josm.data.coor.EastNorth; … … 22 21 import org.openstreetmap.josm.data.osm.OsmData; 23 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 24 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 25 25 import org.openstreetmap.josm.data.projection.proj.TransverseMercator.Hemisphere; … … 171 171 addBbox(o); 172 172 add(tr("Centroid: "), 173 toStringCSV(", ", Main.getProjection().eastNorth2latlon(173 toStringCSV(", ", ProjectionRegistry.getProjection().eastNorth2latlon( 174 174 Geometry.getCentroid(((IWay<?>) o).getNodes())))); 175 175 addWayNodes((IWay<?>) o); … … 203 203 if (bbox != null) { 204 204 add(tr("Bounding box: "), bbox.toStringCSV(", ")); 205 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth( Main.getProjection());206 EastNorth topLeft = bbox.getTopLeft().getEastNorth( Main.getProjection());205 EastNorth bottomRigth = bbox.getBottomRight().getEastNorth(ProjectionRegistry.getProjection()); 206 EastNorth topLeft = bbox.getTopLeft().getEastNorth(ProjectionRegistry.getProjection()); 207 207 add(tr("Bounding box (projected): "), 208 208 Double.toString(topLeft.east()), ", ", -
trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
r13050 r14120 23 23 import javax.swing.event.DocumentListener; 24 24 25 import org.openstreetmap.josm.Main;26 25 import org.openstreetmap.josm.data.coor.EastNorth; 27 26 import org.openstreetmap.josm.data.coor.LatLon; 28 27 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 29 28 import org.openstreetmap.josm.data.coor.conversion.LatLonParser; 29 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 30 30 import org.openstreetmap.josm.gui.ExtendedDialog; 31 31 import org.openstreetmap.josm.gui.util.WindowGeometry; … … 196 196 tfLatLon.setText(CoordinateFormatManager.getDefaultFormat().latToString(llc) + ' ' + 197 197 CoordinateFormatManager.getDefaultFormat().lonToString(llc)); 198 EastNorth en = Main.getProjection().latlon2eastNorth(llc);198 EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(llc); 199 199 tfEastNorth.setText(Double.toString(en.east()) + ' ' + Double.toString(en.north())); 200 200 // Both latLonCoordinates and eastNorthCoordinates may have been reset to null if ll is out of the world … … 213 213 } else { 214 214 if (eastNorthCoordinates == null) return null; 215 return Main.getProjection().eastNorth2latlon(eastNorthCoordinates);215 return ProjectionRegistry.getProjection().eastNorth2latlon(eastNorthCoordinates); 216 216 } 217 217 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r13967 r14120 91 91 import org.openstreetmap.josm.data.preferences.IntegerProperty; 92 92 import org.openstreetmap.josm.data.projection.Projection; 93 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 93 94 import org.openstreetmap.josm.data.projection.Projections; 94 95 import org.openstreetmap.josm.gui.ExtendedDialog; … … 328 329 if (coordinateConverter.requiresReprojection()) { 329 330 content.add(Arrays.asList(tr("Tile download projection"), tileSource.getServerCRS())); 330 content.add(Arrays.asList(tr("Tile display projection"), Main.getProjection().toCode()));331 content.add(Arrays.asList(tr("Tile display projection"), ProjectionRegistry.getProjection().toCode())); 331 332 } 332 333 content.add(Arrays.asList(tr("Current zoom"), Integer.toString(currentZoomLevel))); … … 449 450 content.add(Arrays.asList(tr("Reprojection"), 450 451 tile.getTileSource().getServerCRS() + 451 " -> " + Main.getProjection().toCode()));452 " -> " + ProjectionRegistry.getProjection().toCode())); 452 453 BufferedImage img = tile.getImage(); 453 454 if (img != null) { … … 566 567 } 567 568 // check if projection is supported 568 projectionChanged(null, Main.getProjection());569 projectionChanged(null, ProjectionRegistry.getProjection()); 569 570 initTileSource(this.tileSource); 570 571 } … … 1412 1413 CoordinateConversion.projToEn(topLeftUnshifted), 1413 1414 CoordinateConversion.projToEn(botRightUnshifted)); 1414 ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, Main.getProjection());1415 ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, ProjectionRegistry.getProjection()); 1415 1416 t1 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMin()), zoom); 1416 1417 t2 = tileSource.projectedToTileXY(CoordinateConversion.enToProj(bbox.getMax()), zoom); … … 1962 1963 @Override 1963 1964 public boolean isActive() { 1964 EastNorth offset = bookmark.getDisplacement( Main.getProjection());1965 EastNorth offset = bookmark.getDisplacement(ProjectionRegistry.getProjection()); 1965 1966 EastNorth active = getDisplaySettings().getDisplacement(); 1966 1967 return Utils.equalsEpsilon(offset.east(), active.east()) && Utils.equalsEpsilon(offset.north(), active.north()); -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r13967 r14120 29 29 import javax.swing.JTextField; 30 30 31 import org.openstreetmap.josm.Main;32 31 import org.openstreetmap.josm.data.ProjectionBounds; 33 32 import org.openstreetmap.josm.data.imagery.ImageryInfo; 34 33 import org.openstreetmap.josm.data.preferences.IntegerProperty; 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 35 35 import org.openstreetmap.josm.gui.MainApplication; 36 36 import org.openstreetmap.josm.gui.MapView; … … 85 85 public double getPPD() { 86 86 if (!MainApplication.isDisplayingMapView()) 87 return Main.getProjection().getDefaultZoomInPPD();87 return ProjectionRegistry.getProjection().getDefaultZoomInPPD(); 88 88 MapView mapView = MainApplication.getMap().mapView; 89 89 ProjectionBounds bounds = mapView.getProjectionBounds(); -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r13742 r14120 16 16 import org.apache.commons.jcs.access.CacheAccess; 17 17 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 20 19 import org.openstreetmap.josm.data.coor.LatLon; … … 29 28 import org.openstreetmap.josm.data.preferences.IntegerProperty; 30 29 import org.openstreetmap.josm.data.projection.Projection; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.data.projection.Projections; 32 32 import org.openstreetmap.josm.gui.MainApplication; … … 96 96 AbstractWMSTileSource tileSource; 97 97 if (info.getImageryType() == ImageryType.WMS) { 98 tileSource = new TemplatedWMSTileSource(info, chooseProjection( Main.getProjection()));98 tileSource = new TemplatedWMSTileSource(info, chooseProjection(ProjectionRegistry.getProjection())); 99 99 } else { 100 100 /* … … 107 107 * * we always use current definitions returned by server 108 108 */ 109 WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, Main.getProjection());109 WMSEndpointTileSource endpointTileSource = new WMSEndpointTileSource(info, ProjectionRegistry.getProjection()); 110 110 this.serverProjections = endpointTileSource.getServerProjections(); 111 endpointTileSource.setTileProjection(chooseProjection( Main.getProjection()));111 endpointTileSource.setTileProjection(chooseProjection(ProjectionRegistry.getProjection())); 112 112 tileSource = endpointTileSource; 113 113 } … … 182 182 Logging.info(tr("Reprojecting layer {0} from {1} to {2}. For best image quality and performance," 183 183 + " switch to one of the supported projections: {3}", 184 getName(), proj.toCode(), Main.getProjection().toCode(), Utils.join(", ", getNativeProjections())));184 getName(), proj.toCode(), ProjectionRegistry.getProjection().toCode(), Utils.join(", ", getNativeProjections()))); 185 185 return proj; 186 186 } -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r13733 r14120 7 7 import org.apache.commons.jcs.access.CacheAccess; 8 8 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry; 11 10 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 15 14 import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException; 16 15 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 17 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; … … 81 81 double displayScale = MainApplication.getMap().mapView.getScale(); 82 82 if (coordinateConverter.requiresReprojection()) { 83 displayScale *= Main.getProjection().getMetersPerUnit();83 displayScale *= ProjectionRegistry.getProjection().getMetersPerUnit(); 84 84 } 85 85 Scale snap = scaleList.getSnapScale(displayScale, false); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r13130 r14120 25 25 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 26 26 import org.openstreetmap.josm.data.gpx.WayPoint; 27 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 27 28 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 28 29 import org.openstreetmap.josm.gui.MainApplication; … … 189 190 continue; 190 191 } 191 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth( Main.getProjection()), snapDistance);192 WayPoint wNear = layer.data.nearestPointOnTrack(w.getEastNorth(ProjectionRegistry.getProjection()), snapDistance); 192 193 if (wNear != null) { 193 194 WayPoint wc = new WayPoint(w.getCoor()); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r12846 r14120 8 8 import org.openstreetmap.gui.jmapviewer.Tile; 9 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.ProjectionBounds; 12 11 import org.openstreetmap.josm.data.coor.EastNorth; 13 12 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 14 13 import org.openstreetmap.josm.data.projection.Projection; 14 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 15 15 import org.openstreetmap.josm.data.projection.Projections; 16 16 import org.openstreetmap.josm.gui.MainApplication; … … 122 122 } 123 123 124 Projection projCurrent = Main.getProjection();124 Projection projCurrent = ProjectionRegistry.getProjection(); 125 125 Projection projServer = Projections.getProjectionByCode(source.getServerCRS()); 126 126 EastNorth en00Server = tileToEastNorth(xtile, ytile, zoom); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java
r13387 r14120 14 14 import org.openstreetmap.gui.jmapviewer.interfaces.IProjected; 15 15 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.data.coor.EastNorth; 18 17 import org.openstreetmap.josm.data.coor.LatLon; 19 18 import org.openstreetmap.josm.data.imagery.CoordinateConversion; 20 19 import org.openstreetmap.josm.data.projection.Projecting; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.data.projection.ShiftedProjecting; 22 22 import org.openstreetmap.josm.gui.MapView; … … 202 202 */ 203 203 public boolean requiresReprojection() { 204 return !Objects.equals(tileSource.getServerCRS(), Main.getProjection().toCode());204 return !Objects.equals(tileSource.getServerCRS(), ProjectionRegistry.getProjection().toCode()); 205 205 } 206 206 } -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
r13244 r14120 7 7 8 8 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.coor.EastNorth; 11 10 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 12 11 import org.openstreetmap.josm.data.preferences.BooleanProperty; 12 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 13 13 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 14 14 import org.openstreetmap.josm.io.session.SessionAwareReadApply; … … 206 206 setDisplacement(EastNorth.ZERO); 207 207 } else { 208 setDisplacement(offsetBookmark.getDisplacement( Main.getProjection()));208 setDisplacement(offsetBookmark.getDisplacement(ProjectionRegistry.getProjection())); 209 209 } 210 210 } -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r13281 r14120 22 22 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 23 23 import org.openstreetmap.josm.data.gpx.WayPoint; 24 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.MapFrame; … … 215 216 for (Marker m : recent.parentLayer.data) { 216 217 if (m instanceof AudioMarker) { 217 double distanceSquared = m.getEastNorth( Main.getProjection()).distanceSq(en);218 double distanceSquared = m.getEastNorth(ProjectionRegistry.getProjection()).distanceSq(en); 218 219 if (distanceSquared < closestAudioMarkerDistanceSquared) { 219 220 ca = (AudioMarker) m; … … 348 349 return; 349 350 setEastNorth(w2 == null ? 350 w1.getEastNorth( Main.getProjection()) :351 w1.getEastNorth( Main.getProjection()).interpolate(w2.getEastNorth(Main.getProjection()),351 w1.getEastNorth(ProjectionRegistry.getProjection()) : 352 w1.getEastNorth(ProjectionRegistry.getProjection()).interpolate(w2.getEastNorth(ProjectionRegistry.getProjection()), 352 353 (audioTime - w1.time)/(w2.time - w1.time))); 353 354 time = audioTime; -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingCLI.java
r14119 r14120 21 21 22 22 import org.openstreetmap.gui.jmapviewer.OsmMercator; 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.cli.CLIModule; 25 24 import org.openstreetmap.josm.data.Bounds; … … 32 31 import org.openstreetmap.josm.data.preferences.JosmUrls; 33 32 import org.openstreetmap.josm.data.projection.Projection; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 34 34 import org.openstreetmap.josm.data.projection.Projections; 35 35 import org.openstreetmap.josm.gui.mappaint.RenderingHelper.StyleData; … … 427 427 Config.getPref().putBoolean("mappaint.auto_reload_local_styles", false); // unnecessary to listen for external changes 428 428 String projCode = Optional.ofNullable(argProjection).orElse("epsg:3857"); 429 Main.setProjection(Projections.getProjectionByCode(projCode.toUpperCase(Locale.US)));429 ProjectionRegistry.setProjection(Projections.getProjectionByCode(projCode.toUpperCase(Locale.US))); 430 430 431 431 RightAndLefthandTraffic.initialize(); … … 449 449 RenderingArea determineRenderingArea(DataSet ds) { 450 450 451 Projection proj = Main.getProjection();451 Projection proj = ProjectionRegistry.getProjection(); 452 452 Double scale = null; // scale in east-north units per pixel 453 453 if (argZoom != null) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java
r12966 r14120 16 16 import java.util.Optional; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.Bounds; 20 19 import org.openstreetmap.josm.data.ProjectionBounds; … … 22 21 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 23 22 import org.openstreetmap.josm.data.projection.Projection; 23 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 24 24 import org.openstreetmap.josm.gui.NavigatableComponent; 25 25 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; … … 65 65 this.scale = scale; 66 66 this.styles = styles; 67 Projection proj = Main.getProjection();67 Projection proj = ProjectionRegistry.getProjection(); 68 68 projBounds = new ProjectionBounds(); 69 69 projBounds.extend(proj.latlon2eastNorth(bounds.getMin())); -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r14119 r14120 62 62 import org.openstreetmap.josm.data.imagery.Shape; 63 63 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 64 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 64 65 import org.openstreetmap.josm.gui.MainApplication; 65 66 import org.openstreetmap.josm.gui.download.DownloadDialog; … … 856 857 JButton add = new JButton(tr("Add")); 857 858 buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0)); 858 add.addActionListener(e -> model.addRow(new OffsetBookmark( Main.getProjection().toCode(), "", "", "", 0, 0)));859 add.addActionListener(e -> model.addRow(new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), "", "", "", 0, 0))); 859 860 860 861 JButton delete = new JButton(tr("Delete")); -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r14005 r14120 32 32 import org.openstreetmap.josm.data.projection.CustomProjection; 33 33 import org.openstreetmap.josm.data.projection.Projection; 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 34 35 import org.openstreetmap.josm.data.projection.Projections; 35 36 import org.openstreetmap.josm.gui.ExtendedDialog; … … 493 494 pc.setPreferences(pref); 494 495 Projection proj = pc.getProjection(); 495 Main.setProjection(proj);496 ProjectionRegistry.setProjection(proj); 496 497 } 497 498 -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r13901 r14120 26 26 import javax.xml.transform.stream.StreamResult; 27 27 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.data.coor.EastNorth; 30 29 import org.openstreetmap.josm.data.coor.LatLon; 30 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 31 31 import org.openstreetmap.josm.gui.MainApplication; 32 32 import org.openstreetmap.josm.gui.MapView; … … 264 264 MapView mapView = MainApplication.getMap().mapView; 265 265 EastNorth center = mapView.getCenter(); 266 LatLon centerLL = Main.getProjection().eastNorth2latlon(center);266 LatLon centerLL = ProjectionRegistry.getProjection().eastNorth2latlon(center); 267 267 centerEl.setAttribute("lat", Double.toString(centerLL.lat())); 268 268 centerEl.setAttribute("lon", Double.toString(centerLL.lon())); … … 293 293 } 294 294 } 295 String code = Main.getProjection().toCode();295 String code = ProjectionRegistry.getProjection().toCode(); 296 296 if (code != null) { 297 297 Element codeEl = doc.createElement("code"); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r13807 r14120 37 37 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 38 38 import org.openstreetmap.josm.data.projection.Projection; 39 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 39 40 import org.openstreetmap.josm.data.projection.Projections; 40 41 … … 164 165 } 165 166 166 Node newNode = new Node( Main.getProjection().eastNorth2latlon(intersection));167 Node newNode = new Node(ProjectionRegistry.getProjection().eastNorth2latlon(intersection)); 167 168 Node intNode = newNode; 168 169 boolean insertInSeg1 = false; … … 1053 1054 double area = 0; 1054 1055 double perimeter = 0; 1055 Projection useProjection = projection == null ? Main.getProjection() : projection;1056 Projection useProjection = projection == null ? ProjectionRegistry.getProjection() : projection; 1056 1057 1057 1058 if (!nodes.isEmpty()) { -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTestFT.java
r9546 r14120 6 6 import javax.swing.JFrame; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.conflict.Conflict; 10 9 import org.openstreetmap.josm.data.coor.LatLon; 11 10 import org.openstreetmap.josm.data.osm.Node; 12 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 13 13 import org.openstreetmap.josm.data.projection.Projections; 14 14 … … 18 18 19 19 protected void build() { 20 Main.setProjection(Projections.getProjectionByCode("EPSG:4326")); // WGS 8420 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326")); // WGS 84 21 21 22 22 setLayout(new BorderLayout()); -
trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
r12996 r14120 31 31 import org.junit.runners.Parameterized; 32 32 import org.junit.runners.Parameterized.Parameters; 33 import org.openstreetmap.josm.Main;34 33 import org.openstreetmap.josm.TestUtils; 35 34 import org.openstreetmap.josm.data.Bounds; … … 38 37 import org.openstreetmap.josm.data.osm.OsmPrimitive; 39 38 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 39 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 40 40 import org.openstreetmap.josm.io.IllegalDataException; 41 41 import org.openstreetmap.josm.io.OsmReader; … … 183 183 184 184 ProjectionBounds pb = new ProjectionBounds(); 185 pb.extend( Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMin()));186 pb.extend( Main.getProjection().latlon2eastNorth(testConfig.getTestArea().getMax()));185 pb.extend(ProjectionRegistry.getProjection().latlon2eastNorth(testConfig.getTestArea().getMin())); 186 pb.extend(ProjectionRegistry.getProjection().latlon2eastNorth(testConfig.getTestArea().getMax())); 187 187 double scale = (pb.maxEast - pb.minEast) / testConfig.imageWidth; 188 188 -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r12850 r14120 26 26 import org.junit.Test; 27 27 import org.openstreetmap.josm.JOSMFixture; 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.data.APIDataSet; 30 29 import org.openstreetmap.josm.data.coor.LatLon; … … 38 37 import org.openstreetmap.josm.data.osm.RelationMember; 39 38 import org.openstreetmap.josm.data.osm.Way; 39 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 40 40 import org.openstreetmap.josm.data.projection.Projections; 41 41 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 167 167 // 168 168 Config.getPref().putBoolean("osm-server.atomic-upload", false); 169 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator169 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 170 170 Logging.setLogLevel(Logging.LEVEL_DEBUG); 171 171 -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
r13175 r14120 26 26 import org.junit.rules.Timeout; 27 27 import org.openstreetmap.josm.JOSMFixture; 28 import org.openstreetmap.josm.Main;29 28 import org.openstreetmap.josm.PerformanceTestUtils; 30 29 import org.openstreetmap.josm.TestUtils; … … 36 35 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer.StyleRecord; 37 36 import org.openstreetmap.josm.data.preferences.sources.SourceEntry; 37 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 38 38 import org.openstreetmap.josm.gui.MainApplication; 39 39 import org.openstreetmap.josm.gui.NavigatableComponent; … … 197 197 scale = SCALE_Z17; 198 198 } 199 nc.zoomTo( Main.getProjection().latlon2eastNorth(center), scale);199 nc.zoomTo(ProjectionRegistry.getProjection().latlon2eastNorth(center), scale); 200 200 if (checkScale) { 201 201 int lvl = Selector.OptimizedGeneralSelector.scale2level(nc.getDist100Pixel()); -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r14119 r14120 18 18 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 19 19 import org.openstreetmap.josm.data.preferences.JosmUrls; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 20 21 import org.openstreetmap.josm.data.projection.Projections; 21 22 import org.openstreetmap.josm.gui.MainApplication; … … 126 127 127 128 // init projection 128 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator129 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 129 130 130 131 // setup projection grid files -
trunk/test/unit/org/openstreetmap/josm/MainTest.java
r14119 r14120 15 15 import org.openstreetmap.josm.Main.InitStatusListener; 16 16 import org.openstreetmap.josm.Main.InitializationTask; 17 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 17 18 import org.openstreetmap.josm.io.OnlineResource; 18 19 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 38 39 public void testPreConstructorInit() { 39 40 Main.preConstructorInit(); 40 assertNotNull( Main.getProjection());41 assertNotNull(CoordinateFormatManager.getDefaultFormat()); 41 42 } 42 43 -
trunk/test/unit/org/openstreetmap/josm/command/MoveCommandTest.java
r13489 r14120 15 15 import org.junit.Rule; 16 16 import org.junit.Test; 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.TestUtils; 19 18 import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation; … … 24 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 24 import org.openstreetmap.josm.data.osm.User; 25 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 26 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 27 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 57 57 public void testConstructors() { 58 58 EastNorth offset = new EastNorth(1, 2); 59 LatLon destLatLon = Main.getProjection().eastNorth2latlon(offset);59 LatLon destLatLon = ProjectionRegistry.getProjection().eastNorth2latlon(offset); 60 60 EastNorth start = new EastNorth(2, 0); 61 61 -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r13210 r14120 20 20 import org.junit.Rule; 21 21 import org.junit.Test; 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.TestUtils; 24 23 import org.openstreetmap.josm.data.Bounds; … … 28 27 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeEvent; 29 28 import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener; 29 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 30 30 import org.openstreetmap.josm.testutils.JOSMTestRules; 31 31 import org.openstreetmap.josm.tools.ListenerList; … … 327 327 List<WayPoint> points = Stream 328 328 .of(new EastNorth(10, 10), new EastNorth(10, 0), new EastNorth(-1, 0)) 329 .map( Main.getProjection()::eastNorth2latlon)329 .map(ProjectionRegistry.getProjection()::eastNorth2latlon) 330 330 .map(WayPoint::new) 331 331 .collect(Collectors.toList()); … … 336 336 337 337 WayPoint close = data.nearestPointOnTrack(new EastNorth(5, 5), 10); 338 assertEquals(10, close.getEastNorth( Main.getProjection()).east(), .01);339 assertEquals(5, close.getEastNorth( Main.getProjection()).north(), .01);338 assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01); 339 assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01); 340 340 341 341 close = data.nearestPointOnTrack(new EastNorth(15, 5), 10); 342 assertEquals(10, close.getEastNorth( Main.getProjection()).east(), .01);343 assertEquals(5, close.getEastNorth( Main.getProjection()).north(), .01);342 assertEquals(10, close.getEastNorth(ProjectionRegistry.getProjection()).east(), .01); 343 assertEquals(5, close.getEastNorth(ProjectionRegistry.getProjection()).north(), .01); 344 344 345 345 assertNull(data.nearestPointOnTrack(new EastNorth(5, 5), 1)); -
trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java
r12669 r14120 10 10 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 11 11 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.Bounds; 14 13 import org.openstreetmap.josm.data.coor.EastNorth; … … 16 15 import org.openstreetmap.josm.data.projection.CustomProjection; 17 16 import org.openstreetmap.josm.data.projection.Projection; 17 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 18 18 import org.openstreetmap.josm.data.projection.Projections; 19 19 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 42 42 public void testEPSG3857() { 43 43 Projection projection = Projections.getProjectionByCode("EPSG:3857"); 44 Main.setProjection(projection);44 ProjectionRegistry.setProjection(projection); 45 45 TemplatedWMSTileSource source = new TemplatedWMSTileSource(testImageryWMS, projection); 46 46 verifyMercatorTile(source, 0, 0, 1); … … 67 67 public void testEPSG4326() { 68 68 Projection projection = Projections.getProjectionByCode("EPSG:4326"); 69 Main.setProjection(projection);69 ProjectionRegistry.setProjection(projection); 70 70 TemplatedWMSTileSource source = getSource(projection); 71 71 … … 83 83 public void testEPSG4326widebounds() { 84 84 Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=-180,53,180,54"); 85 Main.setProjection(projection);85 ProjectionRegistry.setProjection(projection); 86 86 TemplatedWMSTileSource source = getSource(projection); 87 87 … … 96 96 public void testEPSG4326narrowbounds() { 97 97 Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=18,-90,20,90"); 98 Main.setProjection(projection);98 ProjectionRegistry.setProjection(projection); 99 99 TemplatedWMSTileSource source = getSource(projection); 100 100 … … 109 109 public void testEPSG2180() { 110 110 Projection projection = Projections.getProjectionByCode("EPSG:2180"); 111 Main.setProjection(projection);111 ProjectionRegistry.setProjection(projection); 112 112 TemplatedWMSTileSource source = getSource(projection); 113 113 … … 128 128 new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 " 129 129 + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006 +bounds=10.5700,55.2000,24.1800,69.1000 "); 130 Main.setProjection(projection);130 ProjectionRegistry.setProjection(projection); 131 131 TemplatedWMSTileSource source = getSource(projection); 132 132 … … 144 144 new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 " 145 145 + "+units=m +no_defs +axis=neu +wmssrs=EPSG:3006"); 146 Main.setProjection(projection);146 ProjectionRegistry.setProjection(projection); 147 147 TemplatedWMSTileSource source = getSource(projection); 148 148 … … 174 174 175 175 private void verifyLocation(TemplatedWMSTileSource source, LatLon location, int z) { 176 Projection projection = ProjectionRegistry.getProjection(); 176 177 assertTrue( 177 178 "Point outside world bounds", 178 Main.getProjection().getWorldBoundsLatLon().contains(location)179 projection.getWorldBoundsLatLon().contains(location) 179 180 ); 180 181 … … 187 188 tileIndex.getYIndex() <= source.getTileYMax(z)); 188 189 189 EastNorth locationEN = Main.getProjection().latlon2eastNorth(location);190 EastNorth x1 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex, z));191 EastNorth x2 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));190 EastNorth locationEN = projection.latlon2eastNorth(location); 191 EastNorth x1 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex, z)); 192 EastNorth x2 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z)); 192 193 // test that location is within tile bounds 193 194 assertTrue(locationEN.toString() + " not within " + bboxStr(x1, x2) + -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java
r14092 r14120 11 11 import org.junit.Rule; 12 12 import org.junit.Test; 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.TestUtils; 15 14 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 15 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 16 import org.openstreetmap.josm.data.projection.Projections; 17 17 import org.openstreetmap.josm.spi.preferences.Config; … … 78 78 ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0); 79 79 assertEquals("single_node_in_way", wmsImageryInfo.getDefaultLayers().get(0).getLayerName()); 80 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());80 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection()); 81 81 tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857")); 82 82 assertEquals("https://tools.geofabrik.de/osmi/views/geometry/wxs?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&" … … 122 122 ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0); 123 123 wmsImageryInfo.setDefaultLayers(Arrays.asList(new DefaultLayer(ImageryType.WMS_ENDPOINT, "historiske-ortofoto", "", ""))); 124 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, Main.getProjection());124 WMSEndpointTileSource tileSource = new WMSEndpointTileSource(wmsImageryInfo, ProjectionRegistry.getProjection()); 125 125 tileSource.initProjection(Projections.getProjectionByCode("EPSG:3857")); 126 126 assertEquals("b8e36d51-119a-423b-b156-d744d54123d5", wmsImageryInfo.getCustomHttpHeaders().get("X-WAAPI-TOKEN")); -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java
r14049 r14120 21 21 import org.openstreetmap.gui.jmapviewer.TileXY; 22 22 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.TestUtils; 25 24 import org.openstreetmap.josm.data.Bounds; … … 27 26 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 28 27 import org.openstreetmap.josm.data.imagery.WMTSTileSource.WMTSGetCapabilitiesException; 28 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 29 29 import org.openstreetmap.josm.data.projection.Projections; 30 30 import org.openstreetmap.josm.spi.preferences.Config; … … 85 85 @Test 86 86 public void testPseudoMercator() throws IOException, WMTSGetCapabilitiesException { 87 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));87 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 88 88 WMTSTileSource testSource = new WMTSTileSource(testImageryPSEUDO_MERCATOR); 89 testSource.initProjection( Main.getProjection());89 testSource.initProjection(ProjectionRegistry.getProjection()); 90 90 91 91 verifyMercatorTile(testSource, 0, 0, 1); … … 115 115 @Test 116 116 public void testWALLONIE() throws IOException, WMTSGetCapabilitiesException { 117 Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));117 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370")); 118 118 WMTSTileSource testSource = new WMTSTileSource(testImageryWALLONIE); 119 testSource.initProjection( Main.getProjection());119 testSource.initProjection(ProjectionRegistry.getProjection()); 120 120 121 121 assertEquals("http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/" … … 135 135 @Ignore("disable this test, needs further working") // XXX 136 136 public void testWALLONIENoMatrixDimension() throws IOException, WMTSGetCapabilitiesException { 137 Main.setProjection(Projections.getProjectionByCode("EPSG:31370"));137 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31370")); 138 138 WMTSTileSource testSource = new WMTSTileSource(getImagery("test/data/wmts/WMTSCapabilities-Wallonie-nomatrixdimension.xml")); 139 testSource.initProjection( Main.getProjection());139 testSource.initProjection(ProjectionRegistry.getProjection()); 140 140 141 141 Bounds wallonieBounds = new Bounds( … … 159 159 @Test 160 160 public void testWIEN() throws IOException, WMTSGetCapabilitiesException { 161 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));161 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 162 162 WMTSTileSource testSource = new WMTSTileSource(testImageryWIEN); 163 testSource.initProjection( Main.getProjection());163 testSource.initProjection(ProjectionRegistry.getProjection()); 164 164 int zoomOffset = 10; 165 165 … … 201 201 @Test 202 202 public void testGeoportalTOPOPL() throws IOException, WMTSGetCapabilitiesException { 203 Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));203 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326")); 204 204 WMTSTileSource testSource = new WMTSTileSource(testImageryTOPO_PL); 205 testSource.initProjection( Main.getProjection());205 testSource.initProjection(ProjectionRegistry.getProjection()); 206 206 verifyTile(new LatLon(56, 12), testSource, 0, 0, 1); 207 207 verifyTile(new LatLon(56, 12), testSource, 0, 0, 2); … … 223 223 @Test 224 224 public void testGeoportalORTOPL4326() throws IOException, WMTSGetCapabilitiesException { 225 Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));225 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:4326")); 226 226 WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL); 227 testSource.initProjection( Main.getProjection());227 testSource.initProjection(ProjectionRegistry.getProjection()); 228 228 verifyTile(new LatLon(53.60205873528009, 19.552206794646956), testSource, 12412, 3941, 13); 229 229 verifyTile(new LatLon(49.79005619189761, 22.778262259134397), testSource, 17714, 10206, 13); … … 232 232 @Test 233 233 public void testGeoportalORTOPL2180() throws IOException, WMTSGetCapabilitiesException { 234 Main.setProjection(Projections.getProjectionByCode("EPSG:2180"));234 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:2180")); 235 235 WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL); 236 testSource.initProjection( Main.getProjection());236 testSource.initProjection(ProjectionRegistry.getProjection()); 237 237 238 238 verifyTile(new LatLon(53.59940948387726, 19.560544913270064), testSource, 6453, 3140, 13); … … 242 242 @Test 243 243 public void testTicket12168() throws IOException, WMTSGetCapabilitiesException { 244 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));244 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 245 245 WMTSTileSource testSource = new WMTSTileSource(testImagery12168); 246 testSource.initProjection( Main.getProjection());246 testSource.initProjection(ProjectionRegistry.getProjection()); 247 247 assertEquals( 248 248 "http://www.ngi.be/cartoweb/1.0.0/topo/default/3857/7/1/1.png", … … 252 252 @Test 253 253 public void testTwoTileSetsForOneProjection() throws Exception { 254 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));254 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 255 255 ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml"); 256 256 ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] { … … 258 258 })); 259 259 WMTSTileSource testSource = new WMTSTileSource(ontario); 260 testSource.initProjection( Main.getProjection());260 testSource.initProjection(ProjectionRegistry.getProjection()); 261 261 assertEquals( 262 262 "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/" … … 269 269 @Test 270 270 public void testTwoTileSetsForOneProjectionSecondLayer() throws Exception { 271 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));271 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 272 272 ImageryInfo ontario = getImagery(TestUtils.getTestDataRoot() + "wmts/WMTSCapabilities-Ontario.xml"); 273 273 ontario.setDefaultLayers(Arrays.asList(new DefaultLayer[] { … … 275 275 })); 276 276 WMTSTileSource testSource = new WMTSTileSource(ontario); 277 testSource.initProjection( Main.getProjection());277 testSource.initProjection(ProjectionRegistry.getProjection()); 278 278 assertEquals( 279 279 "http://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_2014/MapServer/WMTS/tile/1.0.0/Basemap_Imagery_2014/default/" … … 286 286 @Test 287 287 public void testManyLayersScrollbars() throws Exception { 288 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));288 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 289 289 WMTSTileSource testSource = new WMTSTileSource(testLotsOfLayers); 290 testSource.initProjection( Main.getProjection());290 testSource.initProjection(ProjectionRegistry.getProjection()); 291 291 } 292 292 293 293 @Test 294 294 public void testParserForDuplicateTags() throws Exception { 295 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));295 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 296 296 WMTSTileSource testSource = new WMTSTileSource(testDuplicateTags); 297 testSource.initProjection( Main.getProjection());297 testSource.initProjection(ProjectionRegistry.getProjection()); 298 298 assertEquals( 299 299 "http://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&" … … 305 305 @Test 306 306 public void testParserForMissingStyleIdentifier() throws Exception { 307 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));307 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 308 308 WMTSTileSource testSource = new WMTSTileSource(testMissingStyleIdentifer); 309 testSource.initProjection( Main.getProjection());309 testSource.initProjection(ProjectionRegistry.getProjection()); 310 310 } 311 311 312 312 @Test 313 313 public void testForMultipleTileMatricesForOneLayerProjection() throws Exception { 314 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));314 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 315 315 ImageryInfo copy = new ImageryInfo(testMultipleTileMatrixForLayer); 316 316 List<DefaultLayer> defaultLayers = new ArrayList<>(1); … … 318 318 copy.setDefaultLayers(defaultLayers); 319 319 WMTSTileSource testSource = new WMTSTileSource(copy); 320 testSource.initProjection( Main.getProjection());320 testSource.initProjection(ProjectionRegistry.getProjection()); 321 321 assertEquals( 322 322 "http://188.253.0.155:6080/arcgis/rest/services/Mashhad_BaseMap_1/MapServer/WMTS/tile/1.0.0/Mashhad_BaseMap_1" … … 333 333 @Test 334 334 public void testDimension() throws IOException, WMTSGetCapabilitiesException { 335 Main.setProjection(Projections.getProjectionByCode("EPSG:21781"));335 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:21781")); 336 336 ImageryInfo info = new ImageryInfo(testImageryGeoAdminCh); 337 337 List<DefaultLayer> defaultLayers = new ArrayList<>(1); … … 339 339 info.setDefaultLayers(defaultLayers); 340 340 WMTSTileSource testSource = new WMTSTileSource(info); 341 testSource.initProjection( Main.getProjection());341 testSource.initProjection(ProjectionRegistry.getProjection()); 342 342 assertEquals( 343 343 "http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte/default/20140101/21781/1/3/2.png", … … 414 414 @Test 415 415 public void testGisKtnGvAt() throws IOException, WMTSGetCapabilitiesException { 416 Main.setProjection(Projections.getProjectionByCode("EPSG:31258"));416 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:31258")); 417 417 final WMTSTileSource source = new WMTSTileSource(testImageryGisKtnGvAt); 418 source.initProjection( Main.getProjection());418 source.initProjection(ProjectionRegistry.getProjection()); 419 419 final TileXY tile = source.latLonToTileXY(46.6103, 13.8558, 11); 420 420 assertEquals("https://gis.ktn.gv.at/arcgis/rest/services/tilecache/Ortho_2013_2015" + -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r12750 r14120 19 19 import org.junit.Rule; 20 20 import org.junit.Test; 21 import org.openstreetmap.josm.Main;22 21 import org.openstreetmap.josm.data.coor.LatLon; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 23 23 import org.openstreetmap.josm.data.projection.Projections; 24 24 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 49 49 their = new DataSet(); 50 50 their.setVersion("0.6"); 51 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator51 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 52 52 } 53 53 -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r10945 r14120 9 9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 13 13 import org.openstreetmap.josm.data.projection.Projections; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 40 40 @BeforeClass 41 41 public static void setUp() { 42 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator42 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 43 43 } 44 44 -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r14092 r14120 17 17 import org.junit.Rule; 18 18 import org.junit.Test; 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.data.coor.LatLon; 20 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 21 21 import org.openstreetmap.josm.data.projection.Projections; 22 22 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 83 83 @Test 84 84 public void testRemove() throws Exception { 85 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator85 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 86 86 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) { 87 87 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); … … 96 96 @Test 97 97 public void testMove() throws Exception { 98 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator98 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 99 99 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) { 100 100 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r13702 r14120 8 8 import org.junit.Rule; 9 9 import org.junit.Test; 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.coor.EastNorth; 12 11 import org.openstreetmap.josm.data.coor.LatLon; … … 34 33 @BeforeClass 35 34 public static void setUp() { 36 Main.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid35 ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid 37 36 } 38 37 … … 97 96 public void testAlatlon2eastNorth() { 98 97 LatLon ll = new LatLon(46.518, 6.567); 99 EastNorth en = Main.getProjection().latlon2eastNorth(ll);98 EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 100 99 if (debug) { 101 100 System.out.println(en); … … 105 104 106 105 ll = new LatLon(47.78, 8.58); 107 en = Main.getProjection().latlon2eastNorth(ll);106 en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 108 107 if (debug) { 109 108 System.out.println(en); … … 113 112 114 113 ll = new LatLon(46.58, 10.48); 115 en = Main.getProjection().latlon2eastNorth(ll);114 en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 116 115 if (debug) { 117 116 System.out.println(en); … … 121 120 122 121 ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600); 123 en = Main.getProjection().latlon2eastNorth(ll);122 en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 124 123 if (debug) { 125 124 System.out.println(en); … … 130 129 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 131 130 ll = new LatLon(46.04412093223244, 8.730497366167727); 132 en = Main.getProjection().latlon2eastNorth(ll);131 en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 133 132 if (debug) { 134 133 System.out.println(en); … … 144 143 public void testBeastNorth2latlon() { 145 144 EastNorth en = new EastNorth(533112.13, 152227.35); 146 LatLon ll = Main.getProjection().eastNorth2latlon(en);145 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 147 146 if (debug) { 148 147 System.out.println(ll); … … 152 151 153 152 en = new EastNorth(685542.97, 292783.21); 154 ll = Main.getProjection().eastNorth2latlon(en);153 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 155 154 if (debug) { 156 155 System.out.println(ll); … … 160 159 161 160 en = new EastNorth(833066.95, 163265.32); 162 ll = Main.getProjection().eastNorth2latlon(en);161 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 163 162 if (debug) { 164 163 System.out.println(ll); … … 168 167 169 168 en = new EastNorth(600000.0, 200000.0); 170 ll = Main.getProjection().eastNorth2latlon(en);169 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 171 170 if (debug) { 172 171 System.out.println(ll); … … 177 176 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 178 177 en = new EastNorth(700000.0, 100000.0); 179 ll = Main.getProjection().eastNorth2latlon(en);178 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 180 179 if (debug) { 181 180 System.out.println(ll); … … 191 190 public void testCsendandreturn() { 192 191 EastNorth en = new EastNorth(533111.69, 152227.85); 193 LatLon ll = Main.getProjection().eastNorth2latlon(en);194 EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);192 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 193 EastNorth en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 195 194 if (debug) { 196 195 System.out.println(en.east() - en2.east()); … … 203 202 204 203 en = new EastNorth(685544.16, 292782.91); 205 ll = Main.getProjection().eastNorth2latlon(en);206 en2 = Main.getProjection().latlon2eastNorth(ll);204 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 205 en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 207 206 if (debug) { 208 207 System.out.println(en.east() - en2.east()); … … 215 214 216 215 en = new EastNorth(833068.04, 163265.39); 217 ll = Main.getProjection().eastNorth2latlon(en);218 en2 = Main.getProjection().latlon2eastNorth(ll);216 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 217 en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 219 218 if (debug) { 220 219 System.out.println(en.east() - en2.east()); … … 227 226 228 227 en = new EastNorth(600000.0, 200000.0); 229 ll = Main.getProjection().eastNorth2latlon(en);230 en2 = Main.getProjection().latlon2eastNorth(ll);228 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 229 en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 231 230 if (debug) { 232 231 System.out.println(en.east() - en2.east()); … … 239 238 240 239 en = new EastNorth(700000.0, 100000.0); 241 ll = Main.getProjection().eastNorth2latlon(en);242 en2 = Main.getProjection().latlon2eastNorth(ll);240 ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); 241 en2 = ProjectionRegistry.getProjection().latlon2eastNorth(ll); 243 242 if (debug) { 244 243 System.out.println(en.east() - en2.east()); -
trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
r12076 r14120 13 13 import org.junit.Test; 14 14 import org.openstreetmap.josm.JOSMFixture; 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.coor.EastNorth; 17 16 import org.openstreetmap.josm.data.coor.LatLon; 17 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 18 18 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 19 19 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; … … 111 111 112 112 EastNorth eastnorth = p.getEastNorth(); 113 LatLon shouldLatLon = Main.getProjection().getWorldBoundsLatLon().getCenter();114 EastNorth shouldEastNorth = Main.getProjection().latlon2eastNorth(shouldLatLon);113 LatLon shouldLatLon = ProjectionRegistry.getProjection().getWorldBoundsLatLon().getCenter(); 114 EastNorth shouldEastNorth = ProjectionRegistry.getProjection().latlon2eastNorth(shouldLatLon); 115 115 assertEquals("east", shouldEastNorth.east(), eastnorth.east(), 0.01); 116 116 assertEquals("north", shouldEastNorth.north(), eastnorth.north(), 0.01); -
trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
r11867 r14120 18 18 import org.junit.Rule; 19 19 import org.junit.Test; 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.data.Bounds; 22 21 import org.openstreetmap.josm.data.ProjectionBounds; 23 22 import org.openstreetmap.josm.data.coor.EastNorth; 24 23 import org.openstreetmap.josm.data.coor.LatLon; 24 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 25 25 import org.openstreetmap.josm.gui.util.GuiHelper; 26 26 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 82 82 @Test 83 83 public void testDefaultScale() { 84 assertEquals( Main.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001);84 assertEquals(ProjectionRegistry.getProjection().getDefaultZoomInPPD(), component.getScale(), 0.00001); 85 85 } 86 86 -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java
r12922 r14120 9 9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.actions.CopyAction; 13 12 import org.openstreetmap.josm.data.coor.LatLon; 14 13 import org.openstreetmap.josm.data.osm.DataSet; 15 14 import org.openstreetmap.josm.data.osm.Node; 15 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 55 55 56 56 LatLon pos = new LatLon(55, -5); 57 transferHandler.pasteOn(target, Main.getProjection().latlon2eastNorth(pos));57 transferHandler.pasteOn(target, ProjectionRegistry.getProjection().latlon2eastNorth(pos)); 58 58 assertTrue(pos.equalsEpsilon(ds2.getNodes().iterator().next().getCoor())); 59 59 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r14052 r14120 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.openstreetmap.josm.tools.I18n.tr;6 5 import static org.junit.Assert.assertEquals; 7 6 import static org.junit.Assert.assertFalse; 8 7 import static org.junit.Assert.assertTrue; 9 8 import static org.junit.Assert.fail; 9 import static org.openstreetmap.josm.tools.I18n.tr; 10 10 11 11 import java.awt.Color; … … 19 19 import java.util.regex.Matcher; 20 20 21 import javax.swing.JCheckBoxMenuItem; 21 22 import javax.swing.JMenuItem; 22 import javax.swing.JCheckBoxMenuItem;23 23 import javax.swing.JPopupMenu; 24 24 … … 31 31 import org.openstreetmap.josm.data.DataSource; 32 32 import org.openstreetmap.josm.data.osm.DataSet; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 33 34 import org.openstreetmap.josm.data.projection.Projections; 34 35 import org.openstreetmap.josm.gui.MainApplication; … … 36 37 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 37 38 import org.openstreetmap.josm.gui.bbox.SourceButton; 39 import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer; 38 40 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 39 import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;40 41 import org.openstreetmap.josm.gui.util.GuiHelper; 41 42 import org.openstreetmap.josm.testutils.ImagePatternMatching; … … 278 279 Main.pref.put("slippy_map_chooser.mapstyle", "White Tiles"); 279 280 // ensure projection matches JMapViewer's 280 Main.setProjection(Projections.getProjectionByCode("EPSG:3857"));281 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); 281 282 282 283 MapView mapView = MainApplication.getMap().mapView; -
trunk/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java
r12990 r14120 14 14 import org.junit.Rule; 15 15 import org.junit.Test; 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.data.preferences.AbstractProperty; 18 17 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 18 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 19 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 20 … … 181 181 public void testIsProjectionSupported() { 182 182 assertFalse(testLayer.isProjectionSupported(null)); 183 assertTrue(testLayer.isProjectionSupported( Main.getProjection()));183 assertTrue(testLayer.isProjectionSupported(ProjectionRegistry.getProjection())); 184 184 } 185 185 -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r13797 r14120 13 13 import org.junit.Rule; 14 14 import org.junit.Test; 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.coor.LatLon; 17 16 import org.openstreetmap.josm.data.gpx.GpxData; … … 21 20 import org.openstreetmap.josm.data.notes.Note; 22 21 import org.openstreetmap.josm.data.osm.DataSet; 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 23 23 import org.openstreetmap.josm.gui.MainApplication; 24 24 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 144 144 TMSLayer layer = new TMSLayer(new ImageryInfo("the name", "http://www.url.com/")); 145 145 layer.getDisplaySettings().setOffsetBookmark( 146 new OffsetBookmark( Main.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34));146 new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), layer.getInfo().getId(), layer.getInfo().getName(), "", 12, 34)); 147 147 return layer; 148 148 } -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r14119 r14120 32 32 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 33 33 import org.openstreetmap.josm.data.preferences.JosmUrls; 34 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 34 35 import org.openstreetmap.josm.data.projection.Projections; 35 36 import org.openstreetmap.josm.gui.MainApplication; … … 472 473 473 474 if (useProjection) { 474 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator475 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 475 476 } 476 477 … … 589 590 590 591 // TODO: Remove global listeners and other global state. 591 Main.clearProjectionChangeListeners();592 ProjectionRegistry.clearProjectionChangeListeners(); 592 593 Main.pref.resetToInitialState(); 593 594 Main.platform = null;
Note:
See TracChangeset
for help on using the changeset viewer.