Streamsdev | Visualizing Location Data in a Streaming Application

When developing an application that handles geospatial data, it is imperative that we can actually view the data on a map, and see how it is being manipulated by the application. In this article, I am going to demonstrate how you can easily write a Streams application to display your application geospatial data onto a map in a web browser. The MapViewerSample from the Github Samples repository is developed to show how this can be done. The sample application randomly generates location data for two types of entities around Hong Kong Island. Taxi data will be displayed with a red marker on a map. Public Minibus data will be displayed with a green marker. Here’s a screen capture that shows the end result of our sample application: The code for this sample application can be found here: This is the SPL code from the Main composite of the sample application. This application uses a Custom operator to randomly generate location data. The custom operator generates the following information: With the latitude and longitude information, the application calls the…) function to convert the coordinates to a WKT string. The tuples are submitted to a composite operator called MapViewer. The most important part of this application is the MapViewer composite. This composite operator wrappers a HTTPTupleView operator and sets up the resource and context paths for the Jetty server. The MapViewer composite expects schema of the input stream to be of type MapViewerT. MapViewerT is defined as follows: In the composite, the HTTPTupleView operator is set up with a sliding window, partitioned by the entity ID. This allows us to keep history for each of the entities in case we want to show where the entities have traveled over a period of time. The window size is configurable via the $windowSize parameter. The HTTPTupleView operator is also set up with contextResourceBase and context parameter. The contextResourceBase parameter defines the directory location of resources that will be available through the URL context defined by the context parameter. In this case, it is expected that the static html resources are located in <,Applicaton Directory>,/etc directory. The context parameter defines a URL context path that maps the resources defined by the contextResourceBase. With this configuration, you can browse for static html files from the Streams application using the following URL: http://<,PE host>,:8080/map Next, we need an HTML page for displaying the data. The map.html file is located in the MapViewerSample/etc/ directory. It contains JavaScript that displays a map, queries for data from the Streams application and displays the data as markers on the map. To view the location data on a map in a browser, you need to first launch your application to a Streams instance. Once the application is successfully started, start a web browser and enter the following URL: In the previous section, we mentioned that each of the entities can be tagged with a note. The note information can be displayed in popup on the map. To see this information, use the following URL: Source.

Яндекс.Метрика Рейтинг Free Web Counter
page counter
Last Modified: April 18, 2016 @ 11:01 am