Exemplo n.º 1
0
        /// <summary>
        /// 向图层中添加线段
        /// </summary>
        public static bool AddLine(Map oMap,
                                   string strLayer,
                                   string strUID,
                                   string strText,
                                   DPoint[] dPoint,
                                   System.Drawing.Color color,
                                   int lineWidth)
        {
            //获取图层和表
            FeatureLayer layer = (FeatureLayer)oMap.Layers[strLayer];

            //创建线图元及其样式
            FeatureGeometry fg = new MultiCurve(layer.CoordSys, CurveSegmentType.Linear, dPoint);
            CompositeStyle  cs = new MapInfo.Styles.CompositeStyle(new SimpleLineStyle(new LineWidth(lineWidth, LineWidthUnit.Pixel), 2, color));

            MapInfo.Data.Feature feature = new MapInfo.Data.Feature(layer.Table.TableInfo.Columns);

            feature.Geometry = fg;
            feature.Style    = cs;
            feature["uid"]   = strUID;
            feature["name"]  = strText;

            //将线图元加入图层
            layer.Table.InsertFeature(feature);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="oMap"></param>
        /// <param name="strLayer"></param>
        /// <param name="strUID"></param>
        /// <param name="strName"></param>
        /// <param name="dPoint"></param>
        /// <param name="nCode"></param>
        /// <param name="dbCodeSize"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        public static bool AddMarker(Map oMap,
                                     string strLayer,
                                     string strUID,
                                     string strText,
                                     DPoint dPoint,
                                     int nCode,
                                     double dbCodeSize,
                                     System.Drawing.Color color)
        {
            if (oMap == null)
            {
                return(false);
            }
            FeatureLayer layer = oMap.Layers[strLayer] as FeatureLayer;

            if (layer == null)
            {
                return(false);
            }

            //创建点图元及其样式
            FeatureGeometry fg = new Point(oMap.GetDisplayCoordSys(), dPoint);
            CompositeStyle  cs = new MapInfo.Styles.CompositeStyle(new SimpleVectorPointStyle((short)nCode, color, dbCodeSize));


            Feature feature = new Feature(layer.Table.TableInfo.Columns);

            feature.Geometry = fg;
            feature.Style    = cs;
            feature["uid"]   = strUID;
            feature["name"]  = strText;

            //fg.GetGeometryEditor().Rotate(dPoint, 90);
            //fg.EditingComplete();
            //MapInfo.Geometry.IGeometryEdit edit = feature.Geometry.GetGeometryEditor();
            //edit.OffsetByAngle(90, 500, MapInfo.Geometry.DistanceUnit.Meter, MapInfo.Geometry.DistanceType.Spherical);
            //edit.Geometry.EditingComplete();

            layer.Table.InsertFeature(feature);
            return(true);
        }