 
 ensureDir = (path) ->
   fs.mkdirSync(path) unless fs.existsSync(path)
+
+
+retry = (n, fn, args...) ->
+  fn(args...)
+  .catch (e) ->
+    if n > 0
+      console.log "call failed, trying #{n} more times"
+      retry(n-1, fn, args...)
 
 
 closeRings = (feature) ->

    q = query(bbox)
    url = "http://overpass-api.de/api/interpreter?data=#{encodeURIComponent(q)}"
    console.log("overpass:", q)
    httpGet(url)

  .then (resp) ->
    if SAVERAW?

  deferred = Q.defer()
  request url, (err, res, body) ->
    if err?
      deferred.reject(err)
    else
      deferred.resolve(body)
  return deferred.promise
