Friday, August 8, 2008

Poor Man's Tracking

Short of using BlazeDS for asynchronous event notification, RSS is nice "standard" way to publish events. And since XML is a first class citizen in AS3, then parsing the feed is relatively easy. Yes, sure, I can use this syndication library, but it does not give me the control that I need over the feed items, specially over custom tags. One of these custom tags refer to GeoRSS, where you can add a geographical reference to the RSS entries. The geo tags can be of the form of points, lines or polygons. Here is a sample of a GeoRSS feed in JSP, where on every request a random lat/lon point value is generated. This can easily be extended to get the values from a database or a GPS source:

<%@ page contentType="text/xml" language="java" %>
final double lat = -45.0 + 50.0 * Math.random();
final double lon = -45.0 + 50.0 * Math.random();

<subtitle>International earthquake observation labs</subtitle>
<name>Mansour Raad</name>
<title>M 3.2, Mona Passage</title>
<summary>We just had a big one.</summary>
<georss:point><%=lat%> <%=lon%></georss:point>

To read and render the entries on a map, I've extended the GraphicLayer class to create a GeoRSSLayer and it is used as follows:

<?xml version="1.0" encoding="utf-8"?>
<esri:SimpleMarkerSymbol style="circle" color="0x00FFFF" size="20"/>

The GeoRSS class has two additional attributes. The url attributes points to the georss feed location, and the delay attribute indicates the delay time in milliseconds to check for new feed entries. You can download the full source code from here. This is assuming that you are using the Flex API for ArcGIS :-)

No comments: