/// <summary>
        /// This method gets the map object out of the mapfactory with given mapalias and 
        /// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client.
        /// </summary>
        /// <remarks>None</remarks>
        public override void Process()
        {
            // Extract points from the string
            System.Drawing.Point [] points = this.ExtractPoints(this.DataString);

            MapControlModel model = MapControlModel.GetModelFromSession();
            model.SetMapSize(MapAlias, MapWidth, MapHeight);

            MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
            if(map == null) return;

            // There will be only one point, convert it to spatial
            MapInfo.Geometry.DPoint point;
            map.DisplayTransform.FromDisplay(points[0], out point);

            IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias];
            if(lyr == null)
            {
                TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias);
                // Make the table mappable
                ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys()));
                ti.Columns.Add(ColumnFactory.CreateStyleColumn());

                Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
                map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
            }
            lyr = map.Layers[SampleConstants.TempLayerAlias];
            if(lyr == null) return;
            FeatureLayer fLyr = lyr as FeatureLayer;

            MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point);
            // Create a Point style which is a red pin point.
            SimpleVectorPointStyle vs = new SimpleVectorPointStyle();
            vs.Code = 67;
            vs.Color = Color.Red;
            vs.PointSize = Convert.ToInt16(24);
            vs.Attributes = StyleAttributes.PointAttributes.BaseAll;
            vs.SetApplyAll();

            // Create a Feature which contains a Point geometry and insert it into temp table.
            Feature pntFeature = new Feature(geoPoint, vs);
            MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature);

            // Send contents back to client.
            MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
            StreamImageToClient(ms);
        }
示例#2
1
        /// <summary>
        /// �޸Ļ�վ��Ϣ����ͼ��Դ�ļ�
        /// </summary>
        /// <param name="f"></param>
        /// <param name="pointCode"></param>
        /// <param name="iType"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="pointname"></param>
        private void ModifyPoint(Feature f, string pointCode, int iType, double x, double y, string pointname, bool IsBusy)
        {
            MapInfo.Geometry.Point g = new MapInfo.Geometry.Point(GetCoordSys(), x, y);
            SimpleVectorPointStyle vs = null;
            MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable(strTempMapPointTable);
            //vs = new SimpleVectorPointStyle(34, System.Drawing.Color.Red, 12);

            //��ȡ��վ��ʾЧ��
            vs = GetSimpleVectorPointStyleByiType(iType);

            SimpleLineStyle ls = new SimpleLineStyle(new LineWidth(1, LineWidthUnit.Pixel), 1, System.Drawing.Color.Red);
            SimpleInterior si = new SimpleInterior(1, System.Drawing.Color.Red, System.Drawing.Color.Red);
            AreaStyle a = new AreaStyle(ls, si);
            CompositeStyle cs = new CompositeStyle(a, null, null, vs);
            cs = GetCompositeStyleByIsBusy(IsBusy, iType);

            //Columns cols = new Columns();
            //cols.Add(MapInfo.Data.ColumnFactory.CreateStringColumn("Caption", 50));
            //Feature f = new Feature(g, cs, cols);

            f["Obj"] = g;
            f["MI_Style"] = cs;
            f["ID"] = pointCode;
            f["Caption"] = pointname;
            table.UpdateFeature(f);

            MapInfo.Data.TableInfo tableInfo = table.TableInfo;
            tableInfo.WriteTabFile(); //����Ϊ.tab�ļ�
        }
示例#3
1
        // find cities with distance of center of map
        private void menuItemSearchWithinDistance_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                // to compare to SearchWithinScreenRadius, we are calculating
                // the search distance the same way it does
                System.Drawing.Rectangle rect=mapControl1.Bounds;
                System.Drawing.Point pt = new System.Drawing.Point(rect.Left, rect.Top);
                pt.X += rect.Width/2;
                pt.Y += rect.Height/2;

                DPoint dpt1 = new DPoint();
                // convert center point to map coords (could use map.Center)
                _map.DisplayTransform.FromDisplay(pt, out dpt1);

                Distance d = MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance(_map, rect.Width/6);
                SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinDistance(dpt1, _map.GetDisplayCoordSys(), d, ContainsType.Centroid);
                IResultSetFeatureCollection fc = _catalog.Search("uscty_1k", si);

                // show search geometry on screen for visual confirmation
                MapInfo.Geometry.Point p = new MapInfo.Geometry.Point(_map.GetDisplayCoordSys(), dpt1);
                FeatureGeometry buffer = p.Buffer(d.Value, d.Unit, 20, DistanceType.Spherical);
                ShowSearchGeometry(buffer);

                SelectFeatureCollection(fc);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
