Skip to content
February 15, 2012 / Gagan

Tile Feature Strategy in OpenLayers

No doubt there is a huge requirement for client side vector rendering capabilities. The reason being the user interaction with features can be enhanced that can not be thought in case of tile images.

One critical point for heavy traffic sites is caching of the data. Caching can be considered at server side (http cache) and browser cache to reduce the load on servers. So for caching the vector data requests, we  need to request the data from server in predefined extent or tile wise.

I have implemented the client side handling of the tiled vector data request with OpenLayers. OpenLayers has different strategies for requesting the data from server like Fixed, BBOX. Similar way I created a strategy to request the features tile wise and to handle the response, named as Tile Feature Strategy TFS. Here is the working example of TFS with OpenLayers

You can check the TFS class source code that is inherited from OpenLayers Strategy class. I have used GeoJSON format for features. There is slight modification in protocol as well as, check here Protocal_TFS.

Well in this example features returned are not the real features ( as I dont have the data). These features I create for each tile on ad hoc basis but each time in a  tile features are same.  This is achieved with Knuth algo, check the php code for simulated tile feature service here. The response for given tile is GeoJSON feature collection. Well for your actual data, you need to implement a tile feature service at your own at server end. Can take help of TileStache to generate tile wise GeoJSON.

This approach is not new many efforts have been done earlier also. I see ticket for tiled WFS in  OpenLayers. There is microsoft research project for TiledVectors. And there is very nice implementation by Polymaps for Vector Tiles.  Here is another open source arcstache for ArcGIS Server.

About these ads

6 Comments

Leave a Comment
  1. Homme Zwaagstra / Jul 25 2012 4:34 pm

    This looks really interesting! I’ve been searching for some OpenLayers code that replicates the excellent vector tiling in Polymaps, as I also feel there are many strong use cases for this functionality. Kothic JS (http://bit.ly/Q10Btt) implements a similar vector tile format (http://bit.ly/kgP4PH), as does GIS Cloud (http://bit.ly/pkYUR4).

    Have you submitted an OpenLayers pull request for this in GitHub?

  2. ol_user / Aug 8 2012 1:59 pm

    Great work! Thanks a lot!

    • Gagan / Aug 12 2012 10:53 am

      Thanks, Hope its useful to you.

  3. Marc / Aug 20 2012 6:22 pm

    When using a base layer that has a projection other than 4326 it fails to calculate the tile coordinates. At least it failed with the 900913. Not sure it is the best approach, but at line 159 I changed it to take the resolution from the layer, not the map. Unlike the map, this layer is set to be 4326, so the resolution given by getResolution is the proper one and now it works fine with the OSM base layer.

    this.resolution = this.layer.getResolution();

    Instead of:

    this.resolution = this.layer.map.getResolution();

    • Gagan / Sep 11 2012 11:03 am

      Hi Mark,

      Thanks for the bug fixing and posting the same here.

      Gagan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: