As mentioned a while back, Geoserver had some experimental code for KML output. The latest PR1 release has vastly improved KML support, largely submitted by James MacGill.
There was a recent question on the GS-Users list about how to use the sucker inside Google Earth. My personal preference is still for WMS overlays, but if for some reason youâ€™d like your live data outputted as KML, read on.
1. First things first, grab the PR1 release.
2. Setup your desired datastore using the GS web interface. In my case i will configure a new ArcSDE datastore.
3. Add your new featuretype, making sure you set the SRS as 4326 and generate the corresponding bounding box.
4. Do the old Apply/Save/Load trick to load your changes.
5. Now our data is ready to go, we better check KML output is supported. Send a WMS (yes, WMS) GetCapabilities to your service and check that you have the following,
6. Weâ€™re almost done. Now all we need to do is setup a corresponding network link to point to the â€œKML documentâ€ (which is in fact, just a WMS call to the KML output format).
Add the following in the location box for a new network link,
and set the refresh parameters to fly-based refresh after â€œ4 secsâ€
7. Assuming all went ok, you should now have a feature for each polygon which can be toggled individually.
If you are feeling lucky, try adding label definitions and view scales to your SLD. Otherwise you may be unintentially trying to retrieve a KML file containing your whole road dataset
Be aware that due to the way GS extracts each feature, the polygon extents can and will extend beyond the requested BBOX, which can be a good or a bad thing i guess.
Things that could well be added in the future: KMZ support, more customisable KML output (such as Z/height attributes) â€¦ the list goes on. The flexibility in using the available Geoserver datastores certainly makes this a viable alternative to using the 100 different â€œarc exportersâ€. You just canâ€™t beat live data getting sucked straight from your database
If this article interests you, please swing by the GS-Users list and say gday, they are always keen to get more contributors on board.