* @param newCenter The center x-value (easting) to zoom to.
* @param newScale The scale to use.
*/
public void zoomTo(EastNorth newCenter, double newScale) {
Bounds b = getProjection().getWorldBoundsLatLon();
LatLon cl = Projections.inverseProject(newCenter);
boolean changed = false;
double lat = cl.lat();
double lon = cl.lon();
if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); }
else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); }
if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); }
else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); }
if(changed) {
newCenter = Projections.project(new LatLon(lat,lon));
}
int width = getWidth()/2;
int height = getHeight()/2;
LatLon l1 = new LatLon(b.getMinLat(), lon);
LatLon l2 = new LatLon(b.getMaxLat(), lon);
EastNorth e1 = getProjection().latlon2eastNorth(l1);
EastNorth e2 = getProjection().latlon2eastNorth(l2);
double d = e2.north() - e1.north();
if (height > 0 && d < height*newScale) {
double newScaleH = d/height;
e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMinLon()));
e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMaxLon()));
d = e2.east() - e1.east();
if (width > 0 && d < width*newScale) {
newScale = Math.max(newScaleH, d/width);
}
} else if (height > 0) {