Login

Tag "google-earth"

Snippet List

KMLMiddleware

This is a slight modification from the original version at [http://djangosnippets.org/snippets/709/](http://djangosnippets.org/snippets/709/) and is a middleware designed to output the right headers for generated KML or KMZ content. In the case of KMZ content, it handles the compression of the original KML content into the KMZ format. This version applies the processing to only requests ending with a .kml or .kmz in the URL. For instance, a request with the URL **http://example.com/kml/foo.kml** or **http://example.com/foo.kmz** will get processed by this middleware.

  • google-maps
  • kml
  • kmz
  • google-earth
Read More

Forcing Right-Hand Rule (Counter Clockwise) Polygons in GeoDjango for Google Earth / KML

According to the KML Specification, Polygons must be oriented according to the Right-Hand Rule (Counter Clockwise orientation) for them to display correctly in Google Earth. Since not all Polygons are defined according to the Right-Hand Rule, you can use this code to orient them correctly when using GeoDjango. Thanks goes to jbronn of #geodjango on irc.freenode.net for this!

  • geodjango
  • kml
  • google-earth
  • polygon
  • orientation
  • right-hand-rule
Read More

KMZMiddleware

Serving KML from your Django webapp to feed Google-earth isn't that hard, it's just some fun with templates, plus some headers. But serving a compressed version of your KML needs a trick. KMZ isn't just zipped KML. A good KMZ file is a zipped file that decompress to a file called 'doc.kml', which is a KML file. So, I suppose 'http://yourdomain.com/kml/' points to a view generating a well-formed KML. I even suppose that 'http://yourdomain.com/kmz/' points to the same view, but it will serve KMZ instead that KML: no change needed in your code! If your webapps serves more than one KML file you just need to append the new KMZ urls to your urls.py, pointing to the very same view serving the KML version. Then add that urls to the list in this middleware. As an example I included a 'http://yourdomain.com/kml/restricted/' to 'http://yourdomain.com/kmz/restricted/' conversion.

  • middleware
  • kml
  • kmz
  • google-earth
Read More

3 snippets posted so far.