KML Channel Report

From AwasuWiki
Jump to: navigation, search

Awasu's amazing versatility really shines when you start to move, (even ever so slightly) beyond its more straightforward text-based feed reader feature set.

Awasu's unique extraction of feed Metadata opens many new possibilities. One of my favorite types of feed Metadata is geo-spatial data. For some types of feeds, I like to see where a feed item is coming from or the geographical location that they are referencing in the feed.

Awasu is pre-equipped with a metadata module supporting W3C Basic Geo (WSG84 lat/long). But you can also add the GeoRSS Metadata module and the GeoRSS-Simple to W3C Basic Geo XSLT from Awasu's wiki to work with GeoRSS data.

KML is an XML-based language schema for expressing geographic information. There are many applications that support KML; Google Earth being the most widely known.

There are several different ways that you can structure KML data. In the example below if you have selected "Group items by channel" when you define your Channel Report, then this example report will create a "folder" for each channel that contains its feed items. If "Group items by channel" was not selected then all feed items will be listed in descending date order.

KML Channel Report

Download and unpack this ZIP file to the Resources/Report Templates directory (under the Awasu installation directory).

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
  <Document>
    <name>{%REPORT-NAME%}</name>
    {%?REPORT-DESCRIPTION%}
    <description>{%REPORT-DESCRIPTION%}</description>
    {%ENDIF%}
    <visibility>1</visibility>

{%?GROUP-ITEMS-BY-CHANNEL%}

{%REPEAT% Channels-IfGroupingItems}
  {%DEFINE% name="has-geo-metadata" val="false" type="text"}

<!--
Look for geo/longitude and geo/latitude, 
set a flag if found be undefining "has-geo-metadata"
-->
  {%REPEAT% FeedItems}
    {%?ITEM-METADATA% geo/latitude}
      {%?ITEM-METADATA% geo/longitude}
        {%UNDEFINE% has-geo-metadata}
      {%ENDIF%}
    {%ENDIF%}
  {%/REPEAT%}

  {%!has-geo-metadata%}
      <Folder>
        <name><![CDATA[{%CHANNEL-METADATA% name}]]></name>
        <description><![CDATA[{%CHANNEL-METADATA% description}]]></description>

    {%REPEAT% FeedItems}
      {%?ITEM-METADATA% geo/latitude}
        {%?ITEM-METADATA% geo/longitude}
        <Placemark>
          <name><![CDATA[{%ITEM-METADATA% name!}]]></name>
          <description><![CDATA[{%ITEM-METADATA% description}]]></description>
          <Point>
            <coordinates>{%ITEM-METADATA% geo/longitude},{%ITEM-METADATA% geo/latitude},{%?ITEM-METADATA% georss/elev}{%ITEM-METADATA% georss/elev}{%ELSE%}0{%ENDIF%}</coordinates>
          </Point>
        </Placemark>
        {%ENDIF%}
      {%ENDIF%}
    {%/REPEAT%}
    </Folder>
  {%ENDIF%}
{%/REPEAT%} <!-- Channels-IfGroupingItems -->
{%ELSE%}
  {%REPEAT% FeedItems}
    {%?ITEM-METADATA% geo/longitude}
      {%?ITEM-METADATA% geo/latitude}
    <Placemark>
      <name><![CDATA[{%ITEM-METADATA% name!}]]></name>
      <description><![CDATA[{%ITEM-METADATA% description}]]></description>
      <Point>
        <coordinates>{%ITEM-METADATA% geo/longitude},{%ITEM-METADATA% geo/latitude},{%?ITEM-METADATA% georss/elev}{%ITEM-METADATA% georss/elev}{%ELSE%}0{%ENDIF%}</coordinates>
      </Point>
    </Placemark>
      {%ENDIF%}
    {%ENDIF%}
  {%/REPEAT%}

{%ENDIF%} <!-- GROUP-ITEMS-BY-CHANNEL -->
  </Document>
</kml>

This KML Channel Report can be 1) emailed, 2) FTP'd, or 3) saved to a local network file, just like any other Awasu Channel Report. However if you're running Awasu interactively and have Google Earth installed, then this KML Channel Report is a prime candidate for using this Post Processing Open Command.

If you add this simple command to your KML Channel Report's "Run post-processing command", then every time you run your KML Channel Report Awasu will automatically start Google Earth loading the feed items contained in your report with placemarkers for each feed item plotted on the map.

cmd /c start {%REPORT-FILENAME%}