Opened 14 years ago

Closed 12 years ago

#1245 closed enhancement (wontfix)

Map Image format automatic optimization

Reported by: msuing Owned by:
Priority: medium Milestone:
Component: AJAX Viewer Version:
Severity: major Keywords: image, format, png, png8
Cc: External ID:

Description

Hi all,

Since the quality of PNG8 is still not ideal (see http://trac.osgeo.org/mapguide/ticket/634), we often face a dilemma : quality OR speed (PNG or PNG8). It would be great to allow MapGuide to adapt automatically the map image format depending on the client connection speed.

The idea would be to define the image format as a parameter in ajaxmappane.templ :

var mapImageFormat = 'PNG'; default map image format var mapImageAutoFormat = true; automatic optimization of map image format var connectionSpeedLimit = 5000; minimum connection speed for high quality

Then to change the map url to allow a dynamic map image format : function RequestMapImage(reqId, viewParams){

url = webAgent + "?OPERATION=GETDYNAMICMAPOVERLAYIMAGE&FORMAT=" + mapImageFormat + "&VERSION=2.1.0&SESSION="...

After the first map has been loaded we could evaluate the connection speed to change the format to PNG if it's good or PNG8 if it's bad (below connectionSpeedLimit Kbps), for the rest of the session :

function AutoImageFormat() {

var st = new SpeedTest(); st.run({

onStart: function() {

alert('Before Running Speed Test');

} ,onEnd: function(speed) {

alert( 'Speed test complete: ' + speed.Kbps + ' Kbps ' + speed.KBps + ' KBps'); if( speed.Kbps > connectionSpeedLimit )

mapImageFormat = 'PNG';

else

mapImageFormat = 'PNG8';

}

});

}

var SpeedTest = function() { };

SpeedTest.prototype = {

imgUrl: "../stdicons/speedtest.png" Where the image is located at ,size: 258048 size in bytes ,run: function( options ) {

if( options && options.onStart )

options.onStart();

var imgUrl = this.imgUrl + "?r=" + Math.random(); this.startTime = (new Date()).getTime() ;

var testImage = new Image(); var me = this; testImage.onload = function() {

me.endTime = (new Date()).getTime(); me.runTime = me.endTime - me.startTime;

if( options && options.onEnd )

options.onEnd( me.getResults() );

}; testImage.src = imgUrl;

}

,getResults: function() {

if( !this.runTime )

return null;

return {

runTime: this.runTime ,Kbps: ( this.size * 8 / 1024 / ( this.runTime / 1000 ) ) ,KBps: ( this.size / 1024 / ( this.runTime / 1000 ) )

};

}

}

To go one step further, we could :

  • evaluate this connection speed directly on the map image previously loaded instead of "../stdicons/speedtest.png"
  • choose to put automatically JPG format if one of the displayed layers is based on a raster datasource.

Cheers,

Max.

Change History (2)

comment:1 by jbirch, 14 years ago

Version: 2.1.0

Removing version from enhancement ticket (assumed valid regardless of version until implemented).

comment:2 by jng, 12 years ago

Resolution: wontfix
Status: newclosed

This looks too specialized a solution. And PNG8 is much better now anyways.

Note: See TracTickets for help on using tickets.