物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 444|回复: 0

MapXtreme2004 从Oracle空间数据库中导出图片

[复制链接]
发表于 2013-3-13 21:10:24 | 显示全部楼层 |阅读模式

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=gisWD=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");

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-5-10 04:15 , Processed in 0.131186 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表