Ejemplo n.º 1
0
        //查询所在区域
        private String FindMapInRegion(double x, double y, String tableName, String colName)
        {
            String ret = "";

            try
            {
                MapInfo.Data.MIConnection connection = new MapInfo.Data.MIConnection();
                connection.Open();
                MapInfo.Data.MICommand command = connection.CreateCommand();
                command.CommandText = "Select * from " + tableName + " where MI_Point(@x, @y, @cs) within obj";
                command.Parameters.Add("@x", x);
                command.Parameters.Add("@y", y);
                command.Parameters.Add("@cs", this.mapControl.Map.GetDisplayCoordSys());
                command.Prepare();
                MapInfo.Data.IResultSetFeatureCollection irfc = command.ExecuteFeatureCollection();
                if (irfc.Count > 0)
                {
                    ret = irfc[0][colName].ToString();
                }
                command.Dispose();
                connection.Close();
            }
            catch { }
            return(ret);

            /*
             * Feature ftr1 = new Feature(tableTemp.TableInfo.Columns);
             * ftr1.Geometry = new MapInfo.Geometry.Point(mapControl.Map.GetDisplayCoordSys(), new DPoint(113.70, 23.04)) as FeatureGeometry;
             * MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinFeature(ftr1, ContainsType.Geometry);
             * si.QueryDefinition.Columns = null;
             * MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search("chinagl_guide", si);
             * if(irfc.Count > 0)
             *  MessageBox.Show(irfc[0]["Name"].ToString());
             * else MessageBox.Show("null");*/
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         miCommand.Cancel();
         miCommand.Dispose();
         miConnection.Close();
     }
     base.Dispose(disposing);
 }