예제 #1
0
        private MapInfo.Styles.RasterStyle GetRasterStyle(Table table)
        {
            MapInfo.Styles.RasterStyle rasterStyle = null;
            MIDataReader rdr            = null;
            string       projectionlist = "MI_Style";

            rdr = table.ExecuteReader(projectionlist);

            string name;
            string typename;
            int    n = rdr.FieldCount;

            MapInfo.Styles.Style style = null;
            if (rdr.Read())
            {
                for (int i = 0; i < rdr.FieldCount; i++)
                {
                    name     = rdr.GetName(i);
                    typename = rdr.GetDataTypeName(i);
                    if (typename == "MapInfo.Styles.Style")
                    {
                        style = rdr.GetStyle(i);
                    }
                }
            }
            rdr.Close();
            rdr.Dispose();
            rdr = null;
            if (style != null)
            {
                rasterStyle = style as RasterStyle;
            }
            return(rasterStyle);
        }
예제 #2
0
        private void listBoxSearchResult_DoubleClick(object sender, System.EventArgs e)
        {
            // get the selected object
            string selectedCloseMatch = (string)this.listBoxSearchResult.SelectedItem;
            // get the selected object index in the list as well since multiple matches
            // may have the same name - we can't just compare close match names.
            int selectedIndex = this.listBoxSearchResult.SelectedIndex;
            int currentIndex  = 0;

            // create a close match object
            FindCloseMatch closeMatch = null;

            // create an enumerator from the results
            FindCloseMatchEnumerator enumerator = _result.GetCloseMatchEnumerator();

            while (enumerator.MoveNext())
            {
                // if the selected name equals the enumerated name...
                if (currentIndex == selectedIndex && selectedCloseMatch.Equals(enumerator.Current.Name))
                {
                    // set the close match object
                    closeMatch = enumerator.Current;

                    // break out of the loop
                    break;
                }
                // else keep looking
                currentIndex++;
            }
            if (closeMatch != null)
            {
                // create the command string
                string command = "select obj from " + _searchTable.Alias + " where MI_Key = \'" + closeMatch.Key + "\'";

                // create the command object
                MICommand cmd = _miConnection.CreateCommand();
                cmd.CommandText = command;

                // create the reader by executing the command
                MIDataReader rdr = cmd.ExecuteReader();

                // read a row
                rdr.Read();

                // get the point
                MapInfo.Geometry.DPoint point = rdr.GetFeatureGeometry(0).Centroid;

                // Close the reader and dispose of the command.
                rdr.Close();
                cmd.Cancel();
                cmd.Dispose();

                // show point on a map
                showPointOnSearchTableMap(point.x, point.y);
            }
        }
예제 #3
0
 public override bool ProcessRow(MIDataReader reader, IResultSetFeatureCollection features)
 {
     if (_maxRows == 0 || _rowCount < _maxRows)
     {
         features.Add(reader.Current);
     }
     _rowCount++;
     if (_maxRows > 0 && _rowCount >= _maxRows)
     {
         return(false);                                                       // stop processing of this table
     }
     return(true);
 }
예제 #4
0
        // Gets RasterInfo from a given table.
        // Each raster table has exactly one associated raster image, and thus only one record.
        // Reading that record with a data reader, we can get
        // a FeatureGeometry - a bounding rectangle,
        // a Style - the Raster style,
        // a key
        // a RasterInfo object.
        private MapInfo.Raster.RasterInfo GetRasterInfo(Table table)
        {
            MapInfo.Raster.RasterInfo rasterInfo = null;
            MIDataReader rdr            = null;
            string       projectionlist = "obj, MI_Key, MI_Raster, MI_Style";

            rdr = table.ExecuteReader(projectionlist);

            string name;
            string typename;
            int    n = rdr.FieldCount;

            MapInfo.Styles.Style             style;
            MapInfo.Geometry.FeatureGeometry featureGeometry;
            MapInfo.Data.Key key;
            if (rdr.Read())
            {
                for (int i = 0; i < rdr.FieldCount; i++)
                {
                    name     = rdr.GetName(i);
                    typename = rdr.GetDataTypeName(i);
                    if (typename == "MapInfo.Styles.Style")
                    {
                        style = rdr.GetStyle(i);
                    }
                    else if (typename == "MapInfo.Geometry.FeatureGeometry")
                    {
                        featureGeometry = rdr.GetFeatureGeometry(i);
                    }
                    else if (typename == "MapInfo.Data.Key")
                    {
                        key = rdr.GetKey(i);
                    }
                    else if (typename == "MapInfo.Raster.RasterInfo")
                    {
                        rasterInfo = rdr.GetRasterInfo(i);
                    }
                }
            }
            rdr.Close();
            rdr.Dispose();
            rdr = null;
            return(rasterInfo);
        }
