private bool InitWorkingLayer() { MapInfo.Mapping.Map map = null; // Get the map if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 || (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null) { return(false); } // Make sure the Find layer's MemTable exists MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(_workingLayerName); if (table == null) { TableInfoMemTable ti = new TableInfoMemTable(_workingLayerName); ti.Temporary = true; // Add the Geometry column Column col = new MapInfo.Data.GeometryColumn(map.GetDisplayCoordSys()); col.Alias = "obj"; col.DataType = MIDbType.FeatureGeometry; ti.Columns.Add(col); // Add the Style column col = new MapInfo.Data.Column(); col.Alias = "MI_Style"; col.DataType = MIDbType.Style; ti.Columns.Add(col); table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti); } if (table == null) { return(false); } // Make sure the Find layer exists MapInfo.Mapping.FeatureLayer layer = (MapInfo.Mapping.FeatureLayer)map.Layers[_workingLayerName]; if (layer == null) { layer = new MapInfo.Mapping.FeatureLayer(table, _workingLayerName, _workingLayerName); map.Layers.Insert(0, layer); } if (layer == null) { return(false); } // Delete the find object. There should only be one object in this table. (layer.Table as ITableFeatureCollection).Clear(); return(true); }
private bool InitWorkingLayer() { MapInfo.Mapping.Map map = null; // Get the map if (MapInfo.Engine.Session.Current.MapFactory.Count == 0 || (map = MapInfo.Engine.Session.Current.MapFactory[MapControl1.MapAlias]) == null) { return false; } // Make sure the Find layer's MemTable exists MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(_workingLayerName); if (table == null) { TableInfoMemTable ti = new TableInfoMemTable(_workingLayerName); ti.Temporary = true; // Add the Geometry column Column col = new MapInfo.Data.GeometryColumn(map.GetDisplayCoordSys()); col.Alias = "obj"; col.DataType = MIDbType.FeatureGeometry; ti.Columns.Add(col); // Add the Style column col = new MapInfo.Data.Column(); col.Alias = "MI_Style"; col.DataType = MIDbType.Style; ti.Columns.Add(col); table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti); } if (table == null) return false; // Make sure the Find layer exists MapInfo.Mapping.FeatureLayer layer = (MapInfo.Mapping.FeatureLayer)map.Layers[_workingLayerName]; if (layer == null) { layer = new MapInfo.Mapping.FeatureLayer(table, _workingLayerName, _workingLayerName); map.Layers.Insert(0, layer); } if (layer == null) return false; // Delete the find object. There should only be one object in this table. (layer.Table as ITableFeatureCollection).Clear(); return true; }