[geotk] Re: Get envelope for a scale

Theuns Heydenrych theunsheydenrych at gmail.com
Mon Sep 7 08:12:52 EDT 2009


Thanks for the help Martin and Johann
Here is what i did, can you confirm that the thinking is correct?

AffineTransform objectiveToDisplay = (AffineTransform)
mapWidget.getCanvas().getObjectiveToDisplayTransform();
//Amount of inches in one meter
double inchesInOneMeter = 39.3700787
//physical size of pixel on screen
double pixelPhysicalSize = (1/72.0) ;
//physical size of screen pixel in meter
double physicalSizeInMeter = pixelPhysicalSize / inchesInOneMeter;
//The current scale of the projected map
double currentScale = XAffineTransform.getScale(objectiveToDisplay);
//The size of one pixel on the map in meter
double onePixelInMeter = 1/currentScale ;
//The map scale
double MapScale = onePixelInMeter / physicalSizeInMeter ;

Result is then 1:MapScale

This way the you compare one screen pixel size in meter to one pixel size on
the map.

Do you guys agree?




On Mon, Sep 7, 2009 at 12:18 PM, Martin Desruisseaux <
martin.desruisseaux at geomatys.fr> wrote:

> Theuns Heydenrych a écrit :
>
>> What exactly does this number mean, is it the size of a pixel representing
>> one meter?
>>
>
> It is the amount of pixels in one metres. The inverse (23560) is the "real
> world" size in metres of one pixel.
>
> In order to compute a map scale, you need to know the physical size of one
> pixel on your screen device. There is some API in Java2D that are supposed
> to give you this information, but it seems to often fallback on 1/72 of inch
> as a default value.
>
> If "ps" is the physical size in metre of one pixel on your screen, then
>
>  scale(objectiveToDisplay) * ps
>
> should give you the map scale.
>
>        Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geotoolkit/attachments/20090907/15ed599e/attachment.html


More information about the Geotoolkit mailing list