【问题标题】:mapwingis shape is not adding to shapefilemapwingis 形状未添加到 shapefile
【发布时间】:2014-11-16 21:27:49
【问题描述】:
int i = 0;
int j = 0;
int intHandler1 = 0;
MapWinGIS.Shapefile shapefile = new MapWinGIS.Shapefile();
MapWinGIS.Field newField = new MapWinGIS.Field();

newField.Name = "ID";
newField.Type = MapWinGIS.FieldType.INTEGER_FIELD;
newField.Width = 10;
newField.Precision = 0;

shapefile.CreateNew("dummy.shp",MapWinGIS.ShpfileType.SHP_POLYGON);
shapefile.EditInsertField(newField, 0);

List<MapWinGIS.Shape> shape = new List<MapWinGIS.Shape>();

List<MapWinGIS.Point> pt = new List<MapWinGIS.Point>();

foreach (int cell in Drawings.Keys)
{
    foreach (int sector in Drawings[cell].Keys)
    {
        shape.Add(new MapWinGIS.Shape());
        shape[i].Create(MapWinGIS.ShpfileType.SHP_POLYGON);
        shape[i].InsertPart(0, 0);

        pt.Add(new MapWinGIS.Point());
        pt[j].x = Drawings[cell][sector]["X0"];
        pt[j].y = Drawings[cell][sector]["Y0"];
        shape[i].InsertPoint(pt[j], 0);
        j++;

        pt.Add(new MapWinGIS.Point());
        pt[j].x = Drawings[cell][sector]["X3"];
        pt[j].y = Drawings[cell][sector]["Y3"];
        shape[i].InsertPoint(pt[j], 1);
        j++;

        pt.Add(new MapWinGIS.Point());
        pt[j].x = Drawings[cell][sector]["X2"];
        pt[j].y = Drawings[cell][sector]["Y2"];
        shape[i].InsertPoint(pt[j], 2);
        j++;

        pt.Add(new MapWinGIS.Point());
        pt[j].x = Drawings[cell][sector]["X1"];
        pt[j].y = Drawings[cell][sector]["Y1"];
        shape[i].InsertPoint(pt[j], 3);
        j++;

        shape[i].InsertPoint(pt[j - 4], 4);
        shapefile.StartEditingShapes();
        shapefile.EditInsertShape(shape[i],i);                    
        i++;
    }
}            

shapefile.StopEditingTable();
shapefile.Save();
shapefile.Close();

intHandler1 = axMap1.AddLayer(shapefile, true);
axMap1.set_ShapeLayerFillColor(intHandler1, (UInt32)(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.SaddleBrown)));
axMap1.ZoomToMaxExtents();
axMap1.Refresh();

我正在尝试在 MapWinGIS 控件中绘制多个多边形。绘图是一个“Dicationary(int, DIctionary(int, Dictionary(string, float)))”

在上面的代码中,形状被很好地填充了。我查看了 Shape 对象的“IsValid”属性,这是真的。但是当我运行代码以将形状对象添加到 shapefile obj 时,它不会添加。 shapefile 对象的属性“numShapes”为零。请帮助确定我做错了什么。到目前为止没有错误。只是一张空白的地图画布。

【问题讨论】:

    标签: c# map


    【解决方案1】:

    CreateNew (string ShapefileName, ShpfileType ShapefileType) 函数更改为CreateNewWithShapeID (string ShapefileName, ShpfileType ShapefileType)

    【讨论】:

      猜你喜欢
      • 2015-09-14
      • 2016-06-24
      • 2017-06-28
      • 1970-01-01
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      相关资源
      最近更新 更多