Bryan,

If I were to call:

setView(nBands, nBandList, dWorldTLX, dWorldTLY,
        dWorldBRX, dWorldBRY, nWidth, nHeight);

What would be the correct way to call it again with a "zoom in"?  I tried
something like this:

setView(nBands, nBandList, dWorldTLX, dWorldTLY,
        dWorldBRX*2, dWorldBRY*2, nWidth, nHeight);
As I understand it the Java SDK was designed to allow Java application developers to add raster backdrops (using ECW) to Java mapping applications. The assumption is that the Java mapping application is responsible for two things:

1. Providing the user with the GUI tools required to interact with the map.
2. Managing the state of the map view.

Therefore, when the user zooms the map the mapping application calls setView with the required extent.

In your case, if you want to zoom in to the centre of an image you first need to know the size of the view in pixels (nWidth, nHeight) and the extent of the view in world coordinates (dWorldTLX, dWorldTLY, dWorldBRX, dWorldBRY). You can then calculate a new extent and call setView. A long-winded example would be:

double dZoomFactor = 2d;

// Calculate the width and height of the current view in world coordinates.
double dWorldWidth = dWorldBRX - dWorldTLX;
double dWorldHeight = dWorldTLX - dWorldBRX;

// Calculate the centre of the view in world coordinates.
double dWorldCentreX = dWorldTLX + dWorldWidth / 2;
double dWorldCentreY = dWorldBRY + dWorldHeight / 2;

// Calculate the width and height of the zoomed in view based on the zoom factor.
double dZoomWorldWidth = dWorldWidth / dZoomFactor;
double dZoomWorldHeight = dWorldHeight / dZoomFactor;

// Calculate the new view extent.
double dZoomWorldTLX = dWorldCentreX - dZoomWorldWidth / 2;
double dZoomWordTLY = dWorldCentreY + dZoomWorldHeight / 2;
double dZoomWorldBRX = dWorldCentreX + dZoomWorldWidth / 2;
double dZoomWorldBRY = dWorldCentreY - dZoomWorldHeight / 2;

/* Request an updated view. nWidth and nHeight do not change unless
the size of your on screen display has changed. */
setView(nBands, nBandList, dZoomWorldTLX , dZoomWordTLY ,
dZoomWorldBRX , dZoomWorldBRY , nWidth, nHeight);

Hope this helps on the zoom issue. Using GUI tools (i.e. zoom box) required you calculating the world coordinates based on the pixel coordinates that the user clicked on. i.e. Mouse down and mouse up.

Regards
Andrew Hallam

Digital Earth Pty Ltd
http://www.digitalearth.com.au
-----------------------------------------------------------

To make changes to your subscription, please visit our website, http://www.ermapper.com/technicl/ermapperl/index.htm

Reply via email to