zoukankan      html  css  js  c++  java
  • mapx连接数据库

    MIConnection Connection = new MIConnection();
                Connection.Open();            
                MapInfo.Data.SpatialSchemaXY xy = new MapInfo.Data.SpatialSchemaXY();
                xy.XColumn = "id";
                xy.YColumn = "age";
                xy.NullPoint = "0.0, 0.0";
                xy.StyleType = MapInfo.Data.StyleType.None;
                xy.DefaultStyle = new MapInfo.Styles.CompositeStyle();
                xy.CoordSys = MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84);
    
                //建立TableInfo
                MapInfo.Data.TableInfoServer ti = new MapInfo.Data.TableInfoServer("Customers", "Driver={SQL Server};Server=wingao;Database=mapxdb;Uid=sa;Pwd=1;", "select * from CH_SHENGHUI", MapInfo.Data.ServerToolkit.Odbc);
                ti.SpatialSchema = xy;
                MapInfo.Data.Table miCustomers = MapInfo.Engine.Session.Current.Catalog.OpenTable(ti);
                MapInfo.Mapping.FeatureLayer featureLayer = new MapInfo.Mapping.FeatureLayer(miCustomers);
                mapControl1.Map.Layers.Add(featureLayer);
                mapControl1.Map.SetView(featureLayer);
                Connection.Close();
                MessageBox.Show("OK!");
    
    http://www.cnblogs.com/dachie/archive/2010/08/17/1801598.html
    
    

    TableInfoNative tableInfoNative = new TableInfoNative(layerName);
                
        tableInfoNative.TablePath = @"d:\test.tab";
                
        tableInfoNative.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn( MapInfo.Engine.Session.Current.CoordSysFactory.CreateLongLat(MapInfo.Geometry.DatumID.WGS84)));

        tableInfoNative.Columns.Add(ColumnFactory.CreateStyleColumn());

        tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("Name", 100));

        tableInfoNative.Columns.Add(ColumnFactory.CreateStringColumn("LineType", 100));
        tableInfoNative.WriteTabFile();

    //保存tab

    MapInfo.Data.Table t = MapInfo.Engine.Session.Current.Catalog.CreateTable(tableInfoNative);
        MapInfo.Engine.Session.Current.Catalog.CloseTable("test");

    //加载到mapControl

    Table tb = Session.Current.Catalog.CreateTable(tableInfoNative);

        FeatureLayer tempLayer = new FeatureLayer(tb, layerName);

        mapcontrol.Map.Layers.Add(tempLayer);

      

  • 相关阅读:
    Java 中String、StringBuffer、StringBuilder的差别
    [转载]StringBuffer versus String
    二维数组的连续子数组的最大和
    一位数组的最大和
    js中常见的去重方式
    魅族2016Java互联网方向其中一道笔试题--青蛙跳台阶问题
    美团在线编程2016--最大差值
    [转载]MySQL开发中常用的查询语句总结
    实现字符串全排列
    笔试题---最大子序列和
  • 原文地址:https://www.cnblogs.com/bjxly/p/2311402.html
Copyright © 2011-2022 走看看