Monday, May 19, 2014

The light at the end of the Tunnel

A very important aspect of urban design is the ability to model underground infrastructure. Most of this blog's posts are about CityEngine's ability to model urban infrastructure above ground level, however this post will have a closer look at different ways of modeling infrastructure, depending on the position above (or below) the earth's surface.

View from inside the tunnel

Large amounts of urban infrastructure is located underground. These range from electrical-, water-, and waste management elements. The focus of this post will look at how transport networks (railways) can be located above as well as below the ground.

The first step is to determine what the study area's surface looks like. This can be done by adding a heightmap (.tif) image as a terrain layer.

10 m terrain image

After your data infrastructure data is added to the scene, select the features and go to Graph > Align Graph to Terrain > Select the Height map (your terrain) and click on finish.


Now that the data is aligned to the surface of the earth, we can do a simple check, to see whether the data is located underneath or above the surface.

The rule developed in this post was similar to the Redland Redevelopment Rail Guideway rule, which can be downloaded here.

By inserting a small piece of code to the existing CGA rule, we can check if the features are located above or below the terrain and model it appropriately.

heightOverTerrain = convert(y,scope,world,pos,scope.sx,scope.sy,scope.sz)-elevation

@StartRule
Platform--> case heightOverTerrain > 0:
 Divide_Platform
else:  TunnelSplit

TunnelSplit--> comp(f) {top: Tunnel}

Tunnel--> i("Tunnel.dae") s(scope.sx + 5, scope.sy+5, 10)center(xy) Yellow


The code above does the following:

  • Creates a heightOverTerrain function which takes the z-value of the geometry and subtracts the terrain value to determine the height above the terrain. If the value is less than 1, feature is below the surface. You can read more about the convert function at the CityEngine Online Help
  • Platform --> is inserted as the StartRule. The rule calls the heightOverTerrain function to check if the feature is located below or above the surface. 
    • In case the heightOverTerrain value is > 0, the Divide_Platform rule is called, which in turn creates railway and trains along the top part of the surface, and pillars on the bottom part of the graph shape.
    •  In case heightOverTerrain < 0 (which means the feature is below the surface), the Tunnel_Split rule is called. This rule assigns and scales a Tunnel.dae asset to the top part of the shape and colors it Yellow.

By inserting this small piece of code at the @StartRule of the CGA, CityEngine dynamically checks whether to build underground tunnels or above ground railways every time that the shape is edited, depending on the location of the feature regarding the terrain.

You can view the web scene here.