Changeset 9559 in josm
- Timestamp:
- 2016-01-21T17:20:12+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/projection
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r9532 r9559 5 5 6 6 import java.util.ArrayList; 7 import java.util.EnumMap; 7 8 import java.util.HashMap; 8 9 import java.util.List; … … 11 12 import java.util.regex.Matcher; 12 13 import java.util.regex.Pattern; 13 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.data.Bounds; … … 26 26 import org.openstreetmap.josm.data.projection.datum.WGS84Datum; 27 27 import org.openstreetmap.josm.data.projection.proj.ICentralMeridianProvider; 28 import org.openstreetmap.josm.data.projection.proj.IPolar;29 28 import org.openstreetmap.josm.data.projection.proj.Mercator; 30 29 import org.openstreetmap.josm.data.projection.proj.Proj; … … 156 155 } 157 156 157 private enum Polarity { NORTH, SOUTH } 158 159 private EnumMap<Polarity, EastNorth> polesEN; 160 private EnumMap<Polarity, LatLon> polesLL; 161 { 162 polesLL = new EnumMap<>(Polarity.class); 163 polesLL.put(Polarity.NORTH, LatLon.NORTH_POLE); 164 polesLL.put(Polarity.SOUTH, LatLon.SOUTH_POLE); 165 } 166 158 167 /** 159 168 * Constructs a new empty {@code CustomProjection}. … … 761 770 } 762 771 772 private EastNorth getPole(Polarity whichPole) { 773 if (polesEN == null) { 774 polesEN = new EnumMap<>(Polarity.class); 775 for (Polarity p : Polarity.values()) { 776 polesEN.put(p, null); 777 LatLon ll = polesLL.get(p); 778 try { 779 EastNorth enPole = latlon2eastNorth(ll); 780 if (enPole.isValid()) { 781 // project back and check if the result is somewhat reasonable 782 LatLon llBack = eastNorth2latlon(enPole); 783 if (llBack.isValid() && ll.greatCircleDistance(llBack) < 1000) { 784 polesEN.put(p, enPole); 785 } 786 } 787 } catch (Exception e) {} 788 } 789 } 790 return polesEN.get(whichPole); 791 } 792 763 793 @Override 764 794 public Bounds getLatLonBoundsBox(ProjectionBounds r) { … … 788 818 // if the box contains one of the poles, the above method did not get 789 819 // correct min/max latitude value 790 if (proj instanceof IPolar) { 791 IPolar polarProj = (IPolar) proj; 792 if (polarProj.hasPole(false)) { 793 EastNorth enNorthPole = latlon2eastNorth(LatLon.NORTH_POLE); 794 if (r.contains(enNorthPole)) { 795 result.extend(LatLon.NORTH_POLE); 796 } 797 } 798 if (polarProj.hasPole(true)) { 799 EastNorth enSouthPole = latlon2eastNorth(LatLon.SOUTH_POLE); 800 if (r.contains(enSouthPole)) { 801 result.extend(LatLon.SOUTH_POLE); 802 } 820 for (Polarity p : Polarity.values()) { 821 EastNorth pole = getPole(p); 822 if (pole != null && r.contains(pole)) { 823 result.extend(polesLL.get(p)); 803 824 } 804 825 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/PolarStereographic.java
r9428 r9559 57 57 * @since 9419 58 58 */ 59 public class PolarStereographic extends AbstractProj implements IPolar{59 public class PolarStereographic extends AbstractProj { 60 60 /** 61 61 * Maximum number of iterations for iterative computations. … … 181 181 } 182 182 } 183 184 @Override185 public boolean hasPole(boolean south) {186 return south == southPole;187 }188 183 }
Note:
See TracChangeset
for help on using the changeset viewer.