[geotk] Re: Get envelope for a scale

theuns theunsheydenrych at gmail.com
Tue Sep 8 06:06:12 EDT 2009


Hi All

I did a few experiments, and it looks like the pixels per inch is a
issue.

I have in my possession a 1:50 000 scale map as a hard copy of the area
i am looking at, the hard copy map have a UTM grid on it, and one UTM
block on the map represents 1km.
The physical size of the UTM block on the printed map is 2cm x 2cm.

For the same area i have shapefile data like roads, rivers etc. and a
1:50 000 UTM grid shapefile.

Please correct me if i am wrong but my understanding is that if i
display the data on the screen , and zoom to a scale of 1:50 000 , the
UTM blocks should also be 2cm x 2cm?

I implemented the code below to get the current map scale and use for a
start the 1/72 pixels per inch (PPI).
Then use the following method to zoom to the correct scale.

double scaleChange = MapScale / 50000;
mapWidget.getCanvas().getController().scale(scaleChange, point);

When measuring the physical length and width of the UTM grid block on
the screen , i get the following values.

1. 1/72.0 PPI is +- 3mm short
2. 1/98.30691947 PPI is +- 3mm to long
3. 1/86.0 PPI spot on.

The 1/98 PPI i got from the formulas on
http://en.wikipedia.org/wiki/Pixels_per_inch 

My laptop values is 1280 wide 800 high and the diagonal width is
15.354331 inches.

The 1/86.0 i just played with until i get a value that works.

Now before i get shot, is there any fault in my reasoning?
And the PPI value should surely not be hardcoded, how to get that for
different size monitors?
And does aspect ratio play a role?
If it does how will i use it to incorporate the aspect ration into the
calculations? 


 

On Mon, 2009-09-07 at 15:36 +0200, Martin Desruisseaux wrote:
> Theuns Heydenrych a écrit :
> > 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
> 
> Yes I think it is about that. Sometime I do error by putting a division instead 
> than a multiplication or vis-versa, but I think you will spot such mistake from 
> the numerical values. At least all the required steps are as above (as far as I 
> known).
> 
> 	Martin
> 



More information about the Geotoolkit mailing list