Changeset 12818 in josm for trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
- Timestamp:
- 2017-09-10T14:49:56+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java
r12161 r12818 5 5 import java.util.HashMap; 6 6 import java.util.Map; 7 import java.util.function.Consumer; 7 8 import java.util.function.DoubleUnaryOperator; 8 9 … … 204 205 result = projectionBoundsBox; 205 206 if (result == null) { 206 Bounds b = getWorldBoundsLatLon(); 207 // add 4 corners 208 result = new ProjectionBounds(latlon2eastNorth(b.getMin())); 209 result.extend(latlon2eastNorth(b.getMax())); 210 result.extend(latlon2eastNorth(new LatLon(b.getMinLat(), b.getMaxLon()))); 211 result.extend(latlon2eastNorth(new LatLon(b.getMaxLat(), b.getMinLon()))); 212 // and trace along the outline 213 double dLon = (b.getMaxLon() - b.getMinLon()) / 1000; 214 double dLat = (b.getMaxLat() - b.getMinLat()) / 1000; 215 for (double lon = b.getMinLon(); lon < b.getMaxLon(); lon += dLon) { 216 result.extend(latlon2eastNorth(new LatLon(b.getMinLat(), lon))); 217 result.extend(latlon2eastNorth(new LatLon(b.getMaxLat(), lon))); 218 } 219 for (double lat = b.getMinLat(); lat < b.getMaxLat(); lat += dLat) { 220 result.extend(latlon2eastNorth(new LatLon(lat, b.getMinLon()))); 221 result.extend(latlon2eastNorth(new LatLon(lat, b.getMaxLon()))); 222 } 223 projectionBoundsBox = result; 207 ProjectionBounds bds = new ProjectionBounds(); 208 visitOutline(getWorldBoundsLatLon(), bds::extend); 209 projectionBoundsBox = bds; 224 210 } 225 211 } … … 232 218 return this; 233 219 } 220 221 @Override 222 public void visitOutline(Bounds b, Consumer<EastNorth> visitor) { 223 visitOutline(b, 100, visitor); 224 } 225 226 private void visitOutline(Bounds b, int nPoints, Consumer<EastNorth> visitor) { 227 double minlon = b.getMinLon(); 228 if (b.crosses180thMeridian()) { 229 minlon -= 360.0; 230 } 231 double spanLon = b.getMaxLon() - minlon; 232 double spanLat = b.getMaxLat() - b.getMinLat(); 233 234 //TODO: Use projection to see if there is any need for doing this along each axis. 235 for (int step = 0; step < nPoints; step++) { 236 visitor.accept(latlon2eastNorth( 237 new LatLon(b.getMinLat(), minlon + spanLon * step / nPoints))); 238 } 239 for (int step = 0; step < nPoints; step++) { 240 visitor.accept(latlon2eastNorth( 241 new LatLon(b.getMinLat() + spanLat * step / nPoints, b.getMaxLon()))); 242 } 243 for (int step = 0; step < nPoints; step++) { 244 visitor.accept(latlon2eastNorth( 245 new LatLon(b.getMaxLat(), b.getMaxLon() - spanLon * step / nPoints))); 246 } 247 for (int step = 0; step < nPoints; step++) { 248 visitor.accept(latlon2eastNorth( 249 new LatLon(b.getMaxLat() - spanLat * step / nPoints, minlon))); 250 } 251 } 234 252 }
Note:
See TracChangeset
for help on using the changeset viewer.