public void WriteMetadata(IPersistStream stream) { if (!(stream is XmlStream)) { return; } string server = ConfigTextStream.ExtractValue(_connectionString, "server"); string user = ConfigTextStream.ExtractValue(_connectionString, "user"); string pwd = ConfigTextStream.ExtractValue(_connectionString, "pwd"); MapServerConnection conn = new MapServerConnection("http://" + server); //StringBuilder sb = new StringBuilder(); //StringWriter sw = new StringWriter(sb); MemoryStream ms = new MemoryStream(); ((XmlStream)stream).WriteStream(ms); string metadata = Encoding.Unicode.GetString(ms.GetBuffer()).Trim(new char[] { ' ', '\0' }); while (metadata[0] != '<' && metadata.Length > 0) { metadata = metadata.Substring(1, metadata.Length - 1); } if (!conn.UploadMetadata(_name, metadata, user, pwd)) { MessageBox.Show("Error..."); } }
public bool DeleteExplorerObject(ExplorerObjectEventArgs e) { try { MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.RemoveMap(_name, ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't remove map...", "ERROR"); return(false); } _parent.Refresh(); if (ExplorerObjectDeleted != null) { ExplorerObjectDeleted(this); } return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR"); return(false); } }
private void btnConnect_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; lstServices.Items.Clear(); MapServerConnection connection = new MapServerConnection("http://" + txtServer.Text + ":" + numPort.Value.ToString() + "/MapServer"); foreach (MapServerConnection.MapService service in connection.Services(txtUser.Text, txtPwd.Text)) { lstServices.Items.Add(new ListViewItem(service.Name, (int)service.Type)); } } catch (Exception ex) { Cursor = Cursors.Default; MessageBox.Show(ex.Message); } finally { Cursor = Cursors.Default; } }
public RenderTileThreadPool(MapServerConnection connector, string service, string user, string pwd, int size) { _connector = connector; _service = service; _user = user; _pwd = pwd; _size = size; _connector.Timeout = 3600; // 1h }
public override void Refresh() { base.Refresh(); try { MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); //string axl = service.ServiceRequest("catalog", "<GETCLIENTSERVICES/>", "BB294D9C-A184-4129-9555-398AA70284BC", // ConfigTextStream.ExtractValue(_connectionString, "user"), // Identity.HashPassword(ConfigTextStream.ExtractValue(_connectionString, "pwd"))); string axl = WebFunctions.HttpSendRequest("http://" + ConfigTextStream.ExtractValue(_connectionString, "server") + "/catalog?format=xml", "GET", null, ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd")); if (String.IsNullOrEmpty(axl)) { return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(axl); foreach (XmlNode mapService in doc.SelectNodes("//SERVICE[@name]")) { MapServiceType type = MapServiceType.MXL; if (mapService.Attributes["servicetype"] != null) { switch (mapService.Attributes["servicetype"].Value.ToLower()) { case "mxl": type = MapServiceType.MXL; break; case "svc": type = MapServiceType.SVC; break; case "gdi": type = MapServiceType.GDI; break; } } base.AddChildObject(new MapServerServiceExplorerObject(this, mapService.Attributes["name"].Value, _connectionString, type)); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
protected override string SendRequest(IUserData userData, string axlRequest) { if (_dataset == null) { return(""); } string server = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "service"); IServiceRequestContext context = (userData != null) ? userData.GetUserData("IServiceRequestContext") as IServiceRequestContext : null; string user = ConfigTextStream.ExtractValue(_dataset.ConnectionString, "user"); string pwd = Identity.HashPassword(ConfigTextStream.ExtractValue(_dataset.ConnectionString, "pwd")); if ((user == "#" || user == "$") && context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) { string roles = String.Empty; if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) { foreach (string role in context.ServiceRequest.Identity.UserRoles) { if (String.IsNullOrEmpty(role)) { continue; } roles += "|" + role; } } user = context.ServiceRequest.Identity.UserName + roles; pwd = context.ServiceRequest.Identity.HashedPassword; } MapServerConnection conn = new MapServerConnection(server); string resp = conn.Send(service, axlRequest, "BB294D9C-A184-4129-9555-398AA70284BC", user, pwd); try { return(conn.Send(service, axlRequest, "BB294D9C-A184-4129-9555-398AA70284BC", user, pwd)); } catch (Exception ex) { MapServerClass.ErrorLog(context, "Query", server, service, ex); return(String.Empty); } }
private void AddMap2Connection(List <string> serviceNames, List <IMap> maps) { try { if (serviceNames.Count != maps.Count) { return; } for (int i = 0; i < serviceNames.Count; i++) { XmlStream stream = new XmlStream("MapDocument"); stream.Save("IMap", maps[i]); stream.ReduceDocument("//IMap"); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); stream.WriteStream(sw); //XmlDocument doc = new XmlDocument(); //doc.LoadXml(sb.ToString()); MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.AddMap(serviceNames[i], sb.ToString(), ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't add map", "ERROR"); } } Refresh(); if (Refreshed != null) { Refreshed(this); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR"); } }
private void FormAddServiceCollection_Load(object sender, EventArgs e) { MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); string axl = service.Send("catalog", "<GETCLIENTSERVICES/>", "BB294D9C-A184-4129-9555-398AA70284BC", ConfigTextStream.ExtractValue(_connectionString, "user"), Identity.HashPassword(ConfigTextStream.ExtractValue(_connectionString, "pwd"))); if (axl == "") { return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(axl); foreach (XmlNode mapService in doc.SelectNodes("//SERVICE[@name]")) { MapServiceType type = MapServiceType.MXL; if (mapService.Attributes["servicetype"] != null) { switch (mapService.Attributes["servicetype"].Value.ToLower()) { case "mxl": type = MapServiceType.MXL; break; case "svc": type = MapServiceType.SVC; break; default: continue; } } lstAvailServices.Items.Add( new ListViewItem(mapService.Attributes["name"].Value, (type == MapServiceType.MXL) ? 0 : 1)); } }
public void ReadMetadata(IPersistStream stream) { if (!(stream is XmlStream)) { return; } string server = ConfigTextStream.ExtractValue(_connectionString, "server"); string user = ConfigTextStream.ExtractValue(_connectionString, "user"); string pwd = ConfigTextStream.ExtractValue(_connectionString, "pwd"); MapServerConnection conn = new MapServerConnection("http://" + server); string meta = conn.QueryMetadata(_name, user, pwd); if (meta == String.Empty) { return; } StringReader sr = new StringReader(meta); ((XmlStream)stream).ReadStream(sr); }
private void AddServiceCollection2Connection(string collectionName, string[] services) { XmlStream stream = new XmlStream("ServiceCollection"); stream.Save("Services", new XmlStreamStringArray(services)); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); stream.WriteStream(sw); XmlDocument doc = new XmlDocument(); doc.LoadXml(sb.ToString()); MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.AddMap(collectionName, doc.SelectSingleNode("//ServiceCollection").OuterXml, ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't add map", "ERROR"); } }
private void AddService2Connection(XmlStream stream) { try { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); stream.WriteStream(sw); XmlDocument doc = new XmlDocument(); doc.LoadXml(sb.ToString()); FormAddServiceableDataset dlg = new FormAddServiceableDataset(); if (dlg.ShowDialog() != DialogResult.OK) { return; } MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.AddMap(dlg.ServiceName, doc.SelectSingleNode("//IServiceableDataset").OuterXml, ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't add map", "ERROR"); } //Refresh(); Refresh(); if (Refreshed != null) { Refreshed(this); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR"); } }
public bool MapRequest(gView.Framework.Carto.IDisplay display) { if (_dataset == null) { return(false); } if (!_dataset._opened) { _dataset.Open(); } IServiceRequestContext context = display.Map as IServiceRequestContext; try { ISpatialReference sRef = (display.SpatialReference != null) ? display.SpatialReference.Clone() as ISpatialReference : null; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version='1.0' encoding='utf-8'?>"); sb.Append("<ARCXML version='1.1'>"); sb.Append("<REQUEST>"); sb.Append("<GET_IMAGE>"); sb.Append("<PROPERTIES>"); sb.Append("<ENVELOPE minx='" + display.Envelope.minx.ToString() + "' miny='" + display.Envelope.miny.ToString() + "' maxx='" + display.Envelope.maxx.ToString() + "' maxy='" + display.Envelope.maxy.ToString() + "' />"); sb.Append("<IMAGESIZE width='" + display.iWidth + "' height='" + display.iHeight + "' />"); sb.Append("<BACKGROUND color='255,255,255' transcolor='255,255,255' />"); //if (display.SpatialReference != null && !display.SpatialReference.Equals(_sRef)) //{ // string map_param = gView.Framework.Geometry.SpatialReference.ToProj4(display.SpatialReference); // sb.Append("<SPATIALREFERENCE name='" + display.SpatialReference.Name + "' param='" + map_param + "' />"); //} if (sRef != null) { string map_param = gView.Framework.Geometry.SpatialReference.ToProj4(display.SpatialReference); sb.Append("<SPATIALREFERENCE name='" + display.SpatialReference.Name + "' param='" + map_param + "' />"); string wkt = gView.Framework.Geometry.SpatialReference.ToESRIWKT(sRef); string geotranwkt = gView.Framework.Geometry.SpatialReference.ToESRIGeotransWKT(sRef); if (wkt != null) { wkt = wkt.Replace("\"", """); geotranwkt = geotranwkt.Replace("\"", """); if (!String.IsNullOrEmpty(geotranwkt)) { sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />"); sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" datumtransformstring=\"" + geotranwkt + "\" />"); } else { sb.Append("<FEATURECOORDSYS string=\"" + wkt + "\" />"); sb.Append("<FILTERCOORDSYS string=\"" + wkt + "\" />"); } } } sb.Append("<LAYERLIST>"); foreach (IWebServiceTheme theme in Themes) { sb.Append("<LAYERDEF id='" + theme.LayerID + "' visible='" + (theme.Visible && !theme.Locked).ToString() + "' />"); } sb.Append("</LAYERLIST>"); sb.Append("</PROPERTIES>"); sb.Append("</GET_IMAGE>"); sb.Append("</REQUEST>"); sb.Append("</ARCXML>"); string user = ConfigTextStream.ExtractValue(_dataset._connection, "user"); string pwd = Identity.HashPassword(ConfigTextStream.ExtractValue(_dataset._connection, "pwd")); if ((user == "#" || user == "$") && context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) { string roles = String.Empty; if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) { foreach (string role in context.ServiceRequest.Identity.UserRoles) { if (String.IsNullOrEmpty(role)) { continue; } roles += "|" + role; } } user = context.ServiceRequest.Identity.UserName + roles; pwd = context.ServiceRequest.Identity.HashedPassword; } #if (DEBUG) //Logger.LogDebug("Start gView Mapserver Request"); #endif MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_dataset._connection, "server")); string resp = service.Send(_name, sb.ToString(), "BB294D9C-A184-4129-9555-398AA70284BC", user, pwd); #if (DEBUG) //Logger.LogDebug("gView Mapserver Request Finished"); #endif XmlDocument doc = new XmlDocument(); doc.LoadXml(resp); System.Drawing.Bitmap bm = null; XmlNode output = doc.SelectSingleNode("//OUTPUT[@file]"); if (_image != null) { _image.Dispose(); _image = null; } try { System.IO.FileInfo fi = new System.IO.FileInfo(output.Attributes["file"].Value); if (fi.Exists) { bm = System.Drawing.Bitmap.FromFile(fi.FullName) as System.Drawing.Bitmap; } } catch { } if (bm == null) { bm = WebFunctions.DownloadImage(output); } if (bm != null) { _image = new GeorefBitmap(bm); _image.SpatialReference = display.SpatialReference; _image.Envelope = display.Envelope; if (AfterMapRequest != null) { AfterMapRequest(this, display, _image); } } return(_image != null); } catch (Exception ex) { MapServerClass.ErrorLog(context, "MapRequest", ConfigTextStream.ExtractValue(_dataset._connection, "server"), _name, ex); return(false); } }
public bool Open() { try { _opened = true; _themes.Clear(); MapServerConnection server = new MapServerConnection(ConfigTextStream.ExtractValue(_connection, "server")); string axl = "<ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"false\" extensions=\"false\" gv_meta=\"true\" /></REQUEST></ARCXML>"; axl = server.Send(_name, axl, "BB294D9C-A184-4129-9555-398AA70284BC", ConfigTextStream.ExtractValue(_connection, "user"), ConfigTextStream.ExtractValue(_connection, "pwd")); XmlDocument doc = new XmlDocument(); doc.LoadXml(axl); if (_class == null) { _class = new MapServerClass(this); } double dpi = 96.0; XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN"); if (screen != null) { if (screen.Attributes["dpi"] != null) { dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ",")); } } double dpm = (dpi / 0.0254); XmlNode spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE"); if (spatialReference != null) { if (spatialReference.Attributes["param"] != null) { SpatialReference sRef = new SpatialReference(); gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value); if (spatialReference.Attributes["name"] != null) { sRef.Name = spatialReference.Attributes["name"].Value; } _class.SpatialReference = sRef; } } else { XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS"); if (FeatureCoordSysNode != null) { if (FeatureCoordSysNode.Attributes["id"] != null) { _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value); } else if (FeatureCoordSysNode.Attributes["string"] != null) { _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value); } // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring" //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null) //{ //} } } foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE")) { if (_envelope == null) { _envelope = (new Envelope(envelopeNode)).MakeValid(); } else { _envelope.Union((new Envelope(envelopeNode)).MakeValid()); } } foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]")) { bool visible = true; ISpatialReference sRef = _class.SpatialReference; /* * spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE"); * if (spatialReference != null) * { * if (spatialReference.Attributes["param"] != null) * { * sRef = new SpatialReference(); * gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value); * * if (spatialReference.Attributes["name"] != null) * ((SpatialReference)sRef).Name = spatialReference.Attributes["name"].Value; * } * } * else * { * XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS"); * if (FeatureCoordSysNode != null) * { * if (FeatureCoordSysNode.Attributes["id"] != null) * { * sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value); * } * else if (FeatureCoordSysNode.Attributes["string"] != null) * { * sRef = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value); * } * * // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring" * //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null) * //{ * * //} * } * } */ if (layerNode.Attributes["visible"] != null) { bool.TryParse(layerNode.Attributes["visible"].Value, out visible); } IClass themeClass = null; IWebServiceTheme theme = null; if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass") { themeClass = new MapThemeFeatureClass(this, layerNode.Attributes["id"].Value); ((MapThemeFeatureClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; ((MapThemeFeatureClass)themeClass).fieldsFromAXL = layerNode.InnerXml; ((MapThemeFeatureClass)themeClass).SpatialReference = sRef; XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]"); if (FCLASS != null) { ((MapThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value; } theme = LayerFactory.Create(themeClass, _class) as IWebServiceTheme; if (theme == null) { continue; } theme.Visible = visible; } else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image") { if (layerNode.SelectSingleNode("gv_meta/class/implements[@type='gView.Framework.Data.IPointIdentify']") != null) { themeClass = new MapThemeQueryableRasterClass(this, layerNode.Attributes["id"].Value); ((MapThemeQueryableRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; } else { themeClass = new MapThemeRasterClass(this, layerNode.Attributes["id"].Value); ((MapThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; } theme = new WebServiceTheme( themeClass, themeClass.Name, layerNode.Attributes["id"].Value, visible, _class); } else { continue; } try { if (layerNode.Attributes["minscale"] != null) { theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm; } if (layerNode.Attributes["maxscale"] != null) { theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm; } } catch { } _themes.Add(theme); } _state = DatasetState.opened; return(true); } catch (Exception ex) { _state = DatasetState.unknown; _class = null; return(false); } }
private void Run() { if (_metadata == null || _mapServerClass == null || _mapServerClass.Dataset == null || _preRenderScales.Count == 0) { return; } string server = ConfigTextStream.ExtractValue(_mapServerClass.Dataset.ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(_mapServerClass.Dataset.ConnectionString, "service"); string user = ConfigTextStream.ExtractValue(_mapServerClass.Dataset.ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(_mapServerClass.Dataset.ConnectionString, "pwd"); ISpatialReference sRef = SpatialReference.FromID("epsg:" + _selectedEpsg); if (sRef == null) { return; } IEnvelope extent = _metadata.GetEPSGEnvelope(_selectedEpsg); if (extent == null) { return; } if (_bounds == null) { _bounds = extent; } double width = extent.Width; double height = extent.Height; double dpu = 1.0; if (sRef.SpatialParameters.IsGeographic) { GeoUnitConverter converter = new GeoUnitConverter(); dpu = converter.Convert(1.0, GeoUnits.Meters, GeoUnits.DecimalDegrees); } Grid grid = new Grid( (_orientation == GridOrientation.UpperLeft ? _metadata.GetOriginUpperLeft(_selectedEpsg) : _metadata.GetOriginLowerLeft(_selectedEpsg)), /*new Point(extent.minx, extent.maxy) : * new Point(extent.minx, extent.miny))*/ _metadata.TileWidth, _metadata.TileHeight, 96.0, _orientation); int level = 0; foreach (double scale in _metadata.Scales) { double res = scale / (96.0 / 0.0254) * dpu; grid.AddLevel(level++, res); } MapServerConnection connector = new MapServerConnection(server); ProgressReport report = new ProgressReport(); _cancelTracker.Reset(); int step = _cacheFormat == "compact" ? 128 : 1; #region Count Tiles report.featureMax = 0; foreach (double scale in _preRenderScales) { double res = scale / (96.0 / 0.0254) * dpu; int col0 = grid.TileColumn(_bounds.minx, res), col1 = grid.TileColumn(_bounds.maxx, res); int row0 = grid.TileRow(_bounds.maxy, res), row1 = grid.TileRow(_bounds.miny, res); report.featureMax += Math.Max(1, (Math.Abs(col1 - col0) + 1) * (Math.Abs(row1 - row0) + 1) / step / step); } #endregion RenderTileThreadPool threadPool = new RenderTileThreadPool(connector, service, user, pwd, _maxParallelRequests); var thread = threadPool.FreeThread; if (_orientation == GridOrientation.UpperLeft) { thread.Start("init/" + _cacheFormat + "/ul/" + cmbEpsg.SelectedItem.ToString() + "/" + _imgExt.Replace(".", "")); } else { thread.Start("init/" + _cacheFormat + "/ll/" + cmbEpsg.SelectedItem.ToString() + "/" + _imgExt.Replace(".", "")); } foreach (double scale in _preRenderScales) { double res = scale / (96.0 / 0.0254) * dpu; int col0 = grid.TileColumn(_bounds.minx, res), col1 = grid.TileColumn(_bounds.maxx, res); int row0 = grid.TileRow(_bounds.maxy, res), row1 = grid.TileRow(_bounds.miny, res); int cols = Math.Abs(col1 - col0) + 1; int rows = Math.Abs(row1 - row0) + 1; col0 = Math.Min(col0, col1); row0 = Math.Min(row0, row1); if (ReportProgress != null) { report.Message = "Scale: " + scale.ToString() + " - " + Math.Max(1, (rows * cols) / step / step).ToString() + " tiles..."; ReportProgress(report); } string boundingTiles = _cacheFormat == "compact" ? "/" + row0 + "|" + (row0 + rows) + "|" + col0 + "|" + (col0 + cols) : String.Empty; for (int row = row0; row < (row0 + rows) + (step - 1); row += step) { for (int col = col0; col < (col0 + cols) + (step - 1); col += step) { while ((thread = threadPool.FreeThread) == null) { Thread.Sleep(50); if (!_cancelTracker.Continue) { return; } } if (_orientation == GridOrientation.UpperLeft) { thread.Start("tile:render/" + _cacheFormat + "/ul/" + cmbEpsg.SelectedItem.ToString() + "/" + scale.ToString(_nhi) + "/" + row + "/" + col + _imgExt + boundingTiles); } else { thread.Start("tile:render/" + _cacheFormat + "/ll/" + cmbEpsg.SelectedItem.ToString() + "/" + scale.ToString(_nhi) + "/" + row + "/" + col + _imgExt + boundingTiles); } if (ReportProgress != null) { report.featurePos++; if (report.featurePos % 5 == 0 || _cacheFormat == "compact") { ReportProgress(report); } } if (!_cancelTracker.Continue) { return; } } } } while (threadPool.IsFinished == false) { Thread.Sleep(50); } if (!String.IsNullOrEmpty(threadPool.Exceptions)) { MessageBox.Show(threadPool.Exceptions, "Exceptions", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }