/// <summary>
        /// Executes to get tile request.
        /// </summary>
        /// <param name="_"></param>
        private dynamic DoTiles(dynamic _, int scale)
        {
            string instanceName = _.instance;

            // get instance.
            var instance = ApiBootstrapper.Get(instanceName);

            if (instance == null)
            { // not found!
                return(Negotiate.WithStatusCode(HttpStatusCode.NotFound));
            }

            // x,y,z.
            int    x = -1, y = -1;
            ushort z = 0;

            if (ushort.TryParse(_.z, out z) &&
                int.TryParse(_.x, out x) &&
                int.TryParse(_.y, out y))
            { // ok, valid stuff!
                var stream = instance.Get(x, y, z, scale);
                if (stream == null)
                {
                    return(Negotiate.WithStatusCode(HttpStatusCode.NotFound));
                }
                return(Response.FromStream(stream, "image/png"));
            }
            return(Negotiate.WithStatusCode(HttpStatusCode.NotFound));
        }
        /// <summary>
        /// Loads a new instance.
        /// </summary>
        /// <param name="apiConfiguration"></param>
        /// <param name="instanceConfiguration"></param>
        /// <returns></returns>
        private static bool LoadInstance(TileApiConfiguration apiConfiguration, InstanceConfiguration instanceConfiguration)
        {
            // get data file configuration.
            var data = instanceConfiguration.Data;

            // get mapcss configuration.
            var mapCSS = instanceConfiguration.MapCSS;

            if (string.IsNullOrWhiteSpace(mapCSS))
            {
            }

            // get the format.
            var format = instanceConfiguration.Format;

            // get the include file.
            try
            {
                // create routing instance.
                OsmSharp.Logging.Log.TraceEvent("Bootstrapper", OsmSharp.Logging.TraceEventType.Information,
                                                string.Format("Creating {0} instance...", instanceConfiguration.Name));
                switch (format.ToLowerInvariant())
                {
                case "osm-xml":
                    using (var stream = new FileInfo(data).OpenRead())
                    {
                        var streamSource = new XmlOsmStreamSource(stream);
                        using (var cssStream = new FileInfo(mapCSS).OpenRead())
                        {
                            ApiBootstrapper.BuildTileServer("tiles_" +
                                                            instanceConfiguration.Name, streamSource, cssStream, apiConfiguration.Cache);
                        }
                    }
                    break;

                case "osm-pbf":
                    using (var stream = new FileInfo(data).OpenRead())
                    {
                        var streamSource = new PBFOsmStreamSource(stream);
                        using (var cssStream = new FileInfo(mapCSS).OpenRead())
                        {
                            ApiBootstrapper.BuildTileServer("tiles_" +
                                                            instanceConfiguration.Name, streamSource, cssStream, apiConfiguration.Cache);
                        }
                    }
                    break;

                default:
                    throw new Exception(string.Format("Unrecognised raw osm format: {0}", format));
                }
                OsmSharp.Logging.Log.TraceEvent("Bootstrapper", OsmSharp.Logging.TraceEventType.Information,
                                                string.Format("Instance {0} created successfully!", instanceConfiguration.Name));
            }
            catch (Exception ex)
            {
                OsmSharp.Logging.Log.TraceEvent("Bootstrapper", OsmSharp.Logging.TraceEventType.Error,
                                                string.Format("Exception occured while creating instance {0}:{1}",
                                                              instanceConfiguration.Name, ex.ToInvariantString()));
                return(false);
            }
            return(true);
        }