Changeset 9419 in josm
- Timestamp:
- 2016-01-12T17:39:45+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java
r9243 r9419 123 123 124 124 /** 125 * Check, if a point is within the bounds. 126 * @param en the point 127 * @return true, if <code>en</code> is within the bounds 128 */ 129 public boolean contains(EastNorth en) { 130 return minEast <= en.east() && en.east() <= maxEast && 131 minNorth <= en.north() && en.north() <= maxNorth; 132 } 133 134 /** 125 135 * Returns the min east/north. 126 136 * @return the min east/north -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r9384 r9419 56 56 public static final LatLon ZERO = new LatLon(0, 0); 57 57 58 /** 59 * North and south pole. 60 */ 61 public static final LatLon NORTH_POLE = new LatLon(90, 0); 62 public static final LatLon SOUTH_POLE = new LatLon(-90, 0); 63 58 64 private static DecimalFormat cDmsMinuteFormatter = new DecimalFormat("00"); 59 65 private static DecimalFormat cDmsSecondFormatter = new DecimalFormat("00.0"); -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r9135 r9419 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.data.Bounds; 16 import org.openstreetmap.josm.data.ProjectionBounds; 17 import org.openstreetmap.josm.data.coor.EastNorth; 16 18 import org.openstreetmap.josm.data.coor.LatLon; 17 19 import org.openstreetmap.josm.data.projection.datum.CentricDatum; … … 23 25 import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum; 24 26 import org.openstreetmap.josm.data.projection.datum.WGS84Datum; 27 import org.openstreetmap.josm.data.projection.proj.IPolar; 25 28 import org.openstreetmap.josm.data.projection.proj.Mercator; 26 29 import org.openstreetmap.josm.data.projection.proj.Proj; … … 95 98 /** Latitude of second standard parallel */ 96 99 lat_2("lat_2", true), 100 /** Latitude of true scale */ 101 lat_ts("lat_ts", true), 97 102 /** the exact proj.4 string will be preserved in the WKT representation */ 98 103 wktext("wktext", false), // ignored … … 493 498 projParams.lat2 = parseAngle(s, Param.lat_2.key); 494 499 } 500 s = parameters.get(Param.lat_ts.key); 501 if (s != null) { 502 projParams.lat_ts = parseAngle(s, Param.lat_ts.key); 503 } 495 504 proj.initialize(projParams); 496 505 return proj; … … 690 699 return ret; 691 700 } 701 702 @Override 703 public Bounds getLatLonBoundsBox(ProjectionBounds r) { 704 Bounds result = new Bounds(eastNorth2latlon(r.getMin())); 705 result.extend(eastNorth2latlon(r.getMax())); 706 final int N = 40; 707 double dEast = (r.maxEast - r.minEast) / N; 708 double dNorth = (r.maxNorth - r.minNorth) / N; 709 for (int i = 0; i <= N; i++) { 710 result.extend(eastNorth2latlon(new EastNorth(r.minEast + i * dEast, r.minNorth))); 711 result.extend(eastNorth2latlon(new EastNorth(r.minEast + i * dEast, r.maxNorth))); 712 result.extend(eastNorth2latlon(new EastNorth(r.minEast, r.minNorth + i * dNorth))); 713 result.extend(eastNorth2latlon(new EastNorth(r.maxEast, r.minNorth + i * dNorth))); 714 } 715 // if the box contains one of the poles, the above method did not get 716 // correct min/max latitude value 717 if (proj instanceof IPolar) {; 718 IPolar polarProj = (IPolar) proj; 719 if (polarProj.hasPole(false)) { 720 EastNorth enNorthPole = latlon2eastNorth(LatLon.NORTH_POLE); 721 if (r.contains(enNorthPole)) { 722 result.extend(LatLon.NORTH_POLE); 723 } 724 } 725 if (polarProj.hasPole(true)) { 726 EastNorth enSouthPole = latlon2eastNorth(LatLon.SOUTH_POLE); 727 if (r.contains(enSouthPole)) { 728 result.extend(LatLon.SOUTH_POLE); 729 } 730 } 731 } 732 return result; 733 } 692 734 } -
trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java
r9243 r9419 114 114 115 115 /** 116 * first eccentricity 116 * first eccentricity: 117 * sqrt(a*a - b*b) / a 117 118 */ 118 119 public final double e; 119 120 120 121 /** 121 * first eccentricity squared 122 * first eccentricity squared: 123 * (a*a - b*b) / (a*a) 122 124 */ 123 125 public final double e2; 124 126 125 127 /** 126 * square of the second eccentricity 128 * square of the second eccentricity: 129 * (a*a - b*b) / (b*b) 127 130 */ 128 131 public final double eb2; … … 331 334 return new LatLon(Math.toDegrees(lt), Math.toDegrees(lg)); 332 335 } 333 336 334 337 /** 335 338 * convert ellipsoidal coordinates to cartesian coordinates -
trunk/src/org/openstreetmap/josm/data/projection/Projection.java
r9118 r9419 83 83 84 84 /** 85 * Find lat/lon-box containing all the area of a given rectangle in 86 * east/north space. 87 * 88 * This is an approximate method. Points outside of the world should be ignored. 89 * 90 * @param pb the rectangle in projected space 91 * @return minimum lat/lon box, that when projected, covers <code>pb</code> 92 */ 93 Bounds getLatLonBoundsBox(ProjectionBounds pb); 94 95 /** 85 96 * Get the number of meters per unit of this projection. This more 86 97 * defines the scale of the map, than real conversion of unit to meters -
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r9370 r9419 29 29 import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum; 30 30 import org.openstreetmap.josm.data.projection.datum.WGS84Datum; 31 import org.openstreetmap.josm.data.projection.proj.AlbersEqualArea; 31 32 import org.openstreetmap.josm.data.projection.proj.ClassProjFactory; 32 33 import org.openstreetmap.josm.data.projection.proj.DoubleStereographic; … … 34 35 import org.openstreetmap.josm.data.projection.proj.LonLat; 35 36 import org.openstreetmap.josm.data.projection.proj.Mercator; 37 import org.openstreetmap.josm.data.projection.proj.PolarStereographic; 36 38 import org.openstreetmap.josm.data.projection.proj.Proj; 37 39 import org.openstreetmap.josm.data.projection.proj.ProjFactory; … … 82 84 83 85 static { 84 registerBaseProjection(" lonlat", LonLat.class, "core");86 registerBaseProjection("aea", AlbersEqualArea.class, "core"); 85 87 registerBaseProjection("josm:smerc", Mercator.class, "core"); 86 88 registerBaseProjection("lcc", LambertConformalConic.class, "core"); 89 registerBaseProjection("lonlat", LonLat.class, "core"); 87 90 registerBaseProjection("somerc", SwissObliqueMercator.class, "core"); 91 registerBaseProjection("stere", PolarStereographic.class, "core"); 92 registerBaseProjection("sterea", DoubleStereographic.class, "core"); 88 93 registerBaseProjection("tmerc", TransverseMercator.class, "core"); 89 registerBaseProjection("sterea", DoubleStereographic.class, "core");90 94 91 95 ellipsoids.put("airy", Ellipsoid.Airy); -
trunk/src/org/openstreetmap/josm/data/projection/proj/AbstractProj.java
r9132 r9419 53 53 54 54 /** 55 * Ellipsoid excentricity, equals to <code>sqrt({@link #excentricitySquared})</code>. 56 * Value 0 means that the ellipsoid is spherical. 57 * 58 * @see #excentricitySquared 59 */ 60 protected double e; 61 62 /** 55 63 * The square of excentricity: e² = (a²-b²)/a² where 56 64 * <var>e</var> is the excentricity, … … 63 71 public void initialize(ProjParameters params) throws ProjectionConfigurationException { 64 72 e2 = params.ellps.e2; 73 e = params.ellps.e; 65 74 // Compute constants for the mlfn 66 75 double t; … … 134 143 } 135 144 } 145 146 /** 147 * Computes function <code>f(s,c,e²) = c/sqrt(1 - s²×e²)</code> needed for the true scale 148 * latitude (Snyder 14-15), where <var>s</var> and <var>c</var> are the sine and cosine of 149 * the true scale latitude, and <var>e²</var> is the {@linkplain #excentricitySquared 150 * eccentricity squared}. 151 */ 152 final double msfn(final double s, final double c) { 153 return c / Math.sqrt(1.0 - (s*s) * e2); 154 } 155 156 /** 157 * Computes function (15-9) and (9-13) from Snyder. 158 * Equivalent to negative of function (7-7). 159 */ 160 final double tsfn(final double lat, double sinlat) { 161 sinlat *= e; 162 /* 163 * NOTE: change sign to get the equivalent of Snyder (7-7). 164 */ 165 return Math.tan(0.5 * (Math.PI/2 - lat)) / Math.pow((1 - sinlat) / (1 + sinlat), 0.5*e); 166 } 136 167 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/ProjParameters.java
r8346 r9419 14 14 public Double lat1; 15 15 public Double lat2; 16 public Double lat_ts; 16 17 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r9408 r9419 311 311 } 312 312 313 public ProjectionBounds getProjectionBounds(Rectangle r) { 314 EastNorth p1 = getEastNorth(r.x, r.y); 315 EastNorth p2 = getEastNorth(r.x + r.width, r.y + r.height); 316 ProjectionBounds pb = new ProjectionBounds(p1); 317 pb.extend(p2); 318 return pb; 319 } 320 313 321 /** 314 322 * @param r rectangle … … 316 324 */ 317 325 public Bounds getLatLonBounds(Rectangle r) { 318 // TODO Maybe this should be (optional) method of Projection implementation 319 EastNorth p1 = getEastNorth(r.x, r.y); 320 EastNorth p2 = getEastNorth(r.x + r.width, r.y + r.height); 321 322 Bounds result = new Bounds(Main.getProjection().eastNorth2latlon(p1)); 323 324 double eastMin = Math.min(p1.east(), p2.east()); 325 double eastMax = Math.max(p1.east(), p2.east()); 326 double northMin = Math.min(p1.north(), p2.north()); 327 double northMax = Math.max(p1.north(), p2.north()); 328 double deltaEast = (eastMax - eastMin) / 10; 329 double deltaNorth = (northMax - northMin) / 10; 330 331 for (int i = 0; i < 10; i++) { 332 result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMin))); 333 result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin + i * deltaEast, northMax))); 334 result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMin, northMin + i * deltaNorth))); 335 result.extend(Main.getProjection().eastNorth2latlon(new EastNorth(eastMax, northMin + i * deltaNorth))); 336 } 337 338 return result; 326 return Main.getProjection().getLatLonBoundsBox(getProjectionBounds(r)); 339 327 } 340 328 -
trunk/src/org/openstreetmap/josm/gui/util/HighlightHelper.java
r8929 r9419 14 14 15 15 /** 16 * This class stores the set of highli ted primitives and17 * allows easy and fast change of highlighting 16 * This class stores the set of highlighted primitives and 17 * allows easy and fast change of highlighting. 18 18 */ 19 19 public class HighlightHelper { -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r9352 r9419 92 92 public static final String URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=%"; 93 93 94 private static char[] DEFAULT_STRIP = {'\u200B', '\uFEFF'};94 private static final char[] DEFAULT_STRIP = {'\u200B', '\uFEFF'}; 95 95 96 96 /** … … 1000 1000 1001 1001 /** 1002 * An alternative to {@link String#trim()} to effectively remove all leading and trailing white characters, including Unicode ones. 1002 * An alternative to {@link String#trim()} to effectively remove all leading 1003 * and trailing white characters, including Unicode ones. 1003 1004 * @param str The string to strip 1004 1005 * @return <code>str</code>, without leading and trailing characters, according to … … 1017 1018 1018 1019 /** 1019 * An alternative to {@link String#trim()} to effectively remove all leading and trailing white characters, including Unicode ones. 1020 * An alternative to {@link String#trim()} to effectively remove all leading 1021 * and trailing white characters, including Unicode ones. 1020 1022 * @param str The string to strip 1021 1023 * @param skipChars additional characters to skip
Note:
See TracChangeset
for help on using the changeset viewer.