Click or drag to resize

GeoStream renderers

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
GeoStreamRenderer

If you are using GeoStream with a JavaScript client, you can create your own rendering class to inject code into a GeoStream tile server that generates your own custom overlay tiles. GeoStream rendering classes override the abstract GeoStreamRenderer class. At a minimum, you must provide an implementation for the abstract Render method and the abstract ExpiresAfter property. In addition, you can override the CacheId and DataDependentCache properties.

Render method

The Render method of GeoStreamRenderer is just like the Render method of the IMapRenderer interface that is used to draw on a map that shows data from local GBFS files. Implement this method to draw on the map.

C#
public override void Render(Graphics graphics, RenderContext rc) {

    // If we are zoomed a long way out, don't draw anything
    if (rc.Map.Zoom > 2000) {
        return;
    }
    // Calculate a reachable area to draw on the map.
    ReachableArea walkableInAnHour = 
            ReachableArea.WithinTimeSpan(new LatLon(34.1018, -118.2973),
                                         new TimeSpan(1, 0, 0), 
                                         new RoutingStrategyForPedestrian());

    PolygonFence reachable = walkableInAnHour.ComputeConvexPolygon();
    reachable.RenderBrush = new System.Drawing.SolidBrush(Color.FromArgb(80, Color.Blue));
    reachable.RenderPen = new System.Drawing.Pen(Color.Blue, 1);
    // Polygon Fences are drawn in the Prelabelling render mode
    // because there are no modes on the server, set the mode here.
    rc.Mode = RenderMode.PreLabelling;
    // use the render method of the reachable area to draw on the map.
    reachable.Render(graphics, rc);
}

ExpiresAfter property

The ExpiresAfter property controls how long the tiles your renderer creates can remain in the GeoStream tile cache before they expire. This value must be at least one minute.

C#
public override TimeSpan ExpiresAfter {
     get {
         return TimeSpan.FromMinutes(1);
     }
 }

DataDependentCache property

The DataDependentCache property indicates whether the renderer generates tiles that depend on data from the currently-loaded GBFS file. By default, this property is false. If you change this value to true, then any time the GBFS file changes, the GeoStream server generates new tiles rather than using cached versions. You do not need to override this property if your renderer does not use data from the current GBFS file.

Bounds property

The Bounds property indicates the area of the map that the renderer draws on. By default, this property is null, indicating that the renderer can draw anywhere on the map. If your renderer only draws within a limited geographic area, you can improve performance by supplying a bounding box as the value of Bounds. When Bounds is non-null, the Render method is not called for any tile requests that do not overlap the bounding box. This can significantly improve performance.

CacheId property

The CacheId property lets you implement your renderer so that it draws different things depending on arguments from the client. By making the value of CacheId dependent on the same arguments that your Render method uses, you ensure that the GeoStream server only uses cached tiles that were generated using the same arguments as the current request.

C#
public override string CacheId {
     get {
         return Request.Params["color"];
     }
 }

Setting up the server

Your renderer class must be added to an aspx file. The aspx page must have its "async" attribute set to true. You must place the aspx file in the renderers subfolder of your GeoStream server's root directory (by default, this is C:\Program Files\Telogis\GeoBase\GeoStream\server\renderers).

Note Note
If the renderers folder does not exist, you can add it to the root directory of your GeoStream tile server. However, it must be named renderers.

Although a GeoStream renderer generates a tile layer, similar to a WMS tile layer, you do not need to add the layers your renderers produce to the layers.config file. The GeoStream server automatically finds your renderer as long as it is in the renderers folder.

Calling a renderer from a Javascript client

Because a GeoStream renderer produces a tile layer, you can access the tiles your renderer produces from a JavaScript client the same way you access WMS tile layers: by creating a TileLayer object. In the tileConfig of the TileLayer, identify the renderer to use by setting the ServerPage attribute:

JavaScript
var tileLayer = new TileLayer({
   id: 'custom_info',
   map: map,
   tileConfig: {
      ServerPage: 'renderers\myRenderer.aspx',
      args: {myCustomArg: 'myCustomArgValue'}
   }
});

Your JavaScript client can obtain a list of all GeoStream renderers currently installed on the tile server by calling the getGeoStreamRenderers method:

JavaScript
 Telogis.GeoBase.getGeoStreamRenderers(function(renderers) {
    selector = document.getElementById("rendererSelect");
    for (var iRend in renderers) {
        var opt = document.createElement("option");
        opt.value = renderers[iRend];
        opt.text = renderers[iRend];
        selector.add(opt);
    }
});

The getGeoStreamRenderers method takes a single parameter, which is an array of strings, where each string is the path of a renderer. These strings can be assigned to the Serverpage attribute of a tileConfig value.