Google Earth with WMS Overlays continued ..

Apologies for the third thread on this topic, but again i need to clear the air and post a fix for the overlay accuracy issue. Paul raised the concern of overlay accuracy in his own script and so it was obvious i should post the solution.

It is a small fix and all that is required is to calculate a ratio of the min/max bounding box coordinates in order to caclulate the height, in pixels, of the image.

For everyone who has their own alternative script working, simply add the following calculation to your variables,

= 800; $ratio1 = ($coords[2] - $coords[0]);  $ratio2 = abs($coords[1] - $coords[3]); $ratio = $ratio1 / $ratio2;  $height = (int)($width / $ratio); ?>

Then all is needed is to reference these $height and $width vars when calling your WMS request, such as …

[1] = "Cadastre";  $WMS[1] = ""; ?>

The problem with hardcoding these variables is that on occasion, the proportion of the returned WMS image does not match the proportions of the bounding box coordinates. In this situation google attempts to stretch the image to fit the given coordinates, and of course, distortion occurs … resulting in overlays which will not fit the base data. This will fix the problem.

Alternatively you can grab the entire example PHP source right here.

Any further questions id be glad to help.

2 thoughts on “Google Earth with WMS Overlays continued ..”

Comments are closed.