[mapguide-users] Overriding DPI

Traian Stanev traian.stanev at autodesk.com
Thu Sep 6 20:43:18 EDT 2007


The output looks correct in that if the resulting images are each viewed on a device that has the corresponding DPI resolution, the map scale of 5000 would be correct if physically measured with a ruler.
 
What exactly do you think is incorrect? The math behind it goes something like this:
 
double metersPerUnit = map->GetMetersPerUnit();

double metersPerPixel = 0.0254 / dpi;

double mappingWidth = imageWidth * metersPerPixel * scale / metersPerUnit;

 
You can see that the width (and also height) of the visible region will vary inversely with DPI, if everything else is constant.
 
Traian
 
 
 

	-----Original Message----- 
	From: mapguide-users-bounces at lists.osgeo.org on behalf of simon hope 
	Sent: Thu 9/6/2007 6:59 PM 
	To: mapguide-users at lists.osgeo.org 
	Cc: 
	Subject: [mapguide-users] Overriding DPI
	
	


	Hi,
	
	I'm trying a number of methods for exporting images:
	
	1. I used the MgRenderingService class to produce an image (had to use a
	nasty hack to get the current extent as map.GetDataExtent(); doesn't seem to
	work?), but using this method does not give me any control over the image
	dpi.
	
	2. I then sent a request over HTTP directly to the MapAgent CGI - this gives
	me the flexibilty to pass parameters over the URL, however when I set
	different DPI values, I always get an image set at 72 dpi. Here is a sample
	of the request:
	
	http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE&VERSION=1.0.0&SESSION=6669fbe4-0000-1000-8000-0013d3c0f8fe_en_C0A801140AFC0AFB0AFA&MAPNAME=Sheboygan&LOCALE=en&FORMAT=PNG&SETVIEWCENTERX=-87.732492&SETVIEWCENTERY=43.743934&SETVIEWSCALE=5000&SETDISPLAYDPI=96&SETDISPLAYWIDTH=1024&SETDISPLAYHEIGHT=768
	
	This URL uses 96 DPI - if i sent the same URL but increased the DPI, this
	has the effect of changing the extent of the actual image, despite keeping
	the other parameters static.
	
	I read on a post that DPI can be overriden "if the session allows it"? Does
	this mean that I have to update the session somewhere?
	
	I have attached three images using different DPI values (96, 300 and 600)
	which illustrates the effect.
	
	http://www.nabble.com/file/p12533054/http_request96.png http_request96.png
	http://www.nabble.com/file/p12533054/http_request300.png http_request300.png
	http://www.nabble.com/file/p12533054/http_request600.png http_request600.png
	
	I have also tried to increase the image width and height as I increase the
	dpi - this maintains the extent of the image, but does not alter the dpi.
	This method also results in some rather strange labelling  - the number of
	labels increases per feature.
	
	Cheers
	
	Simon
	
	
	
	--
	View this message in context: http://www.nabble.com/Overriding-DPI-tf4395160s16610.html#a12533054
	Sent from the MapGuide Users mailing list archive at Nabble.com.
	
	_______________________________________________
	mapguide-users mailing list
	mapguide-users at lists.osgeo.org
	http://lists.osgeo.org/mailman/listinfo/mapguide-users
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070906/550cb92f/attachment.html


More information about the mapguide-users mailing list