-
From 77f5b2b45b8c07f1b32922d324148a7452c30e43 Mon Sep 17 00:00:00 2001
From: Gubaer <karl.gugisberg@guggis.ch>
Date: Sun, 5 Jun 2011 11:01:23 +0200
Subject: [PATCH] Combined commits from cached-lat-lon, patch against JOSM 4115
---
src/org/openstreetmap/josm/Main.java | 116 ++++++++++++++++++-
.../josm/actions/CreateCircleAction.java | 4 +-
.../josm/actions/ImageryAdjustAction.java | 4 +-
.../josm/actions/OrthogonalizeAction.java | 2 +-
.../josm/actions/mapmode/ExtrudeAction.java | 10 +-
.../openstreetmap/josm/command/MoveCommand.java | 4 +-
.../openstreetmap/josm/data/coor/CachedLatLon.java | 88 ++++++++++-----
src/org/openstreetmap/josm/data/coor/LatLon.java | 9 +-
src/org/openstreetmap/josm/data/gpx/GpxTrack.java | 1 -
.../josm/data/gpx/ImmutableGpxTrackSegment.java | 1 -
src/org/openstreetmap/josm/data/gpx/WayPoint.java | 73 +++++++++++-
.../josm/data/imagery/OffsetBookmark.java | 6 +-
src/org/openstreetmap/josm/data/osm/DataSet.java | 67 +++++++++++-
src/org/openstreetmap/josm/data/osm/INode.java | 3 +-
src/org/openstreetmap/josm/data/osm/Node.java | 119 +++++++++++++++----
src/org/openstreetmap/josm/data/osm/NodeData.java | 38 ++++--
.../josm/data/osm/visitor/BoundingXYVisitor.java | 18 +--
.../data/projection/ProjectionChangeListener.java | 6 +
.../josm/data/projection/Projections.java | 44 +++++---
.../josm/data/validation/OsmValidator.java | 57 +++++-----
src/org/openstreetmap/josm/gui/MapView.java | 4 +-
.../josm/gui/NavigatableComponent.java | 44 +++-----
src/org/openstreetmap/josm/gui/layer/GpxLayer.java | 36 ++++++-
.../openstreetmap/josm/gui/layer/ImageryLayer.java | 2 +-
src/org/openstreetmap/josm/gui/layer/Layer.java | 12 ++-
.../openstreetmap/josm/gui/layer/OsmDataLayer.java | 12 ++-
.../openstreetmap/josm/gui/layer/RawGpsLayer.java | 2 +-
src/org/openstreetmap/josm/gui/layer/TMSLayer.java | 4 +-
.../josm/gui/layer/geoimage/ImageEntry.java | 10 +-
.../josm/gui/layer/markerlayer/Marker.java | 92 +++++++--------
.../josm/gui/preferences/ImageryPreference.java | 2 +-
.../josm/gui/preferences/ProjectionPreference.java | 46 +------
src/org/openstreetmap/josm/io/imagery/Grabber.java | 2 +-
.../openstreetmap/josm/io/imagery/HTMLGrabber.java | 2 +-
.../josm/io/imagery/OsmosnimkiOffsetServer.java | 4 +-
.../openstreetmap/josm/io/imagery/WMSGrabber.java | 18 ++--
src/org/openstreetmap/josm/tools/Geometry.java | 8 +-
.../openstreetmap/josm/fixtures/JOSMFixture.java | 2 +-
.../pair/properties/PropertiesMergerTest.java | 2 +-
.../josm/gui/history/HistoryBrowserTest.java | 2 +-
.../josm/io/MultiFetchServerObjectReaderTest.java | 2 +-
.../josm/io/OsmServerBackreferenceReaderTest.java | 2 +-
.../data/osm/MapPaintVisitorPerformanceTest.java | 2 +-
.../josm/data/osm/DataSetMergerTest.java | 2 +-
.../openstreetmap/josm/data/osm/FilterTest.java | 2 +-
.../josm/data/osm/NodeProjectionTest.java | 72 ++++++++++++
.../josm/data/osm/OsmPrimitiveTest.java | 2 +-
.../josm/data/osm/QuadBucketsTest.java | 4 +-
.../openstreetmap/josm/data/osm/RelationTest.java | 2 +-
.../visitor/MergeSourceBuildingVisitorTest.java | 2 +-
.../josm/data/projection/SwissGridTest.java | 122 +++++++++++++-------
.../properties/PropertiesMergeModelTest.java | 2 +-
52 files changed, 826 insertions(+), 366 deletions(-)
create mode 100644 src/org/openstreetmap/josm/data/projection/ProjectionChangeListener.java
create mode 100644 test/unit/org/openstreetmap/josm/data/osm/NodeProjectionTest.java
diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index c25d00b..4ddd9e0 100644
|
a
|
b
|
import java.awt.event.KeyEvent;
|
| 15 | 15 | import java.awt.event.WindowAdapter; |
| 16 | 16 | import java.awt.event.WindowEvent; |
| 17 | 17 | import java.io.File; |
| | 18 | import java.lang.ref.WeakReference; |
| 18 | 19 | import java.net.URI; |
| 19 | 20 | import java.net.URISyntaxException; |
| 20 | 21 | import java.util.ArrayList; |
| 21 | 22 | import java.util.Collection; |
| | 23 | import java.util.Iterator; |
| 22 | 24 | import java.util.List; |
| 23 | 25 | import java.util.Map; |
| 24 | 26 | import java.util.StringTokenizer; |
| … |
… |
import org.openstreetmap.josm.data.coor.LatLon;
|
| 55 | 57 | import org.openstreetmap.josm.data.osm.DataSet; |
| 56 | 58 | import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; |
| 57 | 59 | import org.openstreetmap.josm.data.projection.Projection; |
| | 60 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener; |
| 58 | 61 | import org.openstreetmap.josm.data.validation.OsmValidator; |
| 59 | 62 | import org.openstreetmap.josm.gui.GettingStarted; |
| 60 | 63 | import org.openstreetmap.josm.gui.MainMenu; |
| … |
… |
import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
|
| 72 | 75 | import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; |
| 73 | 76 | import org.openstreetmap.josm.io.OsmApi; |
| 74 | 77 | import org.openstreetmap.josm.plugins.PluginHandler; |
| | 78 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
| 75 | 79 | import org.openstreetmap.josm.tools.I18n; |
| 76 | 80 | import org.openstreetmap.josm.tools.ImageProvider; |
| 77 | 81 | import org.openstreetmap.josm.tools.OsmUrlToBounds; |
| … |
… |
abstract public class Main {
|
| 118 | 122 | */ |
| 119 | 123 | public static PrimitiveDeepCopy pasteBuffer = new PrimitiveDeepCopy(); |
| 120 | 124 | public static Layer pasteSource; |
| 121 | | /** |
| 122 | | * The projection method used. |
| 123 | | */ |
| 124 | | public static Projection proj; |
| | 125 | |
| | 126 | |
| 125 | 127 | /** |
| 126 | 128 | * The MapFrame. Use setMapFrame to set or clear it. |
| 127 | 129 | */ |
| … |
… |
abstract public class Main {
|
| 212 | 214 | isOpenjdk = System.getProperty("java.vm.name").toUpperCase().indexOf("OPENJDK") != -1; |
| 213 | 215 | platform.startupHook(); |
| 214 | 216 | |
| 215 | | // We try to establish an API connection early, so that any API |
| | 217 | // We try to establish an API connection early, so that any API |
| 216 | 218 | // capabilities are already known to the editor instance. However |
| 217 | 219 | // if it goes wrong that's not critical at this stage. |
| 218 | 220 | try { |
| … |
… |
abstract public class Main {
|
| 767 | 769 | } |
| 768 | 770 | System.err.println("Error: Could not recognize Java Version: "+version); |
| 769 | 771 | } |
| | 772 | |
| | 773 | /* ----------------------------------------------------------------------------------------- */ |
| | 774 | /* projection handling - Main is a registry for a single, global projection instance */ |
| | 775 | /* */ |
| | 776 | /* TODO: For historical reasons the registry is implemented by Main. An alternative approach */ |
| | 777 | /* would be a singleton org.openstreetmap.josm.data.projection.ProjectionRegistry class. */ |
| | 778 | /* ----------------------------------------------------------------------------------------- */ |
| | 779 | /** |
| | 780 | * The projection method used. |
| | 781 | * @deprecated use {@link #getProjection()} and {@link #setProjection(Projection)} instead. |
| | 782 | * For the time being still publicly available, but avoid/migrate write access to it. Use |
| | 783 | * {@link #setProjection(Projection)} in order to trigger a projection change event. |
| | 784 | */ |
| | 785 | @Deprecated |
| | 786 | public static Projection proj; |
| | 787 | |
| | 788 | /** |
| | 789 | * Replies the current projection. |
| | 790 | * |
| | 791 | * @return |
| | 792 | */ |
| | 793 | public static Projection getProjection() { |
| | 794 | return proj; |
| | 795 | } |
| | 796 | |
| | 797 | /** |
| | 798 | * Sets the current projection |
| | 799 | * |
| | 800 | * @param p the projection |
| | 801 | */ |
| | 802 | public static void setProjection(Projection p) { |
| | 803 | CheckParameterUtil.ensureParameterNotNull(p); |
| | 804 | Projection oldValue = proj; |
| | 805 | proj = p; |
| | 806 | fireProjectionChanged(oldValue, proj); |
| | 807 | } |
| | 808 | |
| | 809 | /* |
| | 810 | * Keep WeakReferences to the listeners. This relieves clients from the burden of |
| | 811 | * explicitly removing the listeners and allows us to transparently register every |
| | 812 | * created dataset as projection change listener. |
| | 813 | */ |
| | 814 | private static final ArrayList<WeakReference<ProjectionChangeListener>> listeners = new ArrayList<WeakReference<ProjectionChangeListener>>(); |
| | 815 | |
| | 816 | private static void fireProjectionChanged(Projection oldValue, Projection newValue) { |
| | 817 | if (newValue == null ^ oldValue == null |
| | 818 | || (newValue != null && oldValue != null && !newValue.getClass().getName().equals(oldValue.getClass().getName()))) { |
| | 819 | |
| | 820 | synchronized(Main.class) { |
| | 821 | Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator(); |
| | 822 | while(it.hasNext()){ |
| | 823 | WeakReference<ProjectionChangeListener> wr = it.next(); |
| | 824 | if (wr.get() == null) { |
| | 825 | it.remove(); |
| | 826 | continue; |
| | 827 | } |
| | 828 | wr.get().projectionChanged(oldValue, newValue); |
| | 829 | } |
| | 830 | } |
| | 831 | if (newValue != null) { |
| | 832 | Bounds b = (Main.map != null && Main.map.mapView != null) ? Main.map.mapView.getRealBounds() : null; |
| | 833 | if (b != null){ |
| | 834 | Main.map.mapView.zoomTo(b); |
| | 835 | } |
| | 836 | } |
| | 837 | /* TODO - remove layers with fixed projection */ |
| | 838 | } |
| | 839 | } |
| | 840 | |
| | 841 | /** |
| | 842 | * Register a projection change listener |
| | 843 | * |
| | 844 | * @param listener the listener. Ignored if null. |
| | 845 | */ |
| | 846 | public static void addProjectionChangeListener(ProjectionChangeListener listener) { |
| | 847 | if (listener == null) return; |
| | 848 | synchronized (Main.class) { |
| | 849 | for (WeakReference<ProjectionChangeListener> wr : listeners) { |
| | 850 | // already registered ? => abort |
| | 851 | if (wr.get() == listener) return; |
| | 852 | } |
| | 853 | } |
| | 854 | listeners.add(new WeakReference<ProjectionChangeListener>(listener)); |
| | 855 | } |
| | 856 | |
| | 857 | /** |
| | 858 | * Removes a projection change listener |
| | 859 | * |
| | 860 | * @param listener the listener. Ignored if null. |
| | 861 | */ |
| | 862 | public static void removeProjectionChangeListener(ProjectionChangeListener listener) { |
| | 863 | if (listener == null) return; |
| | 864 | synchronized(Main.class){ |
| | 865 | Iterator<WeakReference<ProjectionChangeListener>> it = listeners.iterator(); |
| | 866 | while(it.hasNext()){ |
| | 867 | WeakReference<ProjectionChangeListener> wr = it.next(); |
| | 868 | // remove the listener - and any other listener which god garbage |
| | 869 | // collected in the meantime |
| | 870 | if (wr.get() == null || wr.get() == listener) { |
| | 871 | it.remove(); |
| | 872 | } |
| | 873 | } |
| | 874 | } |
| | 875 | } |
| 770 | 876 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/CreateCircleAction.java b/src/org/openstreetmap/josm/actions/CreateCircleAction.java
index ebf7666..1afea76 100644
|
a
|
b
|
public final class CreateCircleAction extends JosmAction {
|
| 152 | 152 | // get the position of the new node and insert it |
| 153 | 153 | double x = xc + r*Math.cos(a); |
| 154 | 154 | double y = yc + r*Math.sin(a); |
| 155 | | Node n = new Node(Main.proj.eastNorth2latlon(new EastNorth(x,y))); |
| | 155 | Node n = new Node(Main.getProjection().eastNorth2latlon(new EastNorth(x,y))); |
| 156 | 156 | wayToAdd.add(n); |
| 157 | 157 | cmds.add(new AddCommand(n)); |
| 158 | 158 | } |
| … |
… |
public final class CreateCircleAction extends JosmAction {
|
| 244 | 244 | // get the position of the new node and insert it |
| 245 | 245 | double x = xc + r*Math.cos(a); |
| 246 | 246 | double y = yc + r*Math.sin(a); |
| 247 | | Node n = new Node(Main.proj.eastNorth2latlon(new EastNorth(x,y))); |
| | 247 | Node n = new Node(Main.getProjection().eastNorth2latlon(new EastNorth(x,y))); |
| 248 | 248 | wayToAdd.add(n); |
| 249 | 249 | cmds.add(new AddCommand(n)); |
| 250 | 250 | } |
-
diff --git a/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java b/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
index 9380fc1..3d5b844 100644
|
a
|
b
|
public class ImageryAdjustAction extends MapMode implements MouseListener, Mouse
|
| 161 | 161 | JPanel pnl = new JPanel(new GridBagLayout()); |
| 162 | 162 | pnl.add(new JMultilineLabel(tr("Use arrow keys or drag the imagery layer with mouse to adjust the imagery offset.\n" + |
| 163 | 163 | "You can also enter east and north offset in the {0} coordinates.\n" + |
| 164 | | "If you want to save the offset as bookmark, enter the bookmark name below",Main.proj.toString())), GBC.eop()); |
| | 164 | "If you want to save the offset as bookmark, enter the bookmark name below",Main.getProjection().toString())), GBC.eop()); |
| 165 | 165 | pnl.add(new JLabel(tr("Offset: ")),GBC.std()); |
| 166 | 166 | pnl.add(tOffset,GBC.eol().fill(GBC.HORIZONTAL).insets(0,0,0,5)); |
| 167 | 167 | pnl.add(new JLabel(tr("Bookmark name: ")),GBC.std()); |
| … |
… |
public class ImageryAdjustAction extends MapMode implements MouseListener, Mouse
|
| 210 | 210 | |
| 211 | 211 | public void updateOffsetIntl() { |
| 212 | 212 | // Support projections with very small numbers (e.g. 4326) |
| 213 | | int precision = Main.proj.getDefaultZoomInPPD() >= 1.0 ? 2 : 7; |
| | 213 | int precision = Main.getProjection().getDefaultZoomInPPD() >= 1.0 ? 2 : 7; |
| 214 | 214 | // US locale to force decimal separator to be '.' |
| 215 | 215 | tOffset.setText(new java.util.Formatter(java.util.Locale.US).format( |
| 216 | 216 | "%1." + precision + "f; %1." + precision + "f", |
-
diff --git a/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java b/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
index d4b7714..a7df4da 100644
|
a
|
b
|
public final class OrthogonalizeAction extends JosmAction {
|
| 116 | 116 | public void actionPerformed(ActionEvent e) { |
| 117 | 117 | if (!isEnabled()) |
| 118 | 118 | return; |
| 119 | | if ("EPSG:4326".equals(Main.proj.toString())) { |
| | 119 | if ("EPSG:4326".equals(Main.getProjection().toString())) { |
| 120 | 120 | String msg = tr("<html>You are using the EPSG:4326 projection which might lead<br>" + |
| 121 | 121 | "to undesirable results when doing rectangular alignments.<br>" + |
| 122 | 122 | "Change your projection to get rid of this warning.<br>" + |
-
diff --git a/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java b/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
index 252852c..63c8960 100644
|
a
|
b
|
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 254 | 254 | newN2en = new EastNorth(initialN2en.getX() + bestMovement.getX(), initialN2en.getY() + bestMovement.getY()); |
| 255 | 255 | |
| 256 | 256 | // find out the movement distance, in metres |
| 257 | | double distance = Main.proj.eastNorth2latlon(initialN1en).greatCircleDistance(Main.proj.eastNorth2latlon(newN1en)); |
| | 257 | double distance = Main.getProjection().eastNorth2latlon(initialN1en).greatCircleDistance(Main.getProjection().eastNorth2latlon(newN1en)); |
| 258 | 258 | Main.map.statusLine.setDist(distance); |
| 259 | 259 | updateStatusLine(); |
| 260 | 260 | |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 308 | 308 | if (nodeOverlapsSegment && !alwaysCreateNodes && !hasOtherWays) { |
| 309 | 309 | //move existing node |
| 310 | 310 | Node n1Old = selectedSegment.getFirstNode(); |
| 311 | | cmds.add(new MoveCommand(n1Old, Main.proj.eastNorth2latlon(newN1en))); |
| | 311 | cmds.add(new MoveCommand(n1Old, Main.getProjection().eastNorth2latlon(newN1en))); |
| 312 | 312 | } else { |
| 313 | 313 | //introduce new node |
| 314 | | Node n1New = new Node(Main.proj.eastNorth2latlon(newN1en)); |
| | 314 | Node n1New = new Node(Main.getProjection().eastNorth2latlon(newN1en)); |
| 315 | 315 | wnew.addNode(insertionPoint, n1New); |
| 316 | 316 | insertionPoint ++; |
| 317 | 317 | cmds.add(new AddCommand(n1New)); |
| … |
… |
public class ExtrudeAction extends MapMode implements MapViewPaintable {
|
| 325 | 325 | if (nodeOverlapsSegment && !alwaysCreateNodes && !hasOtherWays) { |
| 326 | 326 | //move existing node |
| 327 | 327 | Node n2Old = selectedSegment.getSecondNode(); |
| 328 | | cmds.add(new MoveCommand(n2Old, Main.proj.eastNorth2latlon(newN2en))); |
| | 328 | cmds.add(new MoveCommand(n2Old, Main.getProjection().eastNorth2latlon(newN2en))); |
| 329 | 329 | } else { |
| 330 | 330 | //introduce new node |
| 331 | | Node n2New = new Node(Main.proj.eastNorth2latlon(newN2en)); |
| | 331 | Node n2New = new Node(Main.getProjection().eastNorth2latlon(newN2en)); |
| 332 | 332 | wnew.addNode(insertionPoint, n2New); |
| 333 | 333 | insertionPoint ++; |
| 334 | 334 | cmds.add(new AddCommand(n2New)); |
-
diff --git a/src/org/openstreetmap/josm/command/MoveCommand.java b/src/org/openstreetmap/josm/command/MoveCommand.java
index b7b5d25..ba43d5d 100644
|
a
|
b
|
import java.util.List;
|
| 11 | 11 | |
| 12 | 12 | import javax.swing.JLabel; |
| 13 | 13 | |
| 14 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 15 | 14 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 16 | 15 | import org.openstreetmap.josm.data.coor.LatLon; |
| 17 | 16 | import org.openstreetmap.josm.data.osm.Node; |
| 18 | 17 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| 19 | 18 | import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; |
| | 19 | import org.openstreetmap.josm.data.projection.Projections; |
| 20 | 20 | import org.openstreetmap.josm.tools.ImageProvider; |
| 21 | 21 | |
| 22 | 22 | /** |
| … |
… |
public class MoveCommand extends Command {
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public MoveCommand(Node node, LatLon position) { |
| 61 | | this(Collections.singleton((OsmPrimitive) node), node.getEastNorth().sub(new CachedLatLon(position).getEastNorth())); |
| | 61 | this(Collections.singleton((OsmPrimitive) node), node.getEastNorth().sub(Projections.project(position))); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public MoveCommand(Collection<OsmPrimitive> objects, EastNorth offset) { |
-
diff --git a/src/org/openstreetmap/josm/data/coor/CachedLatLon.java b/src/org/openstreetmap/josm/data/coor/CachedLatLon.java
index 6858705..f40c264 100644
|
a
|
b
|
|
| 2 | 2 | package org.openstreetmap.josm.data.coor; |
| 3 | 3 | |
| 4 | 4 | import org.openstreetmap.josm.Main; |
| | 5 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| 5 | 6 | import org.openstreetmap.josm.data.projection.Projection; |
| 6 | 7 | |
| | 8 | /** |
| | 9 | * <p>Maintains an internal cache of the projected lat/lon coordinates.</p> |
| | 10 | * |
| | 11 | * <p><strong>Caveat:</strong> instances do not listen to {@link ProjectionChangeEvents}s. Clients have to make |
| | 12 | * sure that they invalidate the internal cache if the {@link Main#getProjection() global projection} changes.</p> |
| | 13 | * |
| | 14 | * @deprecated Don't use anymore. If necessary, maintain a cache of projected coordinates elsewhere. See {@link Node} and {@link WayPoint} for examples. |
| | 15 | * |
| | 16 | */ |
| | 17 | @Deprecated |
| 7 | 18 | public class CachedLatLon extends LatLon { |
| 8 | | private EastNorth eastNorth; |
| 9 | | private Projection proj; |
| 10 | 19 | |
| | 20 | private double east = java.lang.Double.NaN; |
| | 21 | private double north = java.lang.Double.NaN; |
| | 22 | |
| | 23 | /** |
| | 24 | * Constructor |
| | 25 | * |
| | 26 | * @param lat latitude |
| | 27 | * @param lon longitude |
| | 28 | */ |
| 11 | 29 | public CachedLatLon(double lat, double lon) { |
| 12 | | super(lat, lon); |
| | 30 | this(new LatLon(lat,lon)); |
| 13 | 31 | } |
| 14 | 32 | |
| | 33 | /** |
| | 34 | * Constructor |
| | 35 | * |
| | 36 | * @param coor lat/lon pair. If null, assumes lat/lon pair (0,0) |
| | 37 | */ |
| 15 | 38 | public CachedLatLon(LatLon coor) { |
| 16 | | super(coor.lat(), coor.lon()); |
| 17 | | proj = null; |
| | 39 | super(coor == null ? new LatLon(0,0) : coor); |
| 18 | 40 | } |
| 19 | 41 | |
| | 42 | /** |
| | 43 | * Constructor |
| | 44 | * |
| | 45 | * Inversely projects {@code eastNorth} using {@link Main#getProjection() the current projection}. Throws |
| | 46 | * an assertion exception, if this projection isn't set. |
| | 47 | * |
| | 48 | * @param eastNorth the projected east/north coordinates. Assumes (0/0) if null. |
| | 49 | */ |
| 20 | 50 | public CachedLatLon(EastNorth eastNorth) { |
| 21 | | super(Main.proj.eastNorth2latlon(eastNorth)); |
| 22 | | proj = Main.proj; |
| 23 | | this.eastNorth = eastNorth; |
| | 51 | super(Main.getProjection().eastNorth2latlon(eastNorth = eastNorth == null ? new EastNorth(0, 0) : eastNorth)); |
| | 52 | this.east = eastNorth.east(); |
| | 53 | this.north = eastNorth.north(); |
| 24 | 54 | } |
| 25 | 55 | |
| 26 | | public final void setCoor(LatLon coor) { |
| 27 | | setLocation(coor.lon(), coor.lat()); |
| 28 | | proj = null; |
| | 56 | /** |
| | 57 | * Replies the projected east/north coordinates. |
| | 58 | * |
| | 59 | * @return the internally cached east/north coordinates. null, if the globally defined projection is null |
| | 60 | */ |
| | 61 | public final EastNorth getEastNorth() { |
| | 62 | if (east == java.lang.Double.NaN && north == java.lang.Double.NaN) { |
| | 63 | Projection p = Main.getProjection(); |
| | 64 | if (p == null) return null; |
| | 65 | EastNorth en = p.latlon2eastNorth(this); |
| | 66 | this.east = en.east(); |
| | 67 | this.north = en.north(); |
| | 68 | return en; |
| | 69 | } else |
| | 70 | return new EastNorth(east, north); |
| 29 | 71 | } |
| 30 | 72 | |
| 31 | | public final void setEastNorth(EastNorth eastNorth) { |
| 32 | | proj = Main.proj; |
| 33 | | this.eastNorth = eastNorth; |
| 34 | | LatLon l = proj.eastNorth2latlon(eastNorth); |
| 35 | | setLocation(l.lon(), l.lat()); |
| | 73 | /** |
| | 74 | * Invalidate the internal cache for east/north coordinates |
| | 75 | */ |
| | 76 | public void invalidateEastNorthCache() { |
| | 77 | this.east = java.lang.Double.NaN; |
| | 78 | this.north = java.lang.Double.NaN; |
| 36 | 79 | } |
| 37 | 80 | |
| 38 | | public final EastNorth getEastNorth() { |
| 39 | | if(proj != Main.proj) |
| 40 | | { |
| 41 | | proj = Main.proj; |
| 42 | | eastNorth = proj.latlon2eastNorth(this); |
| 43 | | } |
| 44 | | return eastNorth; |
| 45 | | } |
| 46 | 81 | @Override public String toString() { |
| 47 | 82 | return "CachedLatLon[lat="+lat()+",lon="+lon()+"]"; |
| 48 | 83 | } |
| 49 | | |
| 50 | | // Only for Node.get3892DebugInfo() |
| 51 | | public Projection getProjection() { |
| 52 | | return proj; |
| 53 | | } |
| 54 | 84 | } |
-
diff --git a/src/org/openstreetmap/josm/data/coor/LatLon.java b/src/org/openstreetmap/josm/data/coor/LatLon.java
index 63ffdb5..084bc9c 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others |
| 2 | 2 | package org.openstreetmap.josm.data.coor; |
| 3 | 3 | |
| 4 | | import static org.openstreetmap.josm.tools.I18n.trc; |
| 5 | | |
| 6 | 4 | import static java.lang.Math.PI; |
| 7 | 5 | import static java.lang.Math.asin; |
| 8 | 6 | import static java.lang.Math.cos; |
| 9 | 7 | import static java.lang.Math.sin; |
| 10 | 8 | import static java.lang.Math.sqrt; |
| 11 | 9 | import static java.lang.Math.toRadians; |
| | 10 | import static org.openstreetmap.josm.tools.I18n.trc; |
| 12 | 11 | |
| 13 | 12 | import java.text.DecimalFormat; |
| 14 | 13 | import java.text.NumberFormat; |
| … |
… |
public class LatLon extends Coordinate {
|
| 105 | 104 | case DECIMAL_DEGREES: return cDdFormatter.format(y); |
| 106 | 105 | case DEGREES_MINUTES_SECONDS: return dms(y) + ((y < 0) ? SOUTH : NORTH); |
| 107 | 106 | case NAUTICAL: return dm(y) + ((y < 0) ? SOUTH : NORTH); |
| 108 | | case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).north()); |
| | 107 | case EAST_NORTH: return cDdFormatter.format(Main.getProjection().latlon2eastNorth(this).north()); |
| 109 | 108 | default: return "ERR"; |
| 110 | 109 | } |
| 111 | 110 | } |
| … |
… |
public class LatLon extends Coordinate {
|
| 121 | 120 | case DECIMAL_DEGREES: return cDdFormatter.format(x); |
| 122 | 121 | case DEGREES_MINUTES_SECONDS: return dms(x) + ((x < 0) ? WEST : EAST); |
| 123 | 122 | case NAUTICAL: return dm(x) + ((x < 0) ? WEST : EAST); |
| 124 | | case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).east()); |
| | 123 | case EAST_NORTH: return cDdFormatter.format(Main.getProjection().latlon2eastNorth(this).east()); |
| 125 | 124 | default: return "ERR"; |
| 126 | 125 | } |
| 127 | 126 | } |
| … |
… |
public class LatLon extends Coordinate {
|
| 141 | 140 | * by using lat/lon. |
| 142 | 141 | */ |
| 143 | 142 | public boolean isOutSideWorld() { |
| 144 | | Bounds b = Main.proj.getWorldBoundsLatLon(); |
| | 143 | Bounds b = Main.getProjection().getWorldBoundsLatLon(); |
| 145 | 144 | return lat() < b.getMin().lat() || lat() > b.getMax().lat() || |
| 146 | 145 | lon() < b.getMin().lon() || lon() > b.getMax().lon(); |
| 147 | 146 | } |
-
diff --git a/src/org/openstreetmap/josm/data/gpx/GpxTrack.java b/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
index db7c57d..ce837aa 100644
|
a
|
b
|
public interface GpxTrack {
|
| 25 | 25 | * @return Number of times this track has been changed. Always 0 for read-only tracks |
| 26 | 26 | */ |
| 27 | 27 | int getUpdateCount(); |
| 28 | | |
| 29 | 28 | } |
-
diff --git a/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java b/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java
index 5a6eff6..6e76bf3 100644
|
a
|
b
|
public class ImmutableGpxTrackSegment implements GpxTrackSegment {
|
| 64 | 64 | public int getUpdateCount() { |
| 65 | 65 | return 0; |
| 66 | 66 | } |
| 67 | | |
| 68 | 67 | } |
-
diff --git a/src/org/openstreetmap/josm/data/gpx/WayPoint.java b/src/org/openstreetmap/josm/data/gpx/WayPoint.java
index 94b41c6..3ec724d 100644
|
a
|
b
|
package org.openstreetmap.josm.data.gpx;
|
| 6 | 6 | import java.awt.Color; |
| 7 | 7 | import java.util.Date; |
| 8 | 8 | |
| 9 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| | 9 | import org.openstreetmap.josm.Main; |
| 10 | 10 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 11 | 11 | import org.openstreetmap.josm.data.coor.LatLon; |
| | 12 | import org.openstreetmap.josm.data.projection.Projection; |
| 12 | 13 | import org.openstreetmap.josm.tools.PrimaryDateParser; |
| 13 | 14 | |
| 14 | 15 | public class WayPoint extends WithAttributes implements Comparable<WayPoint> { |
| … |
… |
public class WayPoint extends WithAttributes implements Comparable<WayPoint> {
|
| 25 | 26 | public int dir; |
| 26 | 27 | |
| 27 | 28 | public WayPoint(LatLon ll) { |
| 28 | | coor = new CachedLatLon(ll); |
| | 29 | lat = ll.lat(); |
| | 30 | lon = ll.lon(); |
| 29 | 31 | } |
| 30 | 32 | |
| 31 | | private final CachedLatLon coor; |
| | 33 | /* |
| | 34 | * We "inline" lat/lon, rather than usinga LatLon internally => reduces memory overhead. Relevant |
| | 35 | * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server. |
| | 36 | */ |
| | 37 | private double lat = 0; |
| | 38 | private double lon = 0; |
| | 39 | |
| | 40 | /* |
| | 41 | * internal cache of projected coordinates |
| | 42 | */ |
| | 43 | private double east = Double.NaN; |
| | 44 | private double north = Double.NaN; |
| | 45 | |
| | 46 | private boolean isAlreadyProjected() { |
| | 47 | return ! Double.isNaN(east) && ! Double.isNaN(north); |
| | 48 | } |
| | 49 | |
| | 50 | /** |
| | 51 | * <p>Reproject the coordinates and refresh the internal cache of the projected coordinates.</p> |
| | 52 | */ |
| | 53 | public void reproject() { |
| | 54 | Projection p = Main.getProjection(); |
| | 55 | if (p == null){ |
| | 56 | east = Double.NaN; |
| | 57 | north = Double.NaN; |
| | 58 | return; |
| | 59 | } |
| | 60 | EastNorth en = p.latlon2eastNorth(getCoor()); |
| | 61 | east = en.east(); |
| | 62 | north = en.north(); |
| | 63 | } |
| | 64 | |
| | 65 | /** |
| | 66 | * Invalidate the internal cache of east/north coordinates. |
| | 67 | */ |
| | 68 | public void invalidateEastNorthCache() { |
| | 69 | this.east = Double.NaN; |
| | 70 | this.north = Double.NaN; |
| | 71 | } |
| 32 | 72 | |
| 33 | 73 | public final LatLon getCoor() { |
| 34 | | return coor; |
| | 74 | return new LatLon(lat,lon); |
| 35 | 75 | } |
| 36 | 76 | |
| | 77 | |
| | 78 | /** |
| | 79 | * <p>Replies the projected east/north coordinates.</p> |
| | 80 | * |
| | 81 | * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates. |
| | 82 | * Internally caches the projected coordinates.</p> |
| | 83 | * |
| | 84 | * <p><strong>Caveat:</strong> doesn't listen to projection changes. Clients must |
| | 85 | * {@link #reproject() trigger a reprojection} or {@link #invalidateEastNorthCache() invalidate the internal cache}.</p> |
| | 86 | * |
| | 87 | * <p>Replies {@code null}, if no global projection is defined.</p> |
| | 88 | * |
| | 89 | * @return the east north coordinates or {@code null} |
| | 90 | * @see #reproject() |
| | 91 | * @see #invalidateEastNorthCache() |
| | 92 | * |
| | 93 | */ |
| 37 | 94 | public final EastNorth getEastNorth() { |
| 38 | | return coor.getEastNorth(); |
| | 95 | if (isAlreadyProjected()) |
| | 96 | return new EastNorth(east, north); |
| | 97 | reproject(); |
| | 98 | if (!isAlreadyProjected()) return null; |
| | 99 | return new EastNorth(east, north); |
| 39 | 100 | } |
| 40 | 101 | |
| 41 | 102 | @Override |
| 42 | 103 | public String toString() { |
| 43 | | return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + coor.toString() + ", " + attr + ")"; |
| | 104 | return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + getCoor().toString() + ", " + attr + ")"; |
| 44 | 105 | } |
| 45 | 106 | |
| 46 | 107 | /** |
-
diff --git a/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java b/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
index d6d8c6c..838542a 100644
|
a
|
b
|
public class OffsetBookmark {
|
| 29 | 29 | |
| 30 | 30 | public boolean isUsable(ImageryLayer layer) { |
| 31 | 31 | if (proj == null) return false; |
| 32 | | if (!Main.proj.toCode().equals(proj.toCode())) return false; |
| | 32 | if (!Main.getProjection().toCode().equals(proj.toCode())) return false; |
| 33 | 33 | return layer.getInfo().getName().equals(layerName); |
| 34 | 34 | } |
| 35 | 35 | |
| … |
… |
public class OffsetBookmark {
|
| 121 | 121 | public static void bookmarkOffset(String name, ImageryLayer layer) { |
| 122 | 122 | LatLon center; |
| 123 | 123 | if (Main.map != null && Main.map.mapView != null) { |
| 124 | | center = Main.proj.eastNorth2latlon(Main.map.mapView.getCenter()); |
| | 124 | center = Main.getProjection().eastNorth2latlon(Main.map.mapView.getCenter()); |
| 125 | 125 | } else { |
| 126 | 126 | center = new LatLon(0,0); |
| 127 | 127 | } |
| 128 | 128 | OffsetBookmark nb = new OffsetBookmark( |
| 129 | | Main.proj, layer.getInfo().getName(), |
| | 129 | Main.getProjection(), layer.getInfo().getName(), |
| 130 | 130 | name, layer.getDx(), layer.getDy(), center.lon(), center.lat()); |
| 131 | 131 | for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) { |
| 132 | 132 | OffsetBookmark b = it.next(); |
-
diff --git a/src/org/openstreetmap/josm/data/osm/DataSet.java b/src/org/openstreetmap/josm/data/osm/DataSet.java
index 0cde797..dae4fac 100644
|
a
|
b
|
import java.util.concurrent.locks.Lock;
|
| 19 | 19 | import java.util.concurrent.locks.ReadWriteLock; |
| 20 | 20 | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| 21 | 21 | |
| | 22 | import org.openstreetmap.josm.Main; |
| 22 | 23 | import org.openstreetmap.josm.data.Bounds; |
| 23 | 24 | import org.openstreetmap.josm.data.SelectionChangedListener; |
| 24 | 25 | import org.openstreetmap.josm.data.coor.EastNorth; |
| … |
… |
import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
|
| 33 | 34 | import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; |
| 34 | 35 | import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; |
| 35 | 36 | import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; |
| | 37 | import org.openstreetmap.josm.data.projection.Projection; |
| | 38 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener; |
| 36 | 39 | import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; |
| 37 | 40 | import org.openstreetmap.josm.tools.FilteredCollection; |
| 38 | 41 | import org.openstreetmap.josm.tools.Predicate; |
| … |
… |
import org.openstreetmap.josm.tools.SubclassFilteredCollection;
|
| 82 | 85 | * |
| 83 | 86 | * @author imi |
| 84 | 87 | */ |
| 85 | | public class DataSet implements Cloneable { |
| | 88 | public class DataSet implements Cloneable, ProjectionChangeListener { |
| 86 | 89 | |
| 87 | 90 | /** |
| 88 | 91 | * Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent) |
| … |
… |
public class DataSet implements Cloneable {
|
| 120 | 123 | private final ReadWriteLock lock = new ReentrantReadWriteLock(); |
| 121 | 124 | private final Object selectionLock = new Object(); |
| 122 | 125 | |
| | 126 | public DataSet() { |
| | 127 | /* |
| | 128 | * Transparently register as projection change lister. No need to explicitly remove the |
| | 129 | * the listener, projection change listeners are managed as WeakReferences. |
| | 130 | */ |
| | 131 | Main.addProjectionChangeListener(this); |
| | 132 | } |
| | 133 | |
| 123 | 134 | public Lock getReadLock() { |
| 124 | 135 | return lock.readLock(); |
| 125 | 136 | } |
| … |
… |
public class DataSet implements Cloneable {
|
| 974 | 985 | highlightUpdateCount++; |
| 975 | 986 | } |
| 976 | 987 | |
| | 988 | |
| | 989 | /** |
| | 990 | * Triggers a refresh of cached projected coordinates. |
| | 991 | * |
| | 992 | * This method can be invoked after the globally configured projection method |
| | 993 | * changed. |
| | 994 | */ |
| | 995 | public void reproject() { |
| | 996 | if (Main.getProjection() == null) return; // sanity check |
| | 997 | try { |
| | 998 | beginUpdate(); |
| | 999 | for (OsmPrimitive p: allPrimitives) { |
| | 1000 | if ( ! (p instanceof Node)) { |
| | 1001 | continue; |
| | 1002 | } |
| | 1003 | Node n = (Node)p; |
| | 1004 | n.reproject(); |
| | 1005 | } |
| | 1006 | } finally { |
| | 1007 | endUpdate(); |
| | 1008 | } |
| | 1009 | } |
| | 1010 | |
| | 1011 | /** |
| | 1012 | * Invalidates the internal cache of projected east/north coordinates. |
| | 1013 | * |
| | 1014 | * This method can be invoked after the globally configured projection method |
| | 1015 | * changed. In contrast to {@link DataSet#reproject()} it only invalidates the |
| | 1016 | * cache and doesn't reproject the coordinates. |
| | 1017 | */ |
| | 1018 | public void invalidateEastNorthCache() { |
| | 1019 | if (Main.getProjection() == null) return; // sanity check |
| | 1020 | try { |
| | 1021 | beginUpdate(); |
| | 1022 | for (OsmPrimitive p: allPrimitives) { |
| | 1023 | if ( ! (p instanceof Node)) { |
| | 1024 | continue; |
| | 1025 | } |
| | 1026 | Node n = (Node)p; |
| | 1027 | n.invalidateEastNorthCache(); |
| | 1028 | } |
| | 1029 | } finally { |
| | 1030 | endUpdate(); |
| | 1031 | } |
| | 1032 | } |
| | 1033 | |
| 977 | 1034 | public void cleanupDeletedPrimitives() { |
| 978 | 1035 | beginUpdate(); |
| 979 | 1036 | try { |
| … |
… |
public class DataSet implements Cloneable {
|
| 1063 | 1120 | } |
| 1064 | 1121 | return ret; |
| 1065 | 1122 | } |
| | 1123 | |
| | 1124 | /* --------------------------------------------------------------------------------- */ |
| | 1125 | /* interface ProjectionChangeListner */ |
| | 1126 | /* --------------------------------------------------------------------------------- */ |
| | 1127 | @Override |
| | 1128 | public void projectionChanged(Projection oldValue, Projection newValue) { |
| | 1129 | invalidateEastNorthCache(); |
| | 1130 | } |
| 1066 | 1131 | } |
-
diff --git a/src/org/openstreetmap/josm/data/osm/INode.java b/src/org/openstreetmap/josm/data/osm/INode.java
index 68eb01d..40d6cc1 100644
|
a
|
b
|
import org.openstreetmap.josm.data.coor.EastNorth;
|
| 5 | 5 | import org.openstreetmap.josm.data.coor.LatLon; |
| 6 | 6 | |
| 7 | 7 | public interface INode extends IPrimitive { |
| 8 | | |
| | 8 | |
| 9 | 9 | LatLon getCoor(); |
| 10 | 10 | void setCoor(LatLon coor); |
| 11 | 11 | EastNorth getEastNorth(); |
| 12 | 12 | void setEastNorth(EastNorth eastNorth); |
| 13 | | |
| 14 | 13 | } |
-
diff --git a/src/org/openstreetmap/josm/data/osm/Node.java b/src/org/openstreetmap/josm/data/osm/Node.java
index d11bc81..155f61e 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others |
| 2 | 2 | package org.openstreetmap.josm.data.osm; |
| 3 | 3 | |
| 4 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| | 4 | import org.openstreetmap.josm.Main; |
| 5 | 5 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 6 | 6 | import org.openstreetmap.josm.data.coor.LatLon; |
| 7 | 7 | import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor; |
| 8 | 8 | import org.openstreetmap.josm.data.osm.visitor.Visitor; |
| 9 | | |
| | 9 | import org.openstreetmap.josm.data.projection.Projection; |
| | 10 | import org.openstreetmap.josm.data.projection.Projections; |
| 10 | 11 | /** |
| 11 | 12 | * One node data, consisting of one world coordinate waypoint. |
| 12 | 13 | * |
| … |
… |
import org.openstreetmap.josm.data.osm.visitor.Visitor;
|
| 14 | 15 | */ |
| 15 | 16 | public final class Node extends OsmPrimitive implements INode { |
| 16 | 17 | |
| 17 | | private CachedLatLon coor; |
| | 18 | /* |
| | 19 | * We "inline" lat/lon rather than using a LatLon-object => reduces memory footprint |
| | 20 | */ |
| | 21 | static private final double COORDINATE_NOT_DEFINED = Double.NaN; |
| | 22 | private double lat = COORDINATE_NOT_DEFINED; |
| | 23 | private double lon = COORDINATE_NOT_DEFINED; |
| | 24 | |
| | 25 | |
| | 26 | private boolean isLatLonKnown() { |
| | 27 | return lat != COORDINATE_NOT_DEFINED && lon != COORDINATE_NOT_DEFINED; |
| | 28 | } |
| 18 | 29 | |
| 19 | 30 | @Override |
| 20 | 31 | public final void setCoor(LatLon coor) { |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 45 | 56 | |
| 46 | 57 | @Override |
| 47 | 58 | public final LatLon getCoor() { |
| 48 | | return coor; |
| | 59 | if (!isLatLonKnown()) return null; |
| | 60 | return new LatLon(lat,lon); |
| 49 | 61 | } |
| 50 | 62 | |
| | 63 | /** |
| | 64 | * <p>Replies the projected east/north coordinates.</p> |
| | 65 | * |
| | 66 | * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates. |
| | 67 | * Internally caches the projected coordinates.</p> |
| | 68 | * |
| | 69 | * <p><strong>Caveat:</strong> doesn't listen to projection changes. Clients must |
| | 70 | * {@link #reproject() trigger a reprojection} or {@link #invalidateEastNorthCache() invalidate the internal cache}.</p> |
| | 71 | * |
| | 72 | * <p>Replies {@code null} if this node doesn't know lat/lon-coordinates, i.e. because it is an incomplete node. Also |
| | 73 | * replies {@code null}, if no global projection is defined.</p> |
| | 74 | * |
| | 75 | * @return the east north coordinates or {@code null} |
| | 76 | * @see #reproject() |
| | 77 | * @see #invalidateEastNorthCache() |
| | 78 | * |
| | 79 | */ |
| 51 | 80 | @Override |
| 52 | 81 | public final EastNorth getEastNorth() { |
| 53 | | return coor != null ? coor.getEastNorth() : null; |
| | 82 | if (!isLatLonKnown()) return null; |
| | 83 | Projection p = Main.getProjection(); |
| | 84 | if (p == null) return null; |
| | 85 | if (!isAlreadyProjected()) { |
| | 86 | reproject(); |
| | 87 | } |
| | 88 | return new EastNorth(east, north); |
| 54 | 89 | } |
| 55 | 90 | |
| 56 | 91 | /** |
| 57 | 92 | * To be used only by Dataset.reindexNode |
| 58 | 93 | */ |
| 59 | 94 | protected void setCoorInternal(LatLon coor, EastNorth eastNorth) { |
| 60 | | if(this.coor == null) { |
| 61 | | if (eastNorth == null) { |
| 62 | | this.coor = new CachedLatLon(coor); |
| 63 | | } else { |
| 64 | | this.coor = new CachedLatLon(eastNorth); |
| 65 | | } |
| 66 | | } else { |
| 67 | | if (eastNorth == null) { |
| 68 | | this.coor.setCoor(coor); |
| 69 | | } else { |
| 70 | | this.coor.setEastNorth(eastNorth); |
| 71 | | } |
| | 95 | if (coor != null){ |
| | 96 | this.lat = coor.lat(); |
| | 97 | this.lon = coor.lon(); |
| | 98 | invalidateEastNorthCache(); |
| | 99 | } else if (eastNorth != null) { |
| | 100 | LatLon ll = Projections.inverseProject(eastNorth); |
| | 101 | this.lat = ll.lat(); |
| | 102 | this.lon = ll.lon(); |
| | 103 | this.east = eastNorth.east(); |
| | 104 | this.north = eastNorth.north(); |
| 72 | 105 | } |
| 73 | 106 | } |
| 74 | 107 | |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 149 | 182 | boolean locked = writeLock(); |
| 150 | 183 | try { |
| 151 | 184 | super.cloneFrom(osm); |
| 152 | | setCoor(((Node)osm).coor); |
| | 185 | setCoor(((Node)osm).getCoor()); |
| 153 | 186 | } finally { |
| 154 | 187 | writeUnlock(locked); |
| 155 | 188 | } |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 172 | 205 | try { |
| 173 | 206 | super.mergeFrom(other); |
| 174 | 207 | if (!other.isIncomplete()) { |
| 175 | | setCoor(new LatLon(((Node)other).coor)); |
| | 208 | setCoor(new LatLon(((Node)other).getCoor())); |
| 176 | 209 | } |
| 177 | 210 | } finally { |
| 178 | 211 | writeUnlock(locked); |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 199 | 232 | } |
| 200 | 233 | |
| 201 | 234 | @Override public String toString() { |
| | 235 | LatLon coor = getCoor(); |
| 202 | 236 | String coorDesc = coor == null?"":"lat="+coor.lat()+",lon="+coor.lon(); |
| 203 | 237 | return "{Node id=" + getUniqueId() + " version=" + getVersion() + " " + getFlagsAsString() + " " + coorDesc+"}"; |
| 204 | 238 | } |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 210 | 244 | if (! super.hasEqualSemanticAttributes(other)) |
| 211 | 245 | return false; |
| 212 | 246 | Node n = (Node)other; |
| 213 | | if (coor == null && n.coor == null) |
| | 247 | LatLon coor = getCoor(); |
| | 248 | LatLon otherCoor = n.getCoor(); |
| | 249 | if (coor == null && otherCoor == null) |
| 214 | 250 | return true; |
| 215 | | else if (coor != null && n.coor != null) |
| 216 | | return coor.equalsEpsilon(n.coor); |
| | 251 | else if (coor != null && otherCoor != null) |
| | 252 | return coor.equalsEpsilon(otherCoor); |
| 217 | 253 | else |
| 218 | 254 | return false; |
| 219 | 255 | } |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 240 | 276 | |
| 241 | 277 | @Override |
| 242 | 278 | public void updatePosition() { |
| 243 | | // TODO: replace CachedLatLon with simple doubles and update precalculated EastNorth value here |
| 244 | 279 | } |
| 245 | 280 | |
| 246 | 281 | public boolean isConnectionNode() { |
| … |
… |
public final class Node extends OsmPrimitive implements INode {
|
| 252 | 287 | builder.append("Unexpected error. Please report it to http://josm.openstreetmap.de/ticket/3892\n"); |
| 253 | 288 | builder.append(toString()); |
| 254 | 289 | builder.append("\n"); |
| 255 | | if (coor == null) { |
| | 290 | if (isLatLonKnown()) { |
| 256 | 291 | builder.append("Coor is null\n"); |
| 257 | 292 | } else { |
| 258 | | builder.append(String.format("EastNorth: %s\n", coor.getEastNorth())); |
| 259 | | builder.append(coor.getProjection()); |
| | 293 | builder.append(String.format("EastNorth: %s\n", getEastNorth())); |
| | 294 | builder.append(Main.getProjection()); |
| 260 | 295 | builder.append("\n"); |
| 261 | 296 | } |
| 262 | 297 | |
| 263 | 298 | return builder.toString(); |
| 264 | 299 | } |
| | 300 | |
| | 301 | /* |
| | 302 | * the cached projected coordinates |
| | 303 | */ |
| | 304 | private double east = Double.NaN; |
| | 305 | private double north = Double.NaN; |
| | 306 | |
| | 307 | private boolean isAlreadyProjected() { |
| | 308 | return !Double.isNaN(east) && !Double.isNaN(north); |
| | 309 | } |
| | 310 | |
| | 311 | /** |
| | 312 | * <p>Refresh the internal cache of the projected node coordinates.</p> |
| | 313 | * |
| | 314 | * <p>Should be invoked after having switched to a new projection.</p> |
| | 315 | */ |
| | 316 | public void reproject() { |
| | 317 | if (!isLatLonKnown()) return; |
| | 318 | EastNorth en = Projections.project(getCoor()); |
| | 319 | this.east = en.east(); |
| | 320 | this.north = en.north(); |
| | 321 | } |
| | 322 | |
| | 323 | /** |
| | 324 | * Invoke to invalidate the internal cache of projected east/north coordinates. |
| | 325 | * Coordinates are reprojected on demand when the {@link #getEastNorth()} is invoked |
| | 326 | * next time. |
| | 327 | */ |
| | 328 | public void invalidateEastNorthCache() { |
| | 329 | this.east = Double.NaN; |
| | 330 | this.north = Double.NaN; |
| | 331 | } |
| 265 | 332 | } |
-
diff --git a/src/org/openstreetmap/josm/data/osm/NodeData.java b/src/org/openstreetmap/josm/data/osm/NodeData.java
index 16d7f81..73abbb8 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.data.osm; |
| 3 | 3 | |
| 4 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 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.Projections; |
| 8 | 8 | |
| 9 | 9 | public class NodeData extends PrimitiveData implements INode { |
| 10 | 10 | |
| 11 | | private final CachedLatLon coor = new CachedLatLon(0, 0); |
| | 11 | /* |
| | 12 | * we "inline" lat/lon coordinates instead of using a LatLon => reduces memory footprint |
| | 13 | */ |
| | 14 | private double lat = 0; |
| | 15 | private double lon = 0; |
| 12 | 16 | |
| 13 | | public NodeData() { |
| 14 | | |
| 15 | | } |
| | 17 | public NodeData() {} |
| 16 | 18 | |
| 17 | 19 | public NodeData(NodeData data) { |
| 18 | 20 | super(data); |
| … |
… |
public class NodeData extends PrimitiveData implements INode {
|
| 21 | 23 | |
| 22 | 24 | @Override |
| 23 | 25 | public LatLon getCoor() { |
| 24 | | return coor; |
| | 26 | return new LatLon(lat,lon); |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | @Override |
| 28 | 30 | public void setCoor(LatLon coor) { |
| 29 | | this.coor.setCoor(coor); |
| | 31 | if (coor == null) { |
| | 32 | this.lat = 0; |
| | 33 | this.lon = 0; |
| | 34 | } else { |
| | 35 | this.lat = coor.lat(); |
| | 36 | this.lon = coor.lon(); |
| | 37 | } |
| 30 | 38 | } |
| 31 | 39 | |
| 32 | 40 | @Override |
| 33 | 41 | public EastNorth getEastNorth() { |
| 34 | | return this.coor.getEastNorth(); |
| | 42 | /* |
| | 43 | * No internal caching of projected coordinates needed. In contrast to getEastNorth() |
| | 44 | * on Node, this method is rarely used. Caching would be overkill. |
| | 45 | */ |
| | 46 | return Projections.project(getCoor()); |
| 35 | 47 | } |
| 36 | 48 | |
| 37 | 49 | @Override |
| 38 | 50 | public void setEastNorth(EastNorth eastNorth) { |
| 39 | | this.coor.setEastNorth(eastNorth); |
| | 51 | LatLon ll = Projections.inverseProject(eastNorth); |
| | 52 | setCoor(ll); |
| 40 | 53 | } |
| 41 | 54 | |
| 42 | 55 | @Override |
| … |
… |
public class NodeData extends PrimitiveData implements INode {
|
| 46 | 59 | |
| 47 | 60 | @Override |
| 48 | 61 | public String toString() { |
| 49 | | return super.toString() + " NODE " + coor; |
| | 62 | return super.toString() + " NODE " + getCoor(); |
| 50 | 63 | } |
| 51 | 64 | |
| 52 | 65 | @Override |
| 53 | 66 | public OsmPrimitiveType getType() { |
| 54 | 67 | return OsmPrimitiveType.NODE; |
| 55 | 68 | } |
| 56 | | |
| 57 | | @Override |
| | 69 | |
| | 70 | @Override |
| 58 | 71 | public void visit(PrimitiveVisitor visitor) { |
| 59 | 72 | visitor.visit(this); |
| 60 | 73 | } |
| … |
… |
public class NodeData extends PrimitiveData implements INode {
|
| 63 | 76 | public String getDisplayName(NameFormatter formatter) { |
| 64 | 77 | return formatter.format(this); |
| 65 | 78 | } |
| 66 | | |
| 67 | 79 | } |
-
diff --git a/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java b/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
index 2c29454..63f8903 100644
|
a
|
b
|
import java.util.Collection;
|
| 6 | 6 | import org.openstreetmap.josm.Main; |
| 7 | 7 | import org.openstreetmap.josm.data.Bounds; |
| 8 | 8 | import org.openstreetmap.josm.data.ProjectionBounds; |
| 9 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 10 | 9 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 11 | 10 | import org.openstreetmap.josm.data.coor.LatLon; |
| 12 | 11 | import org.openstreetmap.josm.data.osm.Node; |
| … |
… |
public class BoundingXYVisitor extends AbstractVisitor {
|
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | public void visit(LatLon latlon) { |
| 64 | | if(latlon != null) |
| 65 | | { |
| 66 | | if(latlon instanceof CachedLatLon) { |
| 67 | | visit(((CachedLatLon)latlon).getEastNorth()); |
| 68 | | } else { |
| 69 | | visit(Main.proj.latlon2eastNorth(latlon)); |
| 70 | | } |
| | 63 | if(latlon != null){ |
| | 64 | visit(Main.getProjection().latlon2eastNorth(latlon)); |
| 71 | 65 | } |
| 72 | 66 | } |
| 73 | 67 | |
| … |
… |
public class BoundingXYVisitor extends AbstractVisitor {
|
| 112 | 106 | public void enlargeBoundingBox(double enlargeDegree) { |
| 113 | 107 | if (bounds == null) |
| 114 | 108 | return; |
| 115 | | LatLon minLatlon = Main.proj.eastNorth2latlon(bounds.getMin()); |
| 116 | | LatLon maxLatlon = Main.proj.eastNorth2latlon(bounds.getMax()); |
| | 109 | LatLon minLatlon = Main.getProjection().eastNorth2latlon(bounds.getMin()); |
| | 110 | LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax()); |
| 117 | 111 | bounds = new ProjectionBounds( |
| 118 | | Main.proj.latlon2eastNorth(new LatLon(minLatlon.lat() - enlargeDegree, minLatlon.lon() - enlargeDegree)), |
| 119 | | Main.proj.latlon2eastNorth(new LatLon(maxLatlon.lat() + enlargeDegree, maxLatlon.lon() + enlargeDegree))); |
| | 112 | Main.getProjection().latlon2eastNorth(new LatLon(minLatlon.lat() - enlargeDegree, minLatlon.lon() - enlargeDegree)), |
| | 113 | Main.getProjection().latlon2eastNorth(new LatLon(maxLatlon.lat() + enlargeDegree, maxLatlon.lon() + enlargeDegree))); |
| 120 | 114 | } |
| 121 | 115 | |
| 122 | 116 | @Override public String toString() { |
-
diff --git a/src/org/openstreetmap/josm/data/projection/ProjectionChangeListener.java b/src/org/openstreetmap/josm/data/projection/ProjectionChangeListener.java
new file mode 100644
index 0000000..f5accfc
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.data.projection; |
| | 3 | |
| | 4 | public interface ProjectionChangeListener { |
| | 5 | void projectionChanged(Projection oldValue, Projection newValue); |
| | 6 | } |
-
diff --git a/src/org/openstreetmap/josm/data/projection/Projections.java b/src/org/openstreetmap/josm/data/projection/Projections.java
index f31f7a9..10d0a2d 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others |
| 2 | 2 | package org.openstreetmap.josm.data.projection; |
| 3 | 3 | |
| 4 | | import java.util.Arrays; |
| 5 | 4 | import java.util.ArrayList; |
| | 5 | import java.util.Arrays; |
| | 6 | |
| | 7 | import org.openstreetmap.josm.Main; |
| | 8 | import org.openstreetmap.josm.data.coor.EastNorth; |
| | 9 | import org.openstreetmap.josm.data.coor.LatLon; |
| 6 | 10 | |
| 7 | 11 | /** |
| 8 | 12 | * Class to handle projections |
| … |
… |
public class Projections {
|
| 13 | 17 | * List of all available projections. |
| 14 | 18 | */ |
| 15 | 19 | private static ArrayList<Projection> allProjections = |
| 16 | | new ArrayList<Projection>(Arrays.asList(new Projection[] { |
| 17 | | // global projections |
| 18 | | new Epsg4326(), |
| 19 | | new Mercator(), |
| 20 | | new UTM(), |
| 21 | | // regional - alphabetical order by country name |
| 22 | | new LambertEST(), // Still needs proper default zoom |
| 23 | | new Lambert(), // Still needs proper default zoom |
| 24 | | new LambertCC9Zones(), // Still needs proper default zoom |
| 25 | | new UTM_France_DOM(), |
| 26 | | new TransverseMercatorLV(), |
| 27 | | new Puwg(), |
| 28 | | new Epsg3008(), // SWEREF99 13 30 |
| 29 | | new SwissGrid(), |
| 30 | | })); |
| | 20 | new ArrayList<Projection>(Arrays.asList(new Projection[] { |
| | 21 | // global projections |
| | 22 | new Epsg4326(), |
| | 23 | new Mercator(), |
| | 24 | new UTM(), |
| | 25 | // regional - alphabetical order by country name |
| | 26 | new LambertEST(), // Still needs proper default zoom |
| | 27 | new Lambert(), // Still needs proper default zoom |
| | 28 | new LambertCC9Zones(), // Still needs proper default zoom |
| | 29 | new UTM_France_DOM(), |
| | 30 | new TransverseMercatorLV(), |
| | 31 | new Puwg(), |
| | 32 | new Epsg3008(), // SWEREF99 13 30 |
| | 33 | new SwissGrid(), |
| | 34 | })); |
| 31 | 35 | |
| 32 | 36 | public static ArrayList<Projection> getProjections() { |
| 33 | 37 | return allProjections; |
| … |
… |
public class Projections {
|
| 42 | 46 | public static void addProjection(Projection proj) { |
| 43 | 47 | allProjections.add(proj); |
| 44 | 48 | } |
| | 49 | |
| | 50 | static public EastNorth project(LatLon ll) { |
| | 51 | return Main.getProjection().latlon2eastNorth(ll); |
| | 52 | } |
| | 53 | |
| | 54 | static public LatLon inverseProject(EastNorth en) { |
| | 55 | return Main.getProjection().eastNorth2latlon(en); |
| | 56 | } |
| 45 | 57 | } |
-
diff --git a/src/org/openstreetmap/josm/data/validation/OsmValidator.java b/src/org/openstreetmap/josm/data/validation/OsmValidator.java
index ce77780..7817efe 100644
|
a
|
b
|
import javax.swing.JOptionPane;
|
| 22 | 22 | |
| 23 | 23 | import org.openstreetmap.josm.Main; |
| 24 | 24 | import org.openstreetmap.josm.actions.ValidateAction; |
| 25 | | import org.openstreetmap.josm.actions.upload.ValidateUploadHook; |
| 26 | 25 | import org.openstreetmap.josm.data.projection.Epsg4326; |
| 27 | 26 | import org.openstreetmap.josm.data.projection.Lambert; |
| 28 | 27 | import org.openstreetmap.josm.data.projection.Mercator; |
| 29 | 28 | import org.openstreetmap.josm.data.validation.tests.Coastlines; |
| 30 | 29 | import org.openstreetmap.josm.data.validation.tests.CrossingWays; |
| 31 | 30 | import org.openstreetmap.josm.data.validation.tests.DuplicateNode; |
| 32 | | import org.openstreetmap.josm.data.validation.tests.DuplicateWay; |
| 33 | 31 | import org.openstreetmap.josm.data.validation.tests.DuplicateRelation; |
| | 32 | import org.openstreetmap.josm.data.validation.tests.DuplicateWay; |
| 34 | 33 | import org.openstreetmap.josm.data.validation.tests.DuplicatedWayNodes; |
| 35 | 34 | import org.openstreetmap.josm.data.validation.tests.MultipolygonTest; |
| 36 | 35 | import org.openstreetmap.josm.data.validation.tests.NameMismatch; |
| … |
… |
import org.openstreetmap.josm.data.validation.tests.UntaggedNode;
|
| 47 | 46 | import org.openstreetmap.josm.data.validation.tests.UntaggedWay; |
| 48 | 47 | import org.openstreetmap.josm.data.validation.tests.WronglyOrderedWays; |
| 49 | 48 | import org.openstreetmap.josm.gui.MapView.LayerChangeListener; |
| 50 | | import org.openstreetmap.josm.gui.layer.ValidatorLayer; |
| 51 | 49 | import org.openstreetmap.josm.gui.layer.Layer; |
| 52 | 50 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| | 51 | import org.openstreetmap.josm.gui.layer.ValidatorLayer; |
| 53 | 52 | import org.openstreetmap.josm.gui.preferences.ValidatorPreference; |
| 54 | 53 | |
| 55 | 54 | /** |
| … |
… |
public class OsmValidator implements LayerChangeListener {
|
| 76 | 75 | */ |
| 77 | 76 | @SuppressWarnings("unchecked") |
| 78 | 77 | public static Class<Test>[] allAvailableTests = new Class[] { |
| 79 | | DuplicateNode.class, // ID 1 .. 99 |
| 80 | | OverlappingWays.class, // ID 101 .. 199 |
| 81 | | UntaggedNode.class, // ID 201 .. 299 |
| 82 | | UntaggedWay.class, // ID 301 .. 399 |
| 83 | | SelfIntersectingWay.class, // ID 401 .. 499 |
| 84 | | DuplicatedWayNodes.class, // ID 501 .. 599 |
| 85 | | CrossingWays.class, // ID 601 .. 699 |
| 86 | | SimilarNamedWays.class, // ID 701 .. 799 |
| 87 | | NodesWithSameName.class, // ID 801 .. 899 |
| 88 | | Coastlines.class, // ID 901 .. 999 |
| 89 | | WronglyOrderedWays.class, // ID 1001 .. 1099 |
| 90 | | UnclosedWays.class, // ID 1101 .. 1199 |
| 91 | | TagChecker.class, // ID 1201 .. 1299 |
| 92 | | UnconnectedWays.class, // ID 1301 .. 1399 |
| 93 | | DuplicateWay.class, // ID 1401 .. 1499 |
| 94 | | NameMismatch.class, // ID 1501 .. 1599 |
| 95 | | MultipolygonTest.class, // ID 1601 .. 1699 |
| 96 | | RelationChecker.class, // ID 1701 .. 1799 |
| 97 | | TurnrestrictionTest.class, // ID 1801 .. 1899 |
| 98 | | DuplicateRelation.class, // ID 1901 .. 1999 |
| | 78 | DuplicateNode.class, // ID 1 .. 99 |
| | 79 | OverlappingWays.class, // ID 101 .. 199 |
| | 80 | UntaggedNode.class, // ID 201 .. 299 |
| | 81 | UntaggedWay.class, // ID 301 .. 399 |
| | 82 | SelfIntersectingWay.class, // ID 401 .. 499 |
| | 83 | DuplicatedWayNodes.class, // ID 501 .. 599 |
| | 84 | CrossingWays.class, // ID 601 .. 699 |
| | 85 | SimilarNamedWays.class, // ID 701 .. 799 |
| | 86 | NodesWithSameName.class, // ID 801 .. 899 |
| | 87 | Coastlines.class, // ID 901 .. 999 |
| | 88 | WronglyOrderedWays.class, // ID 1001 .. 1099 |
| | 89 | UnclosedWays.class, // ID 1101 .. 1199 |
| | 90 | TagChecker.class, // ID 1201 .. 1299 |
| | 91 | UnconnectedWays.class, // ID 1301 .. 1399 |
| | 92 | DuplicateWay.class, // ID 1401 .. 1499 |
| | 93 | NameMismatch.class, // ID 1501 .. 1599 |
| | 94 | MultipolygonTest.class, // ID 1601 .. 1699 |
| | 95 | RelationChecker.class, // ID 1701 .. 1799 |
| | 96 | TurnrestrictionTest.class, // ID 1801 .. 1899 |
| | 97 | DuplicateRelation.class, // ID 1901 .. 1999 |
| 99 | 98 | }; |
| 100 | 99 | |
| 101 | 100 | public OsmValidator() { |
| … |
… |
public class OsmValidator implements LayerChangeListener {
|
| 241 | 240 | * until most bugs were discovered while keeping the processing time reasonable) |
| 242 | 241 | */ |
| 243 | 242 | public void initializeGridDetail() { |
| 244 | | if (Main.proj.toString().equals(new Epsg4326().toString())) { |
| | 243 | if (Main.getProjection().toString().equals(new Epsg4326().toString())) { |
| 245 | 244 | OsmValidator.griddetail = 10000; |
| 246 | | } else if (Main.proj.toString().equals(new Mercator().toString())) { |
| | 245 | } else if (Main.getProjection().toString().equals(new Mercator().toString())) { |
| 247 | 246 | OsmValidator.griddetail = 0.01; |
| 248 | | } else if (Main.proj.toString().equals(new Lambert().toString())) { |
| | 247 | } else if (Main.getProjection().toString().equals(new Lambert().toString())) { |
| 249 | 248 | OsmValidator.griddetail = 0.1; |
| 250 | 249 | } |
| 251 | 250 | } |
| … |
… |
public class OsmValidator implements LayerChangeListener {
|
| 264 | 263 | e.printStackTrace(); |
| 265 | 264 | JOptionPane.showMessageDialog(Main.parent, |
| 266 | 265 | tr("Error initializing test {0}:\n {1}", test.getClass() |
| 267 | | .getSimpleName(), e), |
| 268 | | tr("Error"), |
| 269 | | JOptionPane.ERROR_MESSAGE); |
| | 266 | .getSimpleName(), e), |
| | 267 | tr("Error"), |
| | 268 | JOptionPane.ERROR_MESSAGE); |
| 270 | 269 | } |
| 271 | 270 | } |
| 272 | 271 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
index e4fe0db..0507b20 100644
|
a
|
b
|
public class MapView extends NavigatableComponent implements PropertyChangeListe
|
| 117 | 117 | * Adds an edit layer change listener |
| 118 | 118 | * |
| 119 | 119 | * @param listener the listener. Ignored if null or already registered. |
| 120 | | * @param initialFire Fire an edit-layer-changed-event right after adding |
| | 120 | * @param initialFire Fire an edit-layer-changed-event right after adding |
| 121 | 121 | * the listener in case there is an edit layer present |
| 122 | 122 | */ |
| 123 | 123 | public static void addEditLayerChangeListener(EditLayerChangeListener listener, boolean initialFire) { |
| … |
… |
public class MapView extends NavigatableComponent implements PropertyChangeListe
|
| 284 | 284 | setActiveLayer(layer); |
| 285 | 285 | } |
| 286 | 286 | layer.addPropertyChangeListener(this); |
| | 287 | Main.addProjectionChangeListener(layer); |
| 287 | 288 | AudioPlayer.reset(); |
| 288 | 289 | repaint(); |
| 289 | 290 | } |
| … |
… |
public class MapView extends NavigatableComponent implements PropertyChangeListe
|
| 358 | 359 | } |
| 359 | 360 | |
| 360 | 361 | layers.remove(layer); |
| | 362 | Main.removeProjectionChangeListener(layer); |
| 361 | 363 | fireLayerRemoved(layer); |
| 362 | 364 | layer.removePropertyChangeListener(this); |
| 363 | 365 | layer.destroy(); |
-
diff --git a/src/org/openstreetmap/josm/gui/NavigatableComponent.java b/src/org/openstreetmap/josm/gui/NavigatableComponent.java
index 32484c4..a1a6328 100644
|
a
|
b
|
import javax.swing.JComponent;
|
| 27 | 27 | import org.openstreetmap.josm.Main; |
| 28 | 28 | import org.openstreetmap.josm.data.Bounds; |
| 29 | 29 | import org.openstreetmap.josm.data.ProjectionBounds; |
| 30 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 31 | 30 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 32 | 31 | import org.openstreetmap.josm.data.coor.LatLon; |
| 33 | 32 | import org.openstreetmap.josm.data.osm.BBox; |
| … |
… |
import org.openstreetmap.josm.data.osm.Way;
|
| 38 | 37 | import org.openstreetmap.josm.data.osm.WaySegment; |
| 39 | 38 | import org.openstreetmap.josm.data.preferences.IntegerProperty; |
| 40 | 39 | import org.openstreetmap.josm.data.projection.Projection; |
| | 40 | import org.openstreetmap.josm.data.projection.Projections; |
| 41 | 41 | import org.openstreetmap.josm.gui.help.Helpful; |
| 42 | 42 | import org.openstreetmap.josm.gui.preferences.ProjectionPreference; |
| 43 | 43 | import org.openstreetmap.josm.tools.Predicate; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 95 | 95 | * every physical pixel on screen are 10 x or 10 y units in the |
| 96 | 96 | * northing/easting space of the projection. |
| 97 | 97 | */ |
| 98 | | private double scale = Main.proj.getDefaultZoomInPPD(); |
| | 98 | private double scale = Main.getProjection().getDefaultZoomInPPD(); |
| 99 | 99 | /** |
| 100 | 100 | * Center n/e coordinate of the desired screen center. |
| 101 | 101 | */ |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | private EastNorth calculateDefaultCenter() { |
| 113 | | Bounds b = Main.proj.getWorldBoundsLatLon(); |
| | 113 | Bounds b = Main.getProjection().getWorldBoundsLatLon(); |
| 114 | 114 | double lat = (b.getMax().lat() + b.getMin().lat())/2; |
| 115 | 115 | double lon = (b.getMax().lon() + b.getMin().lon())/2; |
| 116 | 116 | |
| 117 | | return Main.proj.latlon2eastNorth(new LatLon(lat, lon)); |
| | 117 | return Main.getProjection().latlon2eastNorth(new LatLon(lat, lon)); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public static String getDistText(double dist) { |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 208 | 208 | EastNorth p1 = getEastNorth(r.x, r.y); |
| 209 | 209 | EastNorth p2 = getEastNorth(r.x + r.width, r.y + r.height); |
| 210 | 210 | |
| 211 | | Bounds result = new Bounds(Main.proj.eastNorth2latlon(p1)); |
| | 211 | Bounds result = new Bounds(Main.getProjection().eastNorth2latlon(p1)); |
| 212 | 212 | |
| 213 | 213 | double eastMin = Math.min(p1.east(), p2.east()); |
| 214 | 214 | double eastMax = Math.max(p1.east(), p2.east()); |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 218 | 218 | double deltaNorth = (northMax - northMin) / 10; |
| 219 | 219 | |
| 220 | 220 | for (int i=0; i < 10; i++) { |
| 221 | | result.extend(Main.proj.eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMin))); |
| 222 | | result.extend(Main.proj.eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMax))); |
| 223 | | result.extend(Main.proj.eastNorth2latlon(new EastNorth(eastMin, northMin + i * deltaNorth))); |
| 224 | | result.extend(Main.proj.eastNorth2latlon(new EastNorth(eastMax, northMin + i * deltaNorth))); |
| | 221 | result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMin))); |
| | 222 | result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMax))); |
| | 223 | result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin, northMin + i * deltaNorth))); |
| | 224 | result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMax, northMin + i * deltaNorth))); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return result; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 244 | 244 | public Point2D getPoint2D(LatLon latlon) { |
| 245 | 245 | if (latlon == null) |
| 246 | 246 | return new Point(); |
| 247 | | else if (latlon instanceof CachedLatLon) |
| 248 | | return getPoint2D(((CachedLatLon)latlon).getEastNorth()); |
| 249 | | else |
| 250 | | return getPoint2D(getProjection().latlon2eastNorth(latlon)); |
| | 247 | return getPoint2D(Projections.project(latlon)); |
| 251 | 248 | } |
| | 249 | |
| 252 | 250 | public Point2D getPoint2D(Node n) { |
| 253 | 251 | return getPoint2D(n.getEastNorth()); |
| 254 | 252 | } |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 281 | 279 | */ |
| 282 | 280 | public void zoomTo(EastNorth newCenter, double newScale) { |
| 283 | 281 | Bounds b = getProjection().getWorldBoundsLatLon(); |
| 284 | | CachedLatLon cl = new CachedLatLon(newCenter); |
| | 282 | LatLon cl = Projections.inverseProject(newCenter); |
| 285 | 283 | boolean changed = false; |
| 286 | 284 | double lat = cl.lat(); |
| 287 | 285 | double lon = cl.lon(); |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 290 | 288 | if(lon < b.getMin().lon()) {changed = true; lon = b.getMin().lon(); } |
| 291 | 289 | else if(lon > b.getMax().lon()) {changed = true; lon = b.getMax().lon(); } |
| 292 | 290 | if(changed) { |
| 293 | | newCenter = new CachedLatLon(lat, lon).getEastNorth(); |
| | 291 | newCenter = Projections.project(new LatLon(lat,lon)); |
| 294 | 292 | } |
| 295 | 293 | int width = getWidth()/2; |
| 296 | 294 | int height = getHeight()/2; |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 349 | 347 | } |
| 350 | 348 | |
| 351 | 349 | public void zoomTo(LatLon newCenter) { |
| 352 | | if(newCenter instanceof CachedLatLon) { |
| 353 | | zoomTo(((CachedLatLon)newCenter).getEastNorth(), scale); |
| 354 | | } else { |
| 355 | | zoomTo(getProjection().latlon2eastNorth(newCenter), scale); |
| 356 | | } |
| | 350 | zoomTo(Projections.project(newCenter)); |
| 357 | 351 | } |
| 358 | 352 | |
| 359 | 353 | public void smoothScrollTo(LatLon newCenter) { |
| 360 | | if (newCenter instanceof CachedLatLon) { |
| 361 | | smoothScrollTo(((CachedLatLon)newCenter).getEastNorth()); |
| 362 | | } else { |
| 363 | | smoothScrollTo(getProjection().latlon2eastNorth(newCenter)); |
| 364 | | } |
| | 354 | smoothScrollTo(Projections.project(newCenter)); |
| 365 | 355 | } |
| 366 | 356 | |
| 367 | 357 | /** |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 440 | 430 | double scale; |
| 441 | 431 | |
| 442 | 432 | public ZoomData(EastNorth center, double scale) { |
| 443 | | this.center = new CachedLatLon(center); |
| | 433 | this.center = Projections.inverseProject(center); |
| 444 | 434 | this.scale = scale; |
| 445 | 435 | } |
| 446 | 436 | |
| … |
… |
public class NavigatableComponent extends JComponent implements Helpful {
|
| 1144 | 1134 | * @return The projection to be used in calculating stuff. |
| 1145 | 1135 | */ |
| 1146 | 1136 | public Projection getProjection() { |
| 1147 | | return Main.proj; |
| | 1137 | return Main.getProjection(); |
| 1148 | 1138 | } |
| 1149 | 1139 | |
| 1150 | 1140 | public String helpTopic() { |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/GpxLayer.java b/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
index 83e9df8..e734736 100644
|
a
|
b
|
import org.openstreetmap.josm.data.Bounds;
|
| 51 | 51 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 52 | 52 | import org.openstreetmap.josm.data.coor.LatLon; |
| 53 | 53 | import org.openstreetmap.josm.data.gpx.GpxData; |
| | 54 | import org.openstreetmap.josm.data.gpx.GpxRoute; |
| 54 | 55 | import org.openstreetmap.josm.data.gpx.GpxTrack; |
| 55 | 56 | import org.openstreetmap.josm.data.gpx.GpxTrackSegment; |
| 56 | 57 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| … |
… |
import org.openstreetmap.josm.data.osm.DataSet;
|
| 58 | 59 | import org.openstreetmap.josm.data.osm.Node; |
| 59 | 60 | import org.openstreetmap.josm.data.osm.Way; |
| 60 | 61 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; |
| | 62 | import org.openstreetmap.josm.data.projection.Projection; |
| 61 | 63 | import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; |
| 62 | 64 | import org.openstreetmap.josm.gui.HelpAwareOptionPane; |
| 63 | 65 | import org.openstreetmap.josm.gui.MapView; |
| … |
… |
public class GpxLayer extends Layer {
|
| 329 | 331 | lastTracks.addAll(data.tracks); |
| 330 | 332 | |
| 331 | 333 | g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
| 332 | | Main.pref.getBoolean("mappaint.gpx.use-antialiasing", false) ? |
| 333 | | RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); |
| | 334 | Main.pref.getBoolean("mappaint.gpx.use-antialiasing", false) ? |
| | 335 | RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); |
| 334 | 336 | |
| 335 | 337 | /**************************************************************** |
| 336 | 338 | ********** STEP 1 - GET CONFIG VALUES ************************** |
| … |
… |
public class GpxLayer extends Layer {
|
| 1230 | 1232 | } |
| 1231 | 1233 | if (bestEN == null) |
| 1232 | 1234 | return null; |
| 1233 | | WayPoint best = new WayPoint(Main.proj.eastNorth2latlon(bestEN)); |
| | 1235 | WayPoint best = new WayPoint(Main.getProjection().eastNorth2latlon(bestEN)); |
| 1234 | 1236 | best.time = bestTime; |
| 1235 | 1237 | return best; |
| 1236 | 1238 | } |
| … |
… |
public class GpxLayer extends Layer {
|
| 1489 | 1491 | addRecursiveFiles(files, sel); |
| 1490 | 1492 | importer.importDataHandleExceptions(files, NullProgressMonitor.INSTANCE); |
| 1491 | 1493 | } |
| | 1494 | } |
| 1492 | 1495 | |
| | 1496 | @Override |
| | 1497 | public void projectionChanged(Projection oldValue, Projection newValue) { |
| | 1498 | if (newValue == null) return; |
| | 1499 | if (data.waypoints != null) { |
| | 1500 | for (WayPoint wp : data.waypoints){ |
| | 1501 | wp.invalidateEastNorthCache(); |
| | 1502 | } |
| | 1503 | } |
| | 1504 | if (data.tracks != null){ |
| | 1505 | for (GpxTrack track: data.tracks) { |
| | 1506 | for (GpxTrackSegment segment: track.getSegments()) { |
| | 1507 | for (WayPoint wp: segment.getWayPoints()) { |
| | 1508 | wp.invalidateEastNorthCache(); |
| | 1509 | } |
| | 1510 | } |
| | 1511 | } |
| | 1512 | } |
| | 1513 | if (data.routes != null) { |
| | 1514 | for (GpxRoute route: data.routes) { |
| | 1515 | if (route.routePoints == null) { |
| | 1516 | continue; |
| | 1517 | } |
| | 1518 | for (WayPoint wp: route.routePoints) { |
| | 1519 | wp.invalidateEastNorthCache(); |
| | 1520 | } |
| | 1521 | } |
| | 1522 | } |
| 1493 | 1523 | } |
| 1494 | 1524 | } |
| | 1525 | No newline at end of file |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java b/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
index 6520532..497cff9 100644
|
a
|
b
|
public abstract class ImageryLayer extends Layer {
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public double getPPD(){ |
| 85 | | if (Main.map == null || Main.map.mapView == null) return Main.proj.getDefaultZoomInPPD(); |
| | 85 | if (Main.map == null || Main.map.mapView == null) return Main.getProjection().getDefaultZoomInPPD(); |
| 86 | 86 | ProjectionBounds bounds = Main.map.mapView.getProjectionBounds(); |
| 87 | 87 | return Main.map.mapView.getWidth() / (bounds.maxEast - bounds.minEast); |
| 88 | 88 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/Layer.java b/src/org/openstreetmap/josm/gui/layer/Layer.java
index f6ee43c..0bf99a0 100644
|
a
|
b
|
import org.openstreetmap.josm.actions.SaveAction;
|
| 22 | 22 | import org.openstreetmap.josm.actions.SaveAsAction; |
| 23 | 23 | import org.openstreetmap.josm.data.Bounds; |
| 24 | 24 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; |
| | 25 | import org.openstreetmap.josm.data.projection.Projection; |
| | 26 | import org.openstreetmap.josm.data.projection.ProjectionChangeListener; |
| 25 | 27 | import org.openstreetmap.josm.gui.MapView; |
| 26 | 28 | import org.openstreetmap.josm.tools.Destroyable; |
| 27 | 29 | import org.openstreetmap.josm.tools.ImageProvider; |
| … |
… |
import org.openstreetmap.josm.tools.ImageProvider;
|
| 41 | 43 | * |
| 42 | 44 | * @author imi |
| 43 | 45 | */ |
| 44 | | abstract public class Layer implements Destroyable, MapViewPaintable { |
| | 46 | abstract public class Layer implements Destroyable, MapViewPaintable, ProjectionChangeListener { |
| 45 | 47 | |
| 46 | 48 | public interface LayerAction { |
| 47 | 49 | boolean supportLayers(List<Layer> layers); |
| … |
… |
abstract public class Layer implements Destroyable, MapViewPaintable {
|
| 361 | 363 | new GpxExportAction().export(layer); |
| 362 | 364 | } |
| 363 | 365 | } |
| | 366 | |
| | 367 | /* --------------------------------------------------------------------------------- */ |
| | 368 | /* interface ProjectionChangeListener */ |
| | 369 | /* --------------------------------------------------------------------------------- */ |
| | 370 | @Override |
| | 371 | public void projectionChanged(Projection oldValue, Projection newValue) { |
| | 372 | // default implementation does nothing - override in subclasses |
| | 373 | } |
| 364 | 374 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
index 32fda21..7725a92 100644
|
a
|
b
|
import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor;
|
| 61 | 61 | import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; |
| 62 | 62 | import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory; |
| 63 | 63 | import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; |
| | 64 | import org.openstreetmap.josm.data.projection.Projection; |
| 64 | 65 | import org.openstreetmap.josm.data.validation.TestError; |
| 65 | 66 | import org.openstreetmap.josm.gui.HelpAwareOptionPane; |
| 66 | 67 | import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; |
| … |
… |
import org.openstreetmap.josm.tools.ImageProvider;
|
| 79 | 80 | * @author imi |
| 80 | 81 | */ |
| 81 | 82 | public class OsmDataLayer extends Layer implements Listener, SelectionChangedListener { |
| | 83 | // static private final Logger logger = Logger.getLogger(OsmDataLayer.class.getName()); |
| | 84 | |
| 82 | 85 | static public final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk"; |
| 83 | 86 | static public final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer"; |
| 84 | 87 | |
| … |
… |
public class OsmDataLayer extends Layer implements Listener, SelectionChangedLis
|
| 657 | 660 | JOptionPane.showMessageDialog(Main.parent, p, tr("Warning"), JOptionPane.WARNING_MESSAGE); |
| 658 | 661 | } |
| 659 | 662 | } |
| 660 | | |
| 661 | 663 | } |
| 662 | 664 | |
| 663 | 665 | @Override |
| … |
… |
public class OsmDataLayer extends Layer implements Listener, SelectionChangedLis
|
| 674 | 676 | public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { |
| 675 | 677 | isChanged = true; |
| 676 | 678 | } |
| | 679 | |
| | 680 | @Override |
| | 681 | public void projectionChanged(Projection oldValue, Projection newValue) { |
| | 682 | /* |
| | 683 | * No reprojection required. The dataset itself is registered as projection |
| | 684 | * change listener and already got notified. |
| | 685 | */ |
| | 686 | } |
| 677 | 687 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java b/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
index bb41ddc..4acce3f 100644
|
a
|
b
|
public class RawGpsLayer extends Layer implements PreferenceChangedListener {
|
| 94 | 94 | public final String time; |
| 95 | 95 | public GpsPoint(LatLon ll, String t) { |
| 96 | 96 | latlon = ll; |
| 97 | | eastNorth = Main.proj.latlon2eastNorth(ll); |
| | 97 | eastNorth = Main.getProjection().latlon2eastNorth(ll); |
| 98 | 98 | time = t; |
| 99 | 99 | } |
| 100 | 100 | } |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/TMSLayer.java b/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
index 360a6fc..3423be1 100644
|
a
|
b
|
public class TMSLayer extends ImageryLayer implements ImageObserver, TileLoaderL
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | private Point pixelPos(LatLon ll) { |
| 873 | | return Main.map.mapView.getPoint(Main.proj.latlon2eastNorth(ll).add(getDx(), getDy())); |
| | 873 | return Main.map.mapView.getPoint(Main.getProjection().latlon2eastNorth(ll).add(getDx(), getDy())); |
| 874 | 874 | } |
| 875 | 875 | private Point pixelPos(Tile t) { |
| 876 | 876 | double lon = tileSource.tileXToLon(t.getXtile(), t.getZoom()); |
| … |
… |
public class TMSLayer extends ImageryLayer implements ImageObserver, TileLoaderL
|
| 878 | 878 | return pixelPos(tmpLL); |
| 879 | 879 | } |
| 880 | 880 | private LatLon getShiftedLatLon(EastNorth en) { |
| 881 | | return Main.proj.eastNorth2latlon(en.add(-getDx(), -getDy())); |
| | 881 | return Main.getProjection().eastNorth2latlon(en.add(-getDx(), -getDy())); |
| 882 | 882 | } |
| 883 | 883 | private Coordinate getShiftedCoord(EastNorth en) { |
| 884 | 884 | LatLon ll = getShiftedLatLon(en); |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java b/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
index 5731554..9de7e28 100644
|
a
|
b
|
import java.awt.Image;
|
| 9 | 9 | import java.io.File; |
| 10 | 10 | import java.util.Date; |
| 11 | 11 | |
| 12 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 13 | 12 | import org.openstreetmap.josm.data.coor.LatLon; |
| 14 | 13 | |
| 15 | 14 | /* |
| … |
… |
final public class ImageEntry implements Comparable<ImageEntry>, Cloneable {
|
| 24 | 23 | Image thumbnail; |
| 25 | 24 | |
| 26 | 25 | /** The following values are computed from the correlation with the gpx track */ |
| 27 | | private CachedLatLon pos; |
| | 26 | private LatLon pos; |
| 28 | 27 | /** Speed in kilometer per second */ |
| 29 | 28 | private Double speed; |
| 30 | 29 | /** Elevation (altitude) in meters */ |
| … |
… |
final public class ImageEntry implements Comparable<ImageEntry>, Cloneable {
|
| 45 | 44 | /** |
| 46 | 45 | * getter methods that refer to the temporary value |
| 47 | 46 | */ |
| 48 | | public CachedLatLon getPos() { |
| | 47 | public LatLon getPos() { |
| 49 | 48 | if (tmp != null) |
| 50 | 49 | return tmp.pos; |
| 51 | 50 | return pos; |
| … |
… |
final public class ImageEntry implements Comparable<ImageEntry>, Cloneable {
|
| 85 | 84 | /** |
| 86 | 85 | * setter methods |
| 87 | 86 | */ |
| 88 | | public void setPos(CachedLatLon pos) { |
| 89 | | this.pos = pos; |
| 90 | | } |
| 91 | 87 | public void setPos(LatLon pos) { |
| 92 | | this.pos = new CachedLatLon(pos); |
| | 88 | this.pos = pos; |
| 93 | 89 | } |
| 94 | 90 | public void setSpeed(Double speed) { |
| 95 | 91 | this.speed = speed; |
-
diff --git a/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java b/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
index 6236ea3..e35a75d 100644
|
a
|
b
|
import java.util.Map;
|
| 15 | 15 | |
| 16 | 16 | import javax.swing.Icon; |
| 17 | 17 | |
| 18 | | import org.openstreetmap.josm.data.coor.CachedLatLon; |
| 19 | 18 | import org.openstreetmap.josm.data.coor.EastNorth; |
| 20 | 19 | import org.openstreetmap.josm.data.coor.LatLon; |
| 21 | 20 | import org.openstreetmap.josm.data.gpx.GpxData; |
| 22 | 21 | import org.openstreetmap.josm.data.gpx.GpxLink; |
| 23 | 22 | import org.openstreetmap.josm.data.gpx.WayPoint; |
| 24 | 23 | import org.openstreetmap.josm.data.preferences.IntegerProperty; |
| | 24 | import org.openstreetmap.josm.data.projection.Projections; |
| 25 | 25 | import org.openstreetmap.josm.gui.MapView; |
| 26 | 26 | import org.openstreetmap.josm.tools.ImageProvider; |
| 27 | 27 | |
| … |
… |
public class Marker implements ActionListener {
|
| 69 | 69 | public double offset; /* time offset in seconds from the gpx point from which it was derived, |
| 70 | 70 | may be adjusted later to sync with other data, so not final */ |
| 71 | 71 | |
| 72 | | private CachedLatLon coor; |
| | 72 | private LatLon coor; |
| 73 | 73 | |
| 74 | 74 | public final void setCoor(LatLon coor) { |
| 75 | | if(this.coor == null) { |
| 76 | | this.coor = new CachedLatLon(coor); |
| 77 | | } else { |
| 78 | | this.coor.setCoor(coor); |
| 79 | | } |
| | 75 | this.coor = new LatLon(coor); |
| 80 | 76 | } |
| 81 | 77 | |
| 82 | 78 | public final LatLon getCoor() { |
| … |
… |
public class Marker implements ActionListener {
|
| 84 | 80 | } |
| 85 | 81 | |
| 86 | 82 | public final void setEastNorth(EastNorth eastNorth) { |
| 87 | | coor.setEastNorth(eastNorth); |
| | 83 | this.coor = Projections.inverseProject(eastNorth); |
| 88 | 84 | } |
| 89 | 85 | |
| 90 | 86 | public final EastNorth getEastNorth() { |
| 91 | | return coor.getEastNorth(); |
| | 87 | return Projections.project(this.coor); |
| 92 | 88 | } |
| 93 | 89 | |
| 94 | 90 | /** |
| … |
… |
public class Marker implements ActionListener {
|
| 263 | 259 | * @return Text |
| 264 | 260 | */ |
| 265 | 261 | public String getText() { |
| 266 | | if (this.text != null ) { |
| | 262 | if (this.text != null ) |
| 267 | 263 | return this.text; |
| 268 | | } |
| 269 | | else { |
| | 264 | else |
| 270 | 265 | return getText(this.textMap); |
| 271 | | } |
| 272 | 266 | } |
| 273 | 267 | |
| 274 | 268 | /** |
| … |
… |
public class Marker implements ActionListener {
|
| 284 | 278 | if (textMap != null && !textMap.isEmpty()) { |
| 285 | 279 | switch(PROP_LABEL.get()) |
| 286 | 280 | { |
| 287 | | // name |
| 288 | | case 1: |
| 289 | | { |
| 290 | | if (textMap.containsKey("name")) { |
| 291 | | text = textMap.get("name"); |
| 292 | | } |
| 293 | | break; |
| | 281 | // name |
| | 282 | case 1: |
| | 283 | { |
| | 284 | if (textMap.containsKey("name")) { |
| | 285 | text = textMap.get("name"); |
| 294 | 286 | } |
| | 287 | break; |
| | 288 | } |
| 295 | 289 | |
| 296 | | // desc |
| 297 | | case 2: |
| 298 | | { |
| 299 | | if (textMap.containsKey("desc")) { |
| 300 | | text = textMap.get("desc"); |
| 301 | | } |
| 302 | | break; |
| | 290 | // desc |
| | 291 | case 2: |
| | 292 | { |
| | 293 | if (textMap.containsKey("desc")) { |
| | 294 | text = textMap.get("desc"); |
| 303 | 295 | } |
| | 296 | break; |
| | 297 | } |
| 304 | 298 | |
| 305 | | // auto |
| 306 | | case 0: |
| | 299 | // auto |
| | 300 | case 0: |
| 307 | 301 | // both |
| 308 | | case 3: |
| 309 | | { |
| 310 | | if (textMap.containsKey("name")) { |
| 311 | | text = textMap.get("name"); |
| 312 | | |
| 313 | | if (textMap.containsKey("desc")) { |
| 314 | | if (PROP_LABEL.get() != 0 || !text.equals(textMap.get("desc"))) { |
| 315 | | text += " - " + textMap.get("desc"); |
| 316 | | } |
| | 302 | case 3: |
| | 303 | { |
| | 304 | if (textMap.containsKey("name")) { |
| | 305 | text = textMap.get("name"); |
| | 306 | |
| | 307 | if (textMap.containsKey("desc")) { |
| | 308 | if (PROP_LABEL.get() != 0 || !text.equals(textMap.get("desc"))) { |
| | 309 | text += " - " + textMap.get("desc"); |
| 317 | 310 | } |
| 318 | 311 | } |
| 319 | | else if (textMap.containsKey("desc")) { |
| 320 | | text = textMap.get("desc"); |
| 321 | | } |
| 322 | | break; |
| 323 | 312 | } |
| 324 | | |
| 325 | | // none |
| 326 | | case 4: |
| 327 | | default: |
| 328 | | { |
| 329 | | text = ""; |
| 330 | | break; |
| | 313 | else if (textMap.containsKey("desc")) { |
| | 314 | text = textMap.get("desc"); |
| 331 | 315 | } |
| | 316 | break; |
| | 317 | } |
| | 318 | |
| | 319 | // none |
| | 320 | case 4: |
| | 321 | default: |
| | 322 | { |
| | 323 | text = ""; |
| | 324 | break; |
| | 325 | } |
| 332 | 326 | } |
| 333 | 327 | } |
| 334 | 328 | |
-
diff --git a/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java b/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java
index e5fa737..60502e7 100644
|
a
|
b
|
public class ImageryPreference implements PreferenceSetting {
|
| 733 | 733 | add.addActionListener(new ActionListener() { |
| 734 | 734 | @Override |
| 735 | 735 | public void actionPerformed(ActionEvent e) { |
| 736 | | OffsetBookmark b = new OffsetBookmark(Main.proj,"","",0,0); |
| | 736 | OffsetBookmark b = new OffsetBookmark(Main.getProjection(),"","",0,0); |
| 737 | 737 | model.addRow(b); |
| 738 | 738 | } |
| 739 | 739 | }); |
-
diff --git a/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java b/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
index 9d0b41e..b834a77 100644
|
a
|
b
|
import java.awt.event.ActionEvent;
|
| 8 | 8 | import java.awt.event.ActionListener; |
| 9 | 9 | import java.util.ArrayList; |
| 10 | 10 | import java.util.Collection; |
| 11 | | import java.util.concurrent.CopyOnWriteArrayList; |
| 12 | 11 | |
| 13 | 12 | import javax.swing.BorderFactory; |
| 14 | 13 | import javax.swing.JComboBox; |
| … |
… |
import org.openstreetmap.josm.data.preferences.ParametrizedCollectionProperty;
|
| 26 | 25 | import org.openstreetmap.josm.data.preferences.StringProperty; |
| 27 | 26 | import org.openstreetmap.josm.data.projection.Mercator; |
| 28 | 27 | import org.openstreetmap.josm.data.projection.Projection; |
| 29 | | import org.openstreetmap.josm.data.projection.Projections; |
| 30 | 28 | import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; |
| | 29 | import org.openstreetmap.josm.data.projection.Projections; |
| 31 | 30 | import org.openstreetmap.josm.gui.NavigatableComponent; |
| 32 | 31 | import org.openstreetmap.josm.plugins.PluginHandler; |
| 33 | 32 | import org.openstreetmap.josm.tools.GBC; |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 40 | 39 | } |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | | public interface ProjectionChangedListener { |
| 44 | | void projectionChanged(); |
| 45 | | } |
| 46 | | |
| 47 | 42 | private static final StringProperty PROP_PROJECTION = new StringProperty("projection", Mercator.class.getName()); |
| 48 | 43 | private static final StringProperty PROP_COORDINATES = new StringProperty("coordinates", null); |
| 49 | 44 | private static final CollectionProperty PROP_SUB_PROJECTION = new CollectionProperty("projection.sub", null); |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 64 | 59 | } |
| 65 | 60 | } |
| 66 | 61 | |
| 67 | | //TODO This is not nice place for a listener code but probably only Dataset will want to listen for projection changes so it's acceptable |
| 68 | | private static CopyOnWriteArrayList<ProjectionChangedListener> listeners = new CopyOnWriteArrayList<ProjectionChangedListener>(); |
| 69 | | |
| 70 | | public static void addProjectionChangedListener(ProjectionChangedListener listener) { |
| 71 | | listeners.addIfAbsent(listener); |
| 72 | | } |
| 73 | | |
| 74 | | public static void removeProjectionChangedListener(ProjectionChangedListener listener) { |
| 75 | | listeners.remove(listener); |
| 76 | | } |
| 77 | | |
| 78 | | private static void fireProjectionChanged() { |
| 79 | | for (ProjectionChangedListener listener: listeners) { |
| 80 | | listener.projectionChanged(); |
| 81 | | } |
| 82 | | } |
| 83 | | |
| 84 | | |
| 85 | 62 | /** |
| 86 | 63 | * Combobox with all projections available |
| 87 | 64 | */ |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 160 | 137 | JScrollPane scrollpane = new JScrollPane(projPanel); |
| 161 | 138 | gui.mapcontent.addTab(tr("Map Projection"), scrollpane); |
| 162 | 139 | |
| 163 | | updateMeta(Main.proj); |
| | 140 | updateMeta(Main.getProjection()); |
| 164 | 141 | } |
| 165 | 142 | |
| 166 | 143 | private void updateMeta(Projection proj) |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 200 | 177 | |
| 201 | 178 | static public void setProjection(String name, Collection<String> coll) |
| 202 | 179 | { |
| 203 | | Bounds b = (Main.map != null && Main.map.mapView != null) ? Main.map.mapView.getRealBounds() : null; |
| 204 | | Projection oldProj = Main.proj; |
| 205 | | |
| 206 | 180 | Projection p = null; |
| 207 | 181 | for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) { |
| 208 | 182 | try { |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 210 | 184 | } catch (final Exception e) { |
| 211 | 185 | } |
| 212 | 186 | if (p != null) { |
| 213 | | Main.proj = p; |
| 214 | 187 | break; |
| 215 | 188 | } |
| 216 | 189 | } |
| … |
… |
public class ProjectionPreference implements PreferenceSetting {
|
| 222 | 195 | JOptionPane.ERROR_MESSAGE |
| 223 | 196 | ); |
| 224 | 197 | coll = null; |
| 225 | | Main.proj = new Mercator(); |
| 226 | | name = Main.proj.getClass().getName(); |
| | 198 | p = new Mercator(); |
| | 199 | name = Main.getProjection().getClass().getName(); |
| 227 | 200 | } |
| 228 | 201 | PROP_SUB_PROJECTION.put(coll); |
| 229 | 202 | PROP_PROJECTION_SUBPROJECTION.put(coll, name); |
| 230 | | if(Main.proj instanceof ProjectionSubPrefs) { |
| 231 | | ((ProjectionSubPrefs) Main.proj).setPreferences(coll); |
| 232 | | } |
| 233 | | fireProjectionChanged(); // This should be probably called from the if bellow, but hashCode condition doesn't look sure enough |
| 234 | | if(b != null && (!Main.proj.getClass().getName().equals(oldProj.getClass().getName()) || Main.proj.hashCode() != oldProj.hashCode())) |
| 235 | | { |
| 236 | | Main.map.mapView.zoomTo(b); |
| 237 | | /* TODO - remove layers with fixed projection */ |
| | 203 | if(Main.getProjection() instanceof ProjectionSubPrefs) { |
| | 204 | ((ProjectionSubPrefs) Main.getProjection()).setPreferences(coll); |
| 238 | 205 | } |
| | 206 | Main.setProjection(p); |
| 239 | 207 | } |
| 240 | 208 | |
| 241 | 209 | private class SBPanel extends JPanel implements ActionListener |
-
diff --git a/src/org/openstreetmap/josm/io/imagery/Grabber.java b/src/org/openstreetmap/josm/io/imagery/Grabber.java
index 648cb8b..5a49fc3 100644
|
a
|
b
|
abstract public class Grabber implements Runnable {
|
| 40 | 40 | b.maxNorth + northCoef * northSize)); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | | this.proj = Main.proj; |
| | 43 | this.proj = Main.getProjection(); |
| 44 | 44 | this.pixelPerDegree = request.getPixelPerDegree(); |
| 45 | 45 | this.request = request; |
| 46 | 46 | } |
-
diff --git a/src/org/openstreetmap/josm/io/imagery/HTMLGrabber.java b/src/org/openstreetmap/josm/io/imagery/HTMLGrabber.java
index d12619d..40aac55 100644
|
a
|
b
|
public class HTMLGrabber extends WMSGrabber {
|
| 51 | 51 | ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
| 52 | 52 | BufferedImage img = layer.normalizeImage(ImageIO.read(bais)); |
| 53 | 53 | bais.reset(); |
| 54 | | layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.proj, pixelPerDegree, b.minEast, b.minNorth); |
| | 54 | layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth); |
| 55 | 55 | |
| 56 | 56 | return img; |
| 57 | 57 | } |
-
diff --git a/src/org/openstreetmap/josm/io/imagery/OsmosnimkiOffsetServer.java b/src/org/openstreetmap/josm/io/imagery/OsmosnimkiOffsetServer.java
index 02d9ee5..fc31932 100644
|
a
|
b
|
public class OsmosnimkiOffsetServer implements OffsetServer {
|
| 39 | 39 | |
| 40 | 40 | @Override |
| 41 | 41 | public EastNorth getOffset(ImageryInfo info, EastNorth en) { |
| 42 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| | 42 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| 43 | 43 | try { |
| 44 | 44 | URL url = new URL(this.url + "action=GetOffsetForPoint&lat=" + ll.lat() + "&lon=" + ll.lon() + "&id=" + URLEncoder.encode(info.getFullUrl(), "UTF-8")); |
| 45 | 45 | System.out.println(tr("Querying offset: {0}", url.toString())); |
| … |
… |
public class OsmosnimkiOffsetServer implements OffsetServer {
|
| 49 | 49 | if (i == -1) return null; |
| 50 | 50 | String sLon = s.substring(1,i); |
| 51 | 51 | String sLat = s.substring(i+1,s.length()-1); |
| 52 | | return Main.proj.latlon2eastNorth(new LatLon(Double.valueOf(sLat),Double.valueOf(sLon))).sub(en); |
| | 52 | return Main.getProjection().latlon2eastNorth(new LatLon(Double.valueOf(sLat),Double.valueOf(sLon))).sub(en); |
| 53 | 53 | } catch (Exception e) { |
| 54 | 54 | e.printStackTrace(); |
| 55 | 55 | return null; |
-
diff --git a/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java b/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java
index 048370e..d13bfa3 100644
|
a
|
b
|
public class WMSGrabber extends Grabber {
|
| 71 | 71 | |
| 72 | 72 | protected URL getURL(double w, double s,double e,double n, |
| 73 | 73 | int wi, int ht) throws MalformedURLException { |
| 74 | | String myProj = Main.proj.toCode(); |
| 75 | | if(Main.proj instanceof Mercator) // don't use mercator code directly |
| | 74 | String myProj = Main.getProjection().toCode(); |
| | 75 | if(Main.getProjection() instanceof Mercator) // don't use mercator code directly |
| 76 | 76 | { |
| 77 | | LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(w, s)); |
| 78 | | LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(e, n)); |
| | 77 | LatLon sw = Main.getProjection().eastNorth2latlon(new EastNorth(w, s)); |
| | 78 | LatLon ne = Main.getProjection().eastNorth2latlon(new EastNorth(e, n)); |
| 79 | 79 | myProj = "EPSG:4326"; |
| 80 | 80 | s = sw.lat(); |
| 81 | 81 | w = sw.lon(); |
| … |
… |
public class WMSGrabber extends Grabber {
|
| 113 | 113 | |
| 114 | 114 | static public String getProjection(String baseURL, Boolean warn) |
| 115 | 115 | { |
| 116 | | String projname = Main.proj.toCode(); |
| 117 | | if(Main.proj instanceof Mercator) { |
| | 116 | String projname = Main.getProjection().toCode(); |
| | 117 | if(Main.getProjection() instanceof Mercator) { |
| 118 | 118 | projname = "EPSG:4326"; |
| 119 | 119 | } |
| 120 | 120 | String res = ""; |
| … |
… |
public class WMSGrabber extends Grabber {
|
| 145 | 145 | |
| 146 | 146 | @Override |
| 147 | 147 | public boolean loadFromCache(WMSRequest request) { |
| 148 | | BufferedImage cached = layer.cache.getExactMatch(Main.proj, pixelPerDegree, b.minEast, b.minNorth); |
| | 148 | BufferedImage cached = layer.cache.getExactMatch(Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth); |
| 149 | 149 | |
| 150 | 150 | if (cached != null) { |
| 151 | 151 | request.finish(State.IMAGE, cached); |
| 152 | 152 | return true; |
| 153 | 153 | } else if (request.isAllowPartialCacheMatch()) { |
| 154 | | BufferedImage partialMatch = layer.cache.getPartialMatch(Main.proj, pixelPerDegree, b.minEast, b.minNorth); |
| | 154 | BufferedImage partialMatch = layer.cache.getPartialMatch(Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth); |
| 155 | 155 | if (partialMatch != null) { |
| 156 | 156 | request.finish(State.PARTLY_IN_CACHE, partialMatch); |
| 157 | 157 | return true; |
| … |
… |
public class WMSGrabber extends Grabber {
|
| 193 | 193 | ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
| 194 | 194 | BufferedImage img = layer.normalizeImage(ImageIO.read(bais)); |
| 195 | 195 | bais.reset(); |
| 196 | | layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.proj, pixelPerDegree, b.minEast, b.minNorth); |
| | 196 | layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth); |
| 197 | 197 | return img; |
| 198 | 198 | } |
| 199 | 199 | |
-
diff --git a/src/org/openstreetmap/josm/tools/Geometry.java b/src/org/openstreetmap/josm/tools/Geometry.java
index ade8359..210f6d4 100644
|
a
|
b
|
public class Geometry {
|
| 111 | 111 | return intersectionNodes; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | | Node newNode = new Node(Main.proj.eastNorth2latlon(intersection)); |
| | 114 | Node newNode = new Node(Main.getProjection().eastNorth2latlon(intersection)); |
| 115 | 115 | Node intNode = newNode; |
| 116 | 116 | boolean insertInSeg1 = false; |
| 117 | 117 | boolean insertInSeg2 = false; |
| … |
… |
public class Geometry {
|
| 457 | 457 | |
| 458 | 458 | return inside; |
| 459 | 459 | } |
| 460 | | |
| | 460 | |
| 461 | 461 | /** |
| 462 | 462 | * returns area of a closed way in square meters |
| 463 | 463 | * (approximate(?), but should be OK for small areas) |
| … |
… |
public class Geometry {
|
| 477 | 477 | } |
| 478 | 478 | return Math.abs(area/2); |
| 479 | 479 | } |
| 480 | | |
| | 480 | |
| 481 | 481 | protected static double calcX(Node p1){ |
| 482 | 482 | double lat1, lon1, lat2, lon2; |
| 483 | 483 | double dlon, dlat; |
| … |
… |
public class Geometry {
|
| 494 | 494 | double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); |
| 495 | 495 | return 6367000 * c; |
| 496 | 496 | } |
| 497 | | |
| | 497 | |
| 498 | 498 | protected static double calcY(Node p1){ |
| 499 | 499 | double lat1, lon1, lat2, lon2; |
| 500 | 500 | double dlon, dlat; |
-
diff --git a/test/functional/org/openstreetmap/josm/fixtures/JOSMFixture.java b/test/functional/org/openstreetmap/josm/fixtures/JOSMFixture.java
index e976723..adadcbd 100644
|
a
|
b
|
public class JOSMFixture {
|
| 67 | 67 | Main.pref.init(false); |
| 68 | 68 | |
| 69 | 69 | // init projection |
| 70 | | Main.proj = new Mercator(); |
| | 70 | Main.setProjection(new Mercator()); |
| 71 | 71 | |
| 72 | 72 | // make sure we don't upload to or test against production |
| 73 | 73 | // |
-
diff --git a/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java b/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java
index f7ac131..09146d4 100644
|
a
|
b
|
public class PropertiesMergerTest extends JFrame{
|
| 17 | 17 | private PropertiesMerger merger; |
| 18 | 18 | |
| 19 | 19 | protected void build() { |
| 20 | | Main.proj = new Epsg4326(); |
| | 20 | Main.setProjection(new Epsg4326()); |
| 21 | 21 | |
| 22 | 22 | setLayout(new BorderLayout()); |
| 23 | 23 | add(merger = new PropertiesMerger(), BorderLayout.CENTER); |
-
diff --git a/test/functional/org/openstreetmap/josm/gui/history/HistoryBrowserTest.java b/test/functional/org/openstreetmap/josm/gui/history/HistoryBrowserTest.java
index e343a20..020b8c1 100644
|
a
|
b
|
public class HistoryBrowserTest extends JFrame {
|
| 57 | 57 | Main.pref.init(false); |
| 58 | 58 | |
| 59 | 59 | // init projection |
| 60 | | Main.proj = new Mercator(); |
| | 60 | Main.setProjection(new Mercator()); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | private HistoryBrowser browser; |
-
diff --git a/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java b/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
index cba8559..9a71296 100644
|
a
|
b
|
public class MultiFetchServerObjectReaderTest {
|
| 175 | 175 | // don't use atomic upload, the test API server can't cope with large diff uploads |
| 176 | 176 | // |
| 177 | 177 | Main.pref.put("osm-server.atomic-upload", false); |
| 178 | | Main.proj = new Mercator(); |
| | 178 | Main.setProjection(new Mercator()); |
| 179 | 179 | |
| 180 | 180 | File dataSetCacheOutputFile = new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset"); |
| 181 | 181 | |
-
diff --git a/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java b/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
index 354af96..92d206c 100644
|
a
|
b
|
public class OsmServerBackreferenceReaderTest {
|
| 182 | 182 | // don't use atomic upload, the test API server can't cope with large diff uploads |
| 183 | 183 | // |
| 184 | 184 | Main.pref.put("osm-server.atomic-upload", false); |
| 185 | | Main.proj = new Mercator(); |
| | 185 | Main.setProjection(new Mercator()); |
| 186 | 186 | |
| 187 | 187 | File dataSetCacheOutputFile = new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset"); |
| 188 | 188 | |
-
diff --git a/test/performance/org/openstreetmap/josm/data/osm/MapPaintVisitorPerformanceTest.java b/test/performance/org/openstreetmap/josm/data/osm/MapPaintVisitorPerformanceTest.java
index bb702e2..d74cce7 100644
|
a
|
b
|
public class MapPaintVisitorPerformanceTest {
|
| 31 | 31 | |
| 32 | 32 | @BeforeClass |
| 33 | 33 | public static void load() throws Exception { |
| 34 | | Main.proj = new Mercator(); |
| | 34 | Main.setProjection(new Mercator()); |
| 35 | 35 | img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_3BYTE_BGR); |
| 36 | 36 | g = (Graphics2D)img.getGraphics(); |
| 37 | 37 | nc = new NavigatableComponent(); |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java b/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
index e40437e..58a1a7b 100644
|
a
|
b
|
public class DataSetMergerTest {
|
| 75 | 75 | my.setVersion("0.6"); |
| 76 | 76 | their = new DataSet(); |
| 77 | 77 | their.setVersion("0.6"); |
| 78 | | Main.proj = new Mercator(); |
| | 78 | Main.setProjection(new Mercator()); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | private void runConsistencyTests(DataSet ds) throws Exception { |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java b/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
index 596ccb5..9317599 100644
|
a
|
b
|
public class FilterTest {
|
| 28 | 28 | |
| 29 | 29 | @BeforeClass |
| 30 | 30 | public static void setUp() { |
| 31 | | Main.proj = new Mercator(); |
| | 31 | Main.setProjection(new Mercator()); |
| 32 | 32 | Main.pref = new Preferences(); |
| 33 | 33 | } |
| 34 | 34 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/NodeProjectionTest.java b/test/unit/org/openstreetmap/josm/data/osm/NodeProjectionTest.java
new file mode 100644
index 0000000..a1e4186
|
-
|
+
|
|
| | 1 | // License: GPL. For details, see LICENSE file. |
| | 2 | package org.openstreetmap.josm.data.osm; |
| | 3 | |
| | 4 | import static org.junit.Assert.assertEquals; |
| | 5 | |
| | 6 | import org.junit.Before; |
| | 7 | import org.junit.Test; |
| | 8 | import org.openstreetmap.josm.Main; |
| | 9 | import org.openstreetmap.josm.data.Preferences; |
| | 10 | import org.openstreetmap.josm.data.coor.EastNorth; |
| | 11 | import org.openstreetmap.josm.data.coor.LatLon; |
| | 12 | import org.openstreetmap.josm.data.projection.Epsg4326; |
| | 13 | import org.openstreetmap.josm.data.projection.Mercator; |
| | 14 | public class NodeProjectionTest { |
| | 15 | |
| | 16 | |
| | 17 | @Before |
| | 18 | public void setUp(){ |
| | 19 | Main.pref = new Preferences(); |
| | 20 | Main.setProjection(new Mercator()); |
| | 21 | } |
| | 22 | |
| | 23 | /** |
| | 24 | * If a node is isolated (i.e. if it isn't part of a data set), {@link Node#getEastNorth()} should always |
| | 25 | * reply projected east/north coordinates compliant with the global projection given |
| | 26 | * by {@link Main#getProjection()}. |
| | 27 | */ |
| | 28 | @Test |
| | 29 | public void projectIsolatedNode() { |
| | 30 | Node n = new Node(1,1); |
| | 31 | n.setCoor(new LatLon(0,0)); |
| | 32 | EastNorth en = Main.getProjection().latlon2eastNorth(new LatLon(0,0)); |
| | 33 | assertEquals(en, n.getEastNorth()); |
| | 34 | |
| | 35 | /* change the projection ... */ |
| | 36 | Main.setProjection(new Epsg4326()); |
| | 37 | en = Main.getProjection().latlon2eastNorth(new LatLon(0,0)); |
| | 38 | |
| | 39 | /* n should now reply east/north coordinates for this projection |
| | 40 | * although it is isolated (neither added to a dataset, nor to - indirectly - |
| | 41 | * a layer). |
| | 42 | */ |
| | 43 | assertEquals(en, n.getEastNorth()); |
| | 44 | } |
| | 45 | |
| | 46 | /** |
| | 47 | * If a node isn't isolated (i.e. if it *is* part of a data set), {@link Node#getEastNorth()} should always |
| | 48 | * reply projected east/north coordinates compliant with the global projection given |
| | 49 | * by {@link Main#getProjection()}, *although* it internally caches the projected |
| | 50 | * coordinates. In other words: it should refresh the internal cache if the projection |
| | 51 | * changes. |
| | 52 | */ |
| | 53 | |
| | 54 | @Test |
| | 55 | public void projectNodeBelongingToAnIsolatedDataSet() { |
| | 56 | DataSet ds = new DataSet(); |
| | 57 | Node n = new Node(1,1); |
| | 58 | ds.addPrimitive(n); |
| | 59 | n.setCoor(new LatLon(0,0)); |
| | 60 | EastNorth en = Main.getProjection().latlon2eastNorth(new LatLon(0,0)); |
| | 61 | assertEquals(en, n.getEastNorth()); |
| | 62 | |
| | 63 | /* change the projection ... */ |
| | 64 | Main.setProjection(new Epsg4326()); |
| | 65 | en = Main.getProjection().latlon2eastNorth(new LatLon(0,0)); |
| | 66 | |
| | 67 | /* n should now reply east/north coordinates for this projection |
| | 68 | * although it is part of a dataset which isn't connected to a layer |
| | 69 | */ |
| | 70 | assertEquals(en, n.getEastNorth()); |
| | 71 | } |
| | 72 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java b/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
index 9a2bc7b..5172817 100644
|
a
|
b
|
public class OsmPrimitiveTest {
|
| 28 | 28 | |
| 29 | 29 | @BeforeClass |
| 30 | 30 | public static void setUp() { |
| 31 | | Main.proj = new Mercator(); |
| | 31 | Main.setProjection(new Mercator()); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Test |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java b/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
index c0d9597..9f1fc44 100644
|
a
|
b
|
public class QuadBucketsTest {
|
| 65 | 65 | |
| 66 | 66 | @Test |
| 67 | 67 | public void testRemove() throws Exception { |
| 68 | | Main.proj = new Mercator(); |
| | 68 | Main.setProjection(new Mercator()); |
| 69 | 69 | DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE); |
| 70 | 70 | removeAllTest(ds); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | @Test |
| 74 | 74 | public void testMove() throws Exception { |
| 75 | | Main.proj = new Mercator(); |
| | 75 | Main.setProjection(new Mercator()); |
| 76 | 76 | DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE); |
| 77 | 77 | |
| 78 | 78 | for (Node n: ds.getNodes()) { |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java b/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
index 2687fd8..1bf7122 100644
|
a
|
b
|
public class RelationTest {
|
| 15 | 15 | |
| 16 | 16 | @BeforeClass |
| 17 | 17 | public static void setUp() { |
| 18 | | Main.proj = new Mercator(); |
| | 18 | Main.setProjection(new Mercator()); |
| 19 | 19 | Main.pref = new Preferences(); |
| 20 | 20 | } |
| 21 | 21 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java b/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
index 7b9aee8..fef5177 100644
|
a
|
b
|
public class MergeSourceBuildingVisitorTest {
|
| 36 | 36 | |
| 37 | 37 | @BeforeClass |
| 38 | 38 | public static void setUp() { |
| 39 | | Main.proj = new Mercator(); |
| | 39 | Main.setProjection(new Mercator()); |
| 40 | 40 | Main.pref = new Preferences(); |
| 41 | 41 | } |
| 42 | 42 | |
-
diff --git a/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java b/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
index 4b44434..e369652 100644
|
a
|
b
|
public class SwissGridTest {
|
| 14 | 14 | |
| 15 | 15 | @BeforeClass |
| 16 | 16 | public static void setUp() { |
| 17 | | Main.proj = new SwissGrid(); |
| | 17 | Main.setProjection(new SwissGrid()); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| … |
… |
public class SwissGridTest {
|
| 61 | 61 | public void a_latlon2eastNorth_test() { |
| 62 | 62 | { |
| 63 | 63 | LatLon ll = new LatLon(46.518, 6.567); |
| 64 | | EastNorth en = Main.proj.latlon2eastNorth(ll); |
| 65 | | if (debug) System.out.println(en); |
| | 64 | EastNorth en = Main.getProjection().latlon2eastNorth(ll); |
| | 65 | if (debug) { |
| | 66 | System.out.println(en); |
| | 67 | } |
| 66 | 68 | assertTrue("Lausanne", Math.abs(en.east() - 533111.69) < 0.1); |
| 67 | 69 | assertTrue("Lausanne", Math.abs(en.north() - 152227.85) < 0.1); |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | { |
| 71 | 73 | LatLon ll = new LatLon(47.78, 8.58); |
| 72 | | EastNorth en = Main.proj.latlon2eastNorth(ll); |
| 73 | | if (debug) System.out.println(en); |
| | 74 | EastNorth en = Main.getProjection().latlon2eastNorth(ll); |
| | 75 | if (debug) { |
| | 76 | System.out.println(en); |
| | 77 | } |
| 74 | 78 | assertTrue("Schafouse", Math.abs(en.east() - 685544.16) < 0.1); |
| 75 | 79 | assertTrue("Schafouse", Math.abs(en.north() - 292782.91) < 0.1); |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | { |
| 79 | 83 | LatLon ll = new LatLon(46.58, 10.48); |
| 80 | | EastNorth en = Main.proj.latlon2eastNorth(ll); |
| 81 | | if (debug) System.out.println(en); |
| | 84 | EastNorth en = Main.getProjection().latlon2eastNorth(ll); |
| | 85 | if (debug) { |
| | 86 | System.out.println(en); |
| | 87 | } |
| 82 | 88 | assertTrue("Grinson", Math.abs(en.east() - 833068.04) < 0.1); |
| 83 | 89 | assertTrue("Grinson", Math.abs(en.north() - 163265.39) < 0.1); |
| 84 | 90 | } |
| 85 | 91 | |
| 86 | 92 | { |
| 87 | 93 | LatLon ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600); |
| 88 | | EastNorth en = Main.proj.latlon2eastNorth(ll); |
| 89 | | if (debug) System.out.println(en); |
| | 94 | EastNorth en = Main.getProjection().latlon2eastNorth(ll); |
| | 95 | if (debug) { |
| | 96 | System.out.println(en); |
| | 97 | } |
| 90 | 98 | assertTrue("Berne", Math.abs(en.east() - 600000.0) < 0.1); |
| 91 | 99 | assertTrue("Berne", Math.abs(en.north() - 200000.0) < 0.1); |
| 92 | 100 | } |
| 93 | 101 | { |
| 94 | 102 | LatLon ll = new LatLon(46.0 + 2.0 / 60 + 38.87 / 3600, 8.0 + 43.0 / 60 + 49.79 / 3600); |
| 95 | | EastNorth en = Main.proj.latlon2eastNorth(ll); |
| 96 | | if (debug) System.out.println(en); |
| | 103 | EastNorth en = Main.getProjection().latlon2eastNorth(ll); |
| | 104 | if (debug) { |
| | 105 | System.out.println(en); |
| | 106 | } |
| 97 | 107 | assertTrue("Ref", Math.abs(en.east() - 700000.0) < 0.1); |
| 98 | 108 | assertTrue("Ref", Math.abs(en.north() - 100000.0) < 0.1); |
| 99 | 109 | } |
| … |
… |
public class SwissGridTest {
|
| 104 | 114 | public void b_eastNorth2latlon_test() { |
| 105 | 115 | { |
| 106 | 116 | EastNorth en = new EastNorth(533111.69, 152227.85); |
| 107 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 108 | | if (debug) System.out.println(ll); |
| | 117 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 118 | if (debug) { |
| | 119 | System.out.println(ll); |
| | 120 | } |
| 109 | 121 | assertTrue("Lausanne", Math.abs(ll.lat() - 46.518) < 0.00001); |
| 110 | 122 | assertTrue("Lausanne", Math.abs(ll.lon() - 6.567) < 0.00001); |
| 111 | 123 | } |
| 112 | 124 | |
| 113 | 125 | { |
| 114 | 126 | EastNorth en = new EastNorth(685544.16, 292782.91); |
| 115 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 116 | | if (debug) System.out.println(ll); |
| | 127 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 128 | if (debug) { |
| | 129 | System.out.println(ll); |
| | 130 | } |
| 117 | 131 | assertTrue("Schafouse", Math.abs(ll.lat() - 47.78) < 0.00001); |
| 118 | 132 | assertTrue("Schafouse", Math.abs(ll.lon() - 8.58) < 0.00001); |
| 119 | 133 | } |
| 120 | 134 | |
| 121 | 135 | { |
| 122 | 136 | EastNorth en = new EastNorth(833068.04, 163265.39); |
| 123 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 124 | | if (debug) System.out.println(ll); |
| | 137 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 138 | if (debug) { |
| | 139 | System.out.println(ll); |
| | 140 | } |
| 125 | 141 | assertTrue("Grinson", Math.abs(ll.lat() - 46.58) < 0.00001); |
| 126 | 142 | assertTrue("Grinson", Math.abs(ll.lon() - 10.48) < 0.00001); |
| 127 | 143 | } |
| 128 | 144 | |
| 129 | 145 | { |
| 130 | 146 | EastNorth en = new EastNorth(600000.0, 200000.0); |
| 131 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 132 | | if (debug) System.out.println(ll); |
| | 147 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 148 | if (debug) { |
| | 149 | System.out.println(ll); |
| | 150 | } |
| 133 | 151 | assertTrue("Berne", Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001); |
| 134 | 152 | assertTrue("Berne", Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001); |
| 135 | 153 | } |
| 136 | 154 | |
| 137 | 155 | { |
| 138 | 156 | EastNorth en = new EastNorth(700000.0, 100000.0); |
| 139 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 140 | | if (debug) System.out.println(ll); |
| | 157 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 158 | if (debug) { |
| | 159 | System.out.println(ll); |
| | 160 | } |
| 141 | 161 | assertTrue("Ref", Math.abs(ll.lat() - (46.0 + 2.0 / 60 + 38.87 / 3600)) < 0.00001); |
| 142 | 162 | assertTrue("Ref", Math.abs(ll.lon() - (8.0 + 43.0 / 60 + 49.79 / 3600)) < 0.00001); |
| 143 | 163 | } |
| … |
… |
public class SwissGridTest {
|
| 151 | 171 | public void c_sendandreturn_test() { |
| 152 | 172 | { |
| 153 | 173 | EastNorth en = new EastNorth(533111.69, 152227.85); |
| 154 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 155 | | EastNorth en2 = Main.proj.latlon2eastNorth(ll); |
| 156 | | if (debug) System.out.println(en.east() - en2.east()); |
| 157 | | if (debug) System.out.println(en.north() - en2.north()); |
| | 174 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 175 | EastNorth en2 = Main.getProjection().latlon2eastNorth(ll); |
| | 176 | if (debug) { |
| | 177 | System.out.println(en.east() - en2.east()); |
| | 178 | } |
| | 179 | if (debug) { |
| | 180 | System.out.println(en.north() - en2.north()); |
| | 181 | } |
| 158 | 182 | assertTrue("Lausanne", Math.abs(en.east() - en2.east()) < 0.002); |
| 159 | 183 | assertTrue("Lausanne", Math.abs(en.north() - en2.north()) < 0.002); |
| 160 | 184 | } |
| 161 | 185 | |
| 162 | 186 | { |
| 163 | 187 | EastNorth en = new EastNorth(685544.16, 292782.91); |
| 164 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 165 | | EastNorth en2 = Main.proj.latlon2eastNorth(ll); |
| 166 | | if (debug) System.out.println(en.east() - en2.east()); |
| 167 | | if (debug) System.out.println(en.north() - en2.north()); |
| | 188 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 189 | EastNorth en2 = Main.getProjection().latlon2eastNorth(ll); |
| | 190 | if (debug) { |
| | 191 | System.out.println(en.east() - en2.east()); |
| | 192 | } |
| | 193 | if (debug) { |
| | 194 | System.out.println(en.north() - en2.north()); |
| | 195 | } |
| 168 | 196 | assertTrue("Schafouse", Math.abs(en.east() - en2.east()) < 0.002); |
| 169 | 197 | assertTrue("Schafouse", Math.abs(en.north() - en2.north()) < 0.002); |
| 170 | 198 | } |
| 171 | 199 | |
| 172 | 200 | { |
| 173 | 201 | EastNorth en = new EastNorth(833068.04, 163265.39); |
| 174 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 175 | | EastNorth en2 = Main.proj.latlon2eastNorth(ll); |
| 176 | | if (debug) System.out.println(en.east() - en2.east()); |
| 177 | | if (debug) System.out.println(en.north() - en2.north()); |
| | 202 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 203 | EastNorth en2 = Main.getProjection().latlon2eastNorth(ll); |
| | 204 | if (debug) { |
| | 205 | System.out.println(en.east() - en2.east()); |
| | 206 | } |
| | 207 | if (debug) { |
| | 208 | System.out.println(en.north() - en2.north()); |
| | 209 | } |
| 178 | 210 | assertTrue("Grinson", Math.abs(en.east() - en2.east()) < 0.002); |
| 179 | 211 | assertTrue("Grinson", Math.abs(en.north() - en2.north()) < 0.002); |
| 180 | 212 | } |
| 181 | 213 | |
| 182 | 214 | { |
| 183 | 215 | EastNorth en = new EastNorth(600000.0, 200000.0); |
| 184 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 185 | | EastNorth en2 = Main.proj.latlon2eastNorth(ll); |
| 186 | | if (debug) System.out.println(en.east() - en2.east()); |
| 187 | | if (debug) System.out.println(en.north() - en2.north()); |
| | 216 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 217 | EastNorth en2 = Main.getProjection().latlon2eastNorth(ll); |
| | 218 | if (debug) { |
| | 219 | System.out.println(en.east() - en2.east()); |
| | 220 | } |
| | 221 | if (debug) { |
| | 222 | System.out.println(en.north() - en2.north()); |
| | 223 | } |
| 188 | 224 | assertTrue("Berne", Math.abs(en.east() - en2.east()) < 0.002); |
| 189 | 225 | assertTrue("Berne", Math.abs(en.north() - en2.north()) < 0.002); |
| 190 | 226 | } |
| 191 | 227 | |
| 192 | 228 | { |
| 193 | 229 | EastNorth en = new EastNorth(700000.0, 100000.0); |
| 194 | | LatLon ll = Main.proj.eastNorth2latlon(en); |
| 195 | | EastNorth en2 = Main.proj.latlon2eastNorth(ll); |
| 196 | | if (debug) System.out.println(en.east() - en2.east()); |
| 197 | | if (debug) System.out.println(en.north() - en2.north()); |
| | 230 | LatLon ll = Main.getProjection().eastNorth2latlon(en); |
| | 231 | EastNorth en2 = Main.getProjection().latlon2eastNorth(ll); |
| | 232 | if (debug) { |
| | 233 | System.out.println(en.east() - en2.east()); |
| | 234 | } |
| | 235 | if (debug) { |
| | 236 | System.out.println(en.north() - en2.north()); |
| | 237 | } |
| 198 | 238 | assertTrue("Ref", Math.abs(en.east() - en2.east()) < 0.002); |
| 199 | 239 | assertTrue("Ref", Math.abs(en.north() - en2.north()) < 0.002); |
| 200 | 240 | } |
-
diff --git a/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java b/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
index 7e9ad9b..7f9ffae 100644
|
a
|
b
|
public class PropertiesMergeModelTest {
|
| 46 | 46 | |
| 47 | 47 | @BeforeClass |
| 48 | 48 | public static void init() { |
| 49 | | Main.proj = new Epsg4326(); |
| | 49 | Main.setProjection(new Epsg4326()); |
| 50 | 50 | Main.pref = new Preferences(); |
| 51 | 51 | } |
| 52 | 52 | |