(转自:http://www.cnblogs.com/perdu/archive/2006/01/07/312813.html) 1 连接到Oracle空间数据库 TableInfoServer ti=new TableInfoServer("ZKT"); ti.Toolkit = MapInfo.Data.ServerToolkit.Oci; ti.CacheSettings.CacheType = MapInfo.Data.CacheOption.All; ti.MbrSearch = false; ti.ConnectString = "SRVR=s1;UID=gis;PWD=gis;"; 2 打开空间表 ti.Query = "SELECT * FROM T1 WHERE id1 = '" + strBuilderID + "'"; Table t = conn.Catalog.OpenTable(ti); 3 建立内存表,加快操作 c = MapInfo.Engine.Session.Current.Catalog; TableInfoMemTable tiMem = new TableInfoMemTable("memZKT"); tiMem.CacheSettings.CacheType = MapInfo.Data.CacheOption.All; tiMem.Temporary = true; foreach(MapInfo.Data.Column c1 in t.TableInfo.Columns){ tiMem.Columns.Add(c1.Clone()); System.Diagnostics.Debug.Write(c1.Alias + "-" + c1.DataType.ToString()); } tableMem = c.CreateTable(tiMem); 4 利用MapXtreme2004的ADO.Net从空间表导入内存表 MIConnection conn ; MICommand miCommand; conn = new MIConnection(); conn.Open(); miCommand = conn.CreateCommand(); miCommand.CommandText = "Insert into memZKT select * from zkt"; miCommand.ExecuteNonQuery(); 5 更改图元样式 MapInfo.Styles.CompositeStyle myStyle = new MapInfo.Styles.CompositeStyle(); MapInfo.Styles.SimpleLineStyle regionBorder = new MapInfo.Styles.SimpleLineStyle(); regionBorder.Width = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Pixel); regionBorder.Color = System.Drawing.Color.Black; MapInfo.Styles.SimpleInterior regionInterior = new MapInfo.Styles.SimpleInterior(); regionInterior.Pattern = (int)MapInfo.Styles.PatternStyle.None; regionInterior.Transparent = true; MapInfo.Styles.SimpleLineStyle lineStyle = new MapInfo.Styles.SimpleLineStyle(); lineStyle.Width = new MapInfo.Styles.LineWidth(1,MapInfo.Styles.LineWidthUnit.Pixel); lineStyle.Color = System.Drawing.Color.Black; myStyle.AreaStyle.Border = regionBorder; myStyle.AreaStyle.Interior = regionInterior; myStyle.LineStyle = lineStyle; System.Windows.Forms.Application.DoEvents(); miCommand.CommandText = "Update memZKT Set MI_STYLE=@style "; miCommand.Parameters.Add("@style",myStyle); miCommand.ExecuteNonQuery(); miCommand.Parameters.Clear(); 6 导出到文件 MapInfo.Mapping.MapExport exp = new MapInfo.Mapping.MapExport(_map); exp.Format = MapInfo.Mapping.ExportFormat.Jpeg; MapInfo.Geometry.DRect bounds = f.Geometry.Bounds; newBounds.x1 = bounds.x2 + (bounds.Width() / 2); newBounds.y1 = bounds.y2 + (bounds.Height() / 2); newBounds.x2 = bounds.x1 - (bounds.Width() / 2); newBounds.y2 = bounds.y1 - (bounds.Height() / 2); _map.Center = f.Geometry.Centroid; _map.Bounds = newBounds; exp.Export(strDir + f["id"].ToString() + ".jpg");
MapXtreme2004 从Oracle空间数据库中导出图片
最新推荐文章于 2022-11-18 13:16:25 发布