For a while now I’ve wanted to play with the PHP script that Chris wrote to drag data off an WMS server and throw it onto Google Earth via a network link. Tonight I had some time, so I adapted the script to query the Atlas of Canada‘s WMS server and present the results.
The Atlas of Canada makes 25 layers available on its WMS server, of which I took the seven most useful for my script. While Google Earth’s built-in layers already contain all this information, the point of this exercise was more to acquaint myself with the nitty-gritty of querying geographical databases.
The Atlas of Canada provides background about its WMS server here, while an XML document handles the details. I used both to create a custom PHP script that sits on the Ogle Earth server. When this script is invoked by a network link in Google Earth, it takes the bounding box information Google Earth gives it and brings it to the WMS server, where it asks politely for the required layers. The result is correctly positioned GIFs delivered to Google Earth.
Here is the script if you want to take a gander at the code.
Here is the network link for you to download if you want to see the script in action.
As the metadata about the layers is encoded in a standard XML document that is delivered by the WMS server upon request, there are opportunities here for automating the repetitive work I did to code the seven layers. A much more powerful solution would be to write a parser that queries any given WMS server for the metadata, which it then uses to construct the custom PHP script and KML network link for that server.
Even better would be for Mapdex.org to automatically provide these files alongside search results for WMS servers:-)