Thursday 23 February 2017

WMS + Google Earth + tilted view = alignment failure?


I'm working on a custom web-based application that generates spatial data and that includes a web-based map viewer. We have a custom servlet that handles WMS requests (not a complete WMS implementation, just enough for our needs) and uses MapServer/SWIG to generate image data. The web front end uses OpenLayers. So far, so good: everything works and gives us nice-looking interactive maps.


We also built a feature that creates a KML file with a that refers to our WMS URL -- the user clicks a link and it opens in Google Earth and they can see the data. Again, so far, so good.


The problem comes when the user starts to tilt the camera and pan around in Google Earth. Google Earth starts mis-registering our data, at first by just a few meters at a time but eventually by tens of kilometers, if you tilt, zoom in and out, and pan around enough.


I did some searches and I found several sites that indicated that Google Earth's support for tilting WMS imagery was poor, but little in the way of specifics. Has anyone else tried this and experienced similar issues?


More importantly, how should I approach this problem? Given that our users are very interested in doing exactly this kind of exploration (plot data with topography, tilt the camera down, and fly around in our subject area) and that our users are already pretty committed to using Google Earth as the client, how should we make the data available so that they can view it?



Answer




I am guessing that you are trying to render a single WMS image to cover the entire view. Remember that when the image is tilted it is very difficult to render a rectangular image of the correct resolution for the entire area. Locations close to the camera need to be rendered differently to features on the horizon. Therefore, direct use of WMS is completely unsuitable for use in Google Earth and should be avoided.


The best approach is to create a network link that divides the area into a set of tiles, each with its own unique link to a fixed extent of the WMS as a Super Overlay. This allows Google Earth to decide which tiles to load and when. It will also make it much simpler to implement caching at the server end. Create larger tiles for different zoom levels using the Region tag. When the view is tilted Google Earth can use lower resolution tiles on the horizon, and higher resolution for closer areas. For an idea of a good structure try converting your data manually using the KML Super Overlay GDAL driver.


For large tiles the WMS response needs to be in WGS84 due to projection issues. For smaller tiles it is sometimes possible to use a local projection system by individually calculating the WGS84 coordinates of the tile corners. There are obvious projection issues, although the results are often better than interpolating.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...