protected void Page_Load(object sender, EventArgs e) { try { Param param = new Param(Request); UrlVisitor urlVisitor = new UrlVisitor(); if (Request["z"] != null) { urlVisitor.VisitServers(Config.raster_servers, GetPreferredRasterServerIndex(), "RasterService/bing_mosaic_fixed.aspx" + Request.Url.Query); } else { urlVisitor.VisitServers(Config.raster_servers, GetPreferredRasterServerIndex(), "RasterService/bing_mosaic_any.aspx" + Request.Url.Query); } if (urlVisitor.isSuccess) { if (urlVisitor.isImageResult) { OutputImage(urlVisitor.imageResult.ToArray(), false); } else { OutputHtml(urlVisitor.textResult); } } else { OutputError("Remote server error: " + urlVisitor.errMessage); } } catch (Exception ex) { OutputError("Internal error: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { Param param = new Param(Request); UrlVisitor urlVisitor = new UrlVisitor(); urlVisitor.VisitServers(Config.raster_servers, GetPreferredRasterServerIndex(), "RasterService/bing_tile.aspx" + Request.Url.Query); if (urlVisitor.isSuccess) { if (urlVisitor.isImageResult) { HandleImageResult(urlVisitor); } else { OutputHtml(urlVisitor.textResult); } } else { OutputError("Remote error: " + urlVisitor.errMessage); } } catch (ThreadAbortException) { } catch (Exception ex) { OutputError("Internal error: " + ex.Message); } }
private void Page_Load(object sender, EventArgs e) { try { // get param ParamVector param = new ParamVector(Request); // check if raster is available UrlVisitor urlVisitor = new UrlVisitor(); urlVisitor.VisitServers(Config.raster_servers, 0, "RasterService/bing_tile_exist.aspx" + Request.Url.Query); if (urlVisitor.isSuccess && urlVisitor.isTextResult && urlVisitor.textResult.Trim() == "0") { // when raster is not available at this location, return fully transparent tile OutputImage(Config.fully_transparent_256_tile, true); } else { // when anything goes wrong, just return regular vector tile GenerateVectorTile(param); } } catch (Exception ex) { OutputError("Internal error: " + ex.Message); } }
protected void GenerateVectorTile(ParamVector param) { // check max level if (param.z > Config.vector_max_level) { OutputError("Requested tile is beyond max level"); return; } // layers will be rendered in groups // group requests will be sent to multiple servers in turns: the first group goes to the first server, the second goes to the second, and so on UrlVisitor urlVisitor = new UrlVisitor(); PngImage img = new PngImage(param.styleset.tileWidth, param.styleset.tileHeight, param.styleset.bgColor); // get group queryStrings string[] queryStrings = param.GetQueryStringsByRenderGroup(); long totalResponseTime = 0; for (int i = 0; i < queryStrings.Length; i++) { if (queryStrings[i] == "") { continue; } int serverVisited = urlVisitor.VisitServers(Config.vector_servers, i % Config.vector_servers.Length, queryStrings[i]); if (urlVisitor.isSuccess) { if (urlVisitor.isImageResult) { Statistics.LayerGroupRequested(urlVisitor.responseTime, serverVisited); totalResponseTime += urlVisitor.responseTime; img.Add(urlVisitor.imageResult); } else { OutputError("Remote error: remote server returns text where image is expected: " + urlVisitor.textResult); return; } } else { OutputError("Remote error: " + urlVisitor.errMessage); return; } } // merge images into one OutputImage(img.Save(), true); Statistics.TileRequested(totalResponseTime, param.z); }
protected void Page_Load(object sender, EventArgs e) { try { Param param = new Param(Request); UrlVisitor urlVisitor = new UrlVisitor(); urlVisitor.VisitServers(Config.raster_servers, GetPreferredRasterServerIndex(), "RasterService/bing_sourcelist.aspx" + Request.Url.Query); if (urlVisitor.isSuccess) { OutputJson(urlVisitor.textResult); } else { OutputJson("{\"success\":false, \"error_message\":\"remote server error: " + urlVisitor.errMessage + "\", \"sources\":[]}"); } } catch (Exception ex) { OutputJson("{\"success\":false, \"error_message\":\"remote server error: " + ex.Message + "\", \"sources\":[]}"); } }