Changeset 9431 in josm
 Timestamp:
 20160113T14:00:42+01:00 (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r9426 r9431 700 700 } 701 701 702 private EastNorth getPointAlong(int i, int N, ProjectionBounds r) { 703 double dEast = (r.maxEast  r.minEast) / N; 704 double dNorth = (r.maxNorth  r.minNorth) / N; 705 if (i < N) { 706 return new EastNorth(r.minEast + i * dEast, r.minNorth); 707 } else if (i < 2*N) { 708 i = N; 709 return new EastNorth(r.maxEast, r.minNorth + i * dNorth); 710 } else if (i < 3*N) { 711 i = 2*N; 712 return new EastNorth(r.maxEast  i * dEast, r.maxNorth); 713 } else if (i < 4*N) { 714 i = 3*N; 715 return new EastNorth(r.minEast, r.maxNorth  i * dNorth); 716 } else { 717 throw new AssertionError(); 718 } 719 } 720 702 721 @Override 703 722 public Bounds getLatLonBoundsBox(ProjectionBounds r) { 723 final int N = 10; 704 724 Bounds result = new Bounds(eastNorth2latlon(r.getMin())); 705 725 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))); 726 LatLon llPrev = null; 727 for (int i = 0; i < 4*N; i++) { 728 LatLon llNow = eastNorth2latlon(getPointAlong(i, N, r)); 729 result.extend(llNow); 730 // check if segment crosses 180th meridian and if so, make sure 731 // to extend bounds to +/180 degrees longitude 732 if (llPrev != null) { 733 double lon1 = llPrev.lon(); 734 double lon2 = llNow.lon(); 735 if (90 < lon1 && lon1 < 180 && 180 < lon2 && lon2 < 90) { 736 result.extend(new LatLon(llPrev.lat(), 180)); 737 result.extend(new LatLon(llNow.lat(), 180)); 738 } 739 if (90 < lon2 && lon2 < 180 && 180 < lon1 && lon1 < 90) { 740 result.extend(new LatLon(llNow.lat(), 180)); 741 result.extend(new LatLon(llPrev.lat(), 180)); 742 } 743 } 744 llPrev = llNow; 714 745 } 715 746 // if the box contains one of the poles, the above method did not get
Note: See TracChangeset
for help on using the changeset viewer.