Adds shapes found in the given shape filename to the given polyline
  graph object.

def AddShapefile(shapefile, graph, key_cols):
  """
  Adds shapes found in the given shape filename to the given polyline
  graph object.
  """
  ds = ogr.Open(shapefile)
  layer = ds.GetLayer(0)

  for i in range(0, len(layer)):
    feature = layer.GetFeature(i)

    geometry = feature.GetGeometryRef()

    if key_cols:
      key_list = []
      for col in key_cols:
        key_list.append(str(feature.GetField(col)))
      shape_id = '-'.join(key_list)
    else:
      shape_id = '%s-%d' % (shapefile, i)

    poly = shapelib.Poly(name=shape_id)
    for j in range(0, geometry.GetPointCount()):
      (lat, lng) = (round(geometry.GetY(j), 15), round(geometry.GetX(j), 15))
      poly.AddPoint(shapelib.Point.FromLatLng(lat, lng))
    graph.AddPoly(poly)

  return graph