Here's the code I use. My AOI is defined by maxLat, maxLon, minLat, minLon. This will set the scale and recenter the map on the center.
//start code
Projection p = bean.getProjection();
LatLonPoint centerPoint = new LatLonPoint((maxLat + minLat) / 2,
(maxLon + minLon) / 2);
float scale = ProjMath.getScale(new LatLonPoint(maxLat, maxLon),
new LatLonPoint(minLat, minLon), p);
bean.setScale(scale);
bean.setCenter(centerPoint);
//end code
--------------------------------
Jeremy Zacker
Northrop Grumman - IBCP
(732) 530-5063
jeremy.zacker@ngc.com
-----Original Message-----
From: David Ward [mailto:mry_yachtsman@hotmail.com]
Sent: Friday, June 18, 2004 12:49 PM
To: MChapman@sanz.com; openmap-users@bbn.com
Subject: RE: [OpenMap Users] Calculating map scale?
Mark,
1. I ran into a similar problem sometime ago. In my problem I was trying
to calculate a map scale from a radius. The problem I ran into is that you
get different behavior in the calculation based on your current projection.
Calculating a scale given a radius really blows up when using a Lambert
Conformal Conic projection.
2. My final solution was to abandon trying to provide the user with a
capability of specifying a radius has a means to set the map scale. I still
have a zoom too feature which allows the user to center on an object and
zoom in, but scale is not specifiable by the user.
Cheers,
David
-----------------
David J. Ward
mry_yachtsman@hotmail.com
>From: "Chapman, Martin" <MChapman@sanz.com>
>To: <openmap-users@bbn.com>
>Subject: [OpenMap Users] Calculating map scale?
>Date: Fri, 18 Jun 2004 09:32:30 -0600
>
>All,
>
>I have a question on how to accurately calculate the map scale for a
>zoom-to feature that I am implementing in our application. I have read
>user-group articles that explain that scale is a function of pixels to
>screen res (or something like that). I basically want to be able to
>scale the map to fit an area of interest. The area could be as small as
>a few square miles and as big as an entire hemisphere, or the world. I
>currently am calculating the scale using the aoi width and height
>multiplied by meters per degrees, but it only works on smaller size
>aoi's. When the aoi gets big it doesn't scale correctly. Does anyone
>have an algorithm that would do this?
>
>Martin Chapman
>Cell 303-885-1936
>Office 303-660-3933 x226
>mchapman@sanz.com
>http://www.sanz.com <http://www.sanz.com/>
>
>
_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page - FREE
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"] -- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Mon Jun 21 14:21:05 2004
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:39 EDT