示例#4
0
        // find nearest city to center of map
        private void menuItemSearchNearest_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                // to compare to SearchWithinScreenRadius, we are calculating
                // the search distance the same way it does
                System.Drawing.Rectangle rect = mapControl1.Bounds;
                System.Drawing.Point     pt   = new System.Drawing.Point(rect.Left, rect.Top);
                pt.X += rect.Width / 2;
                pt.Y += rect.Height / 2;

                DPoint dpt1 = new DPoint();
                // convert center point to map coords (could use map.Center)
                _map.DisplayTransform.FromDisplay(pt, out dpt1);
                Distance d = MapInfo.Mapping.SearchInfoFactory.ScreenToMapDistance(_map, 3);

                SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchNearest(dpt1, _map.GetDisplayCoordSys(), d);
                IResultSetFeatureCollection fc = _catalog.Search("uscty_1k", si);

                MapInfo.Geometry.Point p      = new MapInfo.Geometry.Point(_map.GetDisplayCoordSys(), dpt1);
                FeatureGeometry        buffer = p.Buffer(d.Value, d.Unit, 20, DistanceType.Spherical);
                ShowSearchGeometry(buffer);

                SelectFeatureCollection(fc);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        /// <summary>
        /// This method gets the map object out of the mapfactory with given mapalias and
        /// Adds a point feature into a temp layer, exports it to memory stream and streams it back to client.
        /// </summary>
        /// <remarks>None</remarks>
        public override void Process()
        {
            // Extract points from the string
            System.Drawing.Point [] points = this.ExtractPoints(this.DataString);

            MapControlModel model = MapControlModel.GetModelFromSession();

            model.SetMapSize(MapAlias, MapWidth, MapHeight);

            MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
            if (map == null)
            {
                return;
            }

            // There will be only one point, convert it to spatial
            MapInfo.Geometry.DPoint point;
            map.DisplayTransform.FromDisplay(points[0], out point);

            IMapLayer lyr = map.Layers[SampleConstants.TempLayerAlias];

            if (lyr == null)
            {
                TableInfoMemTable ti = new TableInfoMemTable(SampleConstants.TempTableAlias);
                // Make the table mappable
                ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(map.GetDisplayCoordSys()));
                ti.Columns.Add(ColumnFactory.CreateStyleColumn());

                Table table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
                map.Layers.Insert(0, new FeatureLayer(table, "templayer", SampleConstants.TempLayerAlias));
            }
            lyr = map.Layers[SampleConstants.TempLayerAlias];
            if (lyr == null)
            {
                return;
            }
            FeatureLayer fLyr = lyr as FeatureLayer;

            MapInfo.Geometry.Point geoPoint = new MapInfo.Geometry.Point(map.GetDisplayCoordSys(), point);
            // Create a Point style which is a red pin point.
            SimpleVectorPointStyle vs = new SimpleVectorPointStyle();

            vs.Code       = 67;
            vs.Color      = Color.Red;
            vs.PointSize  = Convert.ToInt16(24);
            vs.Attributes = StyleAttributes.PointAttributes.BaseAll;
            vs.SetApplyAll();

            // Create a Feature which contains a Point geometry and insert it into temp table.
            Feature pntFeature = new Feature(geoPoint, vs);

            MapInfo.Data.Key key = fLyr.Table.InsertFeature(pntFeature);

            // Send contents back to client.
            MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);

            StreamImageToClient(ms);
        }
示例#6
0
        private void FindCity()
        {
            Find find = null;

            try
            {
                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;
                }

                // Do the find
                MapInfo.Mapping.FeatureLayer findLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_findLayerName];
                find = new Find(findLayer.Table, findLayer.Table.TableInfo.Columns[_findColumnName]);
                FindResult result = find.Search(DropDownList1.SelectedItem.Text);
                if (result.ExactMatch)
                {
                    // Create a Feature (point) for the location we found
                    CoordSys        csys = findLayer.CoordSys;
                    FeatureGeometry g    = new MapInfo.Geometry.Point(csys, result.FoundPoint.X, result.FoundPoint.Y);
                    Feature         f    = new Feature(g, new MapInfo.Styles.SimpleVectorPointStyle(52, System.Drawing.Color.DarkGreen, 32));

                    // Delete the existing find object and add the new one
                    MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_workingLayerName];
                    if (workingLayer != null)
                    {
                        (workingLayer.Table as ITableFeatureCollection).Clear();
                        workingLayer.Table.InsertFeature(f);
                    }

                    // Set the map's center and zooom
                    map.Center = new DPoint(result.FoundPoint.X, result.FoundPoint.Y);
                    MapInfo.Geometry.Distance d = new MapInfo.Geometry.Distance(1000, map.Zoom.Unit);
                    map.Zoom = d;
                }
                else
                {
                    this.Label3.Text = ("Cannot find the country");
                }
                find.Dispose();
            }
            catch (Exception)
            {
                if (find != null)
                {
                    find.Dispose();
                }
            }
        }
        private void FindCity()
        {
            Find find = null;
            try
            {
                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;
                }

                // Do the find
                MapInfo.Mapping.FeatureLayer findLayer = (MapInfo.Mapping.FeatureLayer) map.Layers[_findLayerName];
                find = new Find(findLayer.Table, findLayer.Table.TableInfo.Columns[_findColumnName]);
                FindResult result = find.Search(DropDownList1.SelectedItem.Text);
                if (result.ExactMatch)
                {
                    // Create a Feature (point) for the location we found
                    CoordSys csys = findLayer.CoordSys;
                    FeatureGeometry g = new MapInfo.Geometry.Point(csys, result.FoundPoint.X, result.FoundPoint.Y);
                    Feature f = new Feature(g, new MapInfo.Styles.SimpleVectorPointStyle(52, System.Drawing.Color.DarkGreen, 32));

                    // Delete the existing find object and add the new one
                    MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)map.Layers[_workingLayerName];
                    if (workingLayer != null)
                    {
                        (workingLayer.Table as ITableFeatureCollection).Clear();
                        workingLayer.Table.InsertFeature(f);
                    }

                    // Set the map's center and zooom
                    map.Center = new DPoint(result.FoundPoint.X, result.FoundPoint.Y);
                    MapInfo.Geometry.Distance d = new MapInfo.Geometry.Distance(1000, map.Zoom.Unit);
                    map.Zoom = d;
                }
                else
                {
                    this.Label3.Text = ("Cannot find the country");
                }
                find.Dispose();
            }
            catch (Exception)
            {
                if (find != null) find.Dispose();
            }
        }