/// <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); }
public static void Run() { //ExStart: CreateMultiCurve string path = RunExamples.GetDataDir() + "CreateMultiCurve_out.shp"; using (VectorLayer layer = VectorLayer.Create(path, Drivers.Shapefile)) { var feature = layer.ConstructFeature(); var multiCurve = new MultiCurve(); multiCurve.Add(Geometry.FromText("LineString (0 0, 1 0)")); multiCurve.Add(Geometry.FromText("CircularString (2 2, 3 3, 4 2)")); multiCurve.Add(Geometry.FromText("CompoundCurve ((0 1, 0 0), CircularString (0 0, 3 3, 6 0))")); feature.Geometry = multiCurve; layer.Add(feature); } //ExEnd: CreateMultiCurve }