예제 #5
0
		public void SelectAllIndivColumns()
		{
			MIDataReader rdr = null;
			string projectionlist = "obj, MI_Key, MI_Grid, MI_Style";
			rdr = _miTable.ExecuteReader(projectionlist);
			
			string name;
			string typename;
			int n = rdr.FieldCount;
			if(rdr.Read())
			{
				n = rdr.FieldCount;//shouldn't change
				for(int i =0; i <n; i++)
				{
					name = rdr.GetName(i);
					typename = rdr.GetDataTypeName(i);
					if(typename == "MapInfo.Styles.Style")
					{
						_mStyle = rdr.GetStyle(i) as GridStyle; 
					}
					else if(typename == "MapInfo.Geometry.FeatureGeometry")
					{
						_mObject = rdr.GetFeatureGeometry(i);
					}
					else if(typename == "MapInfo.Data.Key")
					{
						_mKey = rdr.GetKey(i);
					}
					else if (typename == "MapInfo.Raster.GridInfo")
					{
						_mGridInfo = rdr.GetGridInfo(i);
					}
				}
			}

			rdr.Close();
			rdr.Dispose();
			rdr = null;
		}
예제 #6
0
        private string DetermineRemoteGeomType(FeatureLayer layer)
        {
            MapInfo.Data.Table   t     = layer.Table;
            MapInfo.Styles.Style style = null;

            MIConnection con = null;
            MICommand    cmd = null;
            MIDataReader dr  = null;

            try {
                con = new MIConnection();
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = "select mi_style from \"" + t.Alias + "\"";
                cmd.CommandType = System.Data.CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    if (!dr.IsDBNull(0))
                    {
                        style = dr.GetStyle(0);
                        break;
                    }
                }
            }
            catch (MIException) {
                // e.g. if there is no mi_style column
            }
            finally {
                if (cmd != null)
                {
                    cmd.Dispose();
                    cmd = null;
                }
                if (dr != null)
                {
                    dr.Close();
                }
                if (con != null)
                {
                    con.Close();
                    con = null;
                }
            }

            if (style != null)
            {
                if (style is SimpleLineStyle)
                {
                    return("lclayerline.bmp");
                }
                else if (style is SimpleInterior || style is AreaStyle)
                {
                    return("lclayerregion.bmp");
                }
                else if (style is BasePointStyle)
                {
                    return("lclayerpoint.bmp");
                }
                else
                {
                    return("lclayer.bmp");
                }
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
 public override bool ProcessRow(MIDataReader reader, IResultSetFeatureCollection features)
 {
     if (_maxRows == 0 || _rowCount < _maxRows) {
         features.Add(reader.Current);
     }
     _rowCount++;
     if (_maxRows > 0 && _rowCount >= _maxRows) return false; // stop processing of this table
     return true;
 }
예제 #8
0
 private void SetGrid(MIDataReader miReader, bool showSchema)
 {
     DataSet ds = new DataSet("Results");
     ds.Tables.Add(miReader.GetSchemaTable());
     DataTable dt = new DataTable("Data");
     for (int i = 0; i < miReader.FieldCount; i++)
     {
         DataColumn dc = dt.Columns.Add(miReader.GetName(i));
     }
     while (miReader.Read())
     {
         DataRow dr = dt.NewRow();
         for (int i = 0; i < miReader.FieldCount; i++)
         {
             dr[i] = miReader.GetValue(i);
         }
         dt.Rows.Add(dr);
     }
     ds.Tables.Add(dt);
     if (showSchema)
     {
         dataGrid.DataSource = miReader.GetSchemaTable();
     }
     else
     {
         dataGrid.DataSource = dt;
     }
     _output.WriteLine("{0} rows diplayed", dt.Rows.Count);
 }
예제 #9
0
 private void SetGrid(MIDataReader miReader)
 {
     SetGrid(miReader, false);
 }