Real-time Taxi Cabs (KML Network Link Example)

From fmepedia

ss_google_earth_taxi_cabs_thumb.png (http://fmepedia.com/attachments//Real-time_Taxi_Cabs_(KML_Network_Link_Example)/ss_google_earth_taxi_cabs.png)

Scenario

This example uses FME Server to handle real-time data and publish it to a KML output for viewing in Google Earth.

It demonstrates how to create a workspace that translates location data (in this case taxi cab positions) into a styled KML dataset, how to publish that workspace to the FME Server, and how to utilize FME's KML Network Link Service to show the taxi cab locations in Google Earth in real-time.


Table of contents



Viewing the Example

This example is set up and running on Safe's FME Server demo site. You can try it out by clicking either of these links below.
The sole requirement for running the live demo is installation of Google Earth. On opening you will need to tick the check box for the link and double-click the link to activate it.


Run it live (http://fmeserver.com:80/fmekmllink/Demos/mobile_assets_fence_buffer.fmw) Watch a demo (http://www.safe.com/products/server/demos.php)



See the following information if you want to implement the example on your own FME Server, or find out how simple it is to implement.



How it Works

As with most FME Server scenarios, a Spatial ETL process (workspace) is designed using FME Desktop (Workbench) and uploaded to FME Server.

The workspace reads live GPS data as its input, restructures the contents, and outputs KML format data. When uploaded to the FME Server it is registered as a KML Network Link service.

Now when the translation URL is called (as in the "Run it Live" link above) a request is made to FME Server. It runs the workspace and returns KML format data directly to Google Earth.

By setting the refresh rate in Google Earth (say 1 second), a new request is made at the defined interval and a new set of data returned.


Workspace

The workspace used to generate the KML output has this content: ss_workspace_thumb.png (http://fmepedia.com/attachments//Real-time_Taxi_Cabs_(KML_Network_Link_Example)/ss_workspace.png)

  1. Google Earth uses the KML Network Link, provided by FME Server, to request KML data from FME Server.
  2. When this URL is requested, FME Server performs a workspace translation that:
    • reads the current_points.csv file,
    • adds a geometry component to each row (or feature) based on the location field (or attribute),
    • adds a text label to each point feature based on the cab_number and operator fields,
    • adds a different icon to each point feature based on the value of the status field, and
    • writes the point features out to a KML file.
  3. The KML file is then streamed back to Google Earth for display.
  4. The process is repeated based on the KML Network Link's refresh interval.



Setting up the Example

For the purposes of this exercise, the taxi location info is being generated by a (non-FME) script in place of a GPS tracking service. However, substitution of a real source dataset would be extremely simple and, if anyone has access to such a source, please feel free to contact us (mailto:fmepedia@safe.com) to discuss incorporating that data into a similar demo.


Requirements


Initial Steps

  • Download the example Workspaces, Datasets and Python Script zip file.
  • Unzip the file.
  • Copy the 'data' directory and the 'GPS-Software.py' script to the following directory on the computer that has FME Server installed:
    • C:\temp\
  • Copy the 'taxi_icon_*.png' files to a web accessible directory. For Apache-Tomcat, copy the files to the following directory:
    • <ApacheTomcat>\webapps\ROOT\


FME Server Steps

  • Open the 'realTimeTaxiCabs.fmw' workspace in FME Workbench 2008 or greater.
  • Open the properties of the KMLStyler transformers and modify the Icon Name parameter so that it references the correct URL pointing to each of the 'taxi_icon_*.png' files.
  • Save the workspace.
  • Publish the workspace to FME Server into the 'Demos' repository (you may need to create this repository using the New button) and register it with the KML Network Link Service.
    • Note: you will be prompted to upload the current_points.csv file, but we know that this file will exist on the computer that has FME Server installed, so you should uncheck the Upload checkbox.



Running the Example

ss_gps_software_thumb.png (http://fmepedia.com/attachments//Real-time_Taxi_Cabs_(KML_Network_Link_Example)/ss_gps_software.png)

  • GPS Tracking Software:
    • Start the 'GPS-Software.py' script by double clicking the file or running it from the command line (this will start generating the c:\temp\current_points.csv file that contains the real-time locations and attributes).


ss_run_kml_network_link_thumb.png (http://fmepedia.com/attachments//Real-time_Taxi_Cabs_(KML_Network_Link_Example)/ss_run_kml_network_link.png)

  • FME Server:
    • Open the FME Server web interface, click the Services tab, expand the KML Network Link Service, expand the 'Demos' repository, click the Run button next to the 'realTimeTaxiCabs.fmw' workspace.
    • You will be prompted to open/save a Google Earth KMZ file, click open to have the KML Network Link open in Google Earth.


ss_kml_network_link_refresh_thumb.png (http://fmepedia.com/attachments//Real-time_Taxi_Cabs_(KML_Network_Link_Example)/ss_kml_network_link_refresh.png)

  • Google Earth:
    • Right click the KML Network Link and select Properties.
    • In the Edit Network Link window, click the Refresh tab and change the Time-Based Refresh to 1 second instead of 1 minute and click the OK button (if you running a less powerful computer, than you may want to select 3-5 seconds instead).
    • Check on the KML Network Link and double click it to zoom in to the Taxi Cabs.




Moving On...

At this point FME's big advantage is the ability to blend in other datasets and to carry out other types of data transformation.

For example:

  • Add a new source to the workspace that feeds in traffic reports to highlight potential problem areas.
  • Add in static navigation data - such as speed limits, low bridges etc - to view the real-time data against
  • Merge in specialist background data - such as a set of specific raster map overlays

And of course this is just an example: it would be just as simple to use any form of live spatial data, such as other modes of transport (bus, aircraft, trucks, ferries, trains, etc) or environmental data (weather, pollution, rainfall, etc).



More Information

Please feel free to contact us for more information on this particular example, or any other spatial data solutions this example inspires in you.

Technical Info: Contact support@safe.com (mailto:support@safe.com)
Product Info: Contact sales@safe.com (mailto:sales@safe.com)



User Comments Add a new comment