graphhopper/graphhopper — pull request #133 by khuebner (2013-12-22 15:01:38+00:00)
Title: Preparing support of turn restrictions: Extended GraphStorage 

The last attempt to implement turn restriction support "failed" due to one huge commit no one could work with. However, I would love to see this feature in the master very soon, therefore I decided to use the knowledge I gained and try to redesign the whole thing step by step. So here is the first step: storing turn restrictions.
---
Turn restrictions need to be stored within the graph. To do so and to keep an eye on further extensions like turn costs, a turn cost table needs be stored next to nodes and edges. However, we need to store pointers from nodes to those table somehow which requires additional fields on the nodes. In my first attempt, I created a new complete Graph which extended the current GraphHopperStorage, which was not a good decision. However, I designed the storage problem of turn cost tables from scratch and therefore I want to introduce a component called ExtendedStorage:

An implementation of such ExtendedStorage will be put into GraphHopperStorage on initialization time and offers the possibility to store additional stuff next to nodes and edges without touching GraphHopperStorage. GraphHopperStorage now has an additional integer field for each node and edge. Both fields are optional and the implementation of ExtendedStorage decides, whether those fields will be created or not and those fields should be used.

For example, TurnCostStorage (extends ExtendedStorage) requires the additional field for nodes and stores a pointer towards the first entry of a turn cost table, which is managed by TurnCostStorage.