Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# mapwingis形状未添加到shapefile inti=0; int j=0; int intHandler1=0; MapWinGIS.Shapefile Shapefile=新的MapWinGIS.Shapefile(); MapWinGIS.Field newField=新的MapWinGIS.Field(); newField.Name=“ID”; newField.Type=MapWinGIS.FieldType.INTEGER\u字段; newField.Width=10; newField.Precision=0; CreateNew(“dummy.shp”,MapWinGIS.ShpfileType.shp_POLYGON); EditInsertField(newField,0); 列表形状=新列表(); List pt=新列表(); foreach(图形中的int单元格。键) { foreach(图形中的int扇区[cell].Keys) { shape.Add(新的MapWinGIS.shape()); 形状[i]。创建(MapWinGIS.ShpfileType.SHP_POLYGON); 形状[i]。插入零件(0,0); pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X0”]; pt[j].y=图形[单元][扇区][“Y0”]; 形状[i]。插入点(pt[j],0); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X3”]; pt[j].y=图纸[单元][扇区][“Y3”]; 形状[i]。插入点(pt[j],1); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X2”]; pt[j].y=图纸[单元][扇区][“Y2”]; 形状[i]。插入点(pt[j],2); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X1”]; pt[j].y=图纸[单元][扇区][“Y1”]; 形状[i]。插入点(pt[j],3); j++; 形状[i].插入点(pt[j-4],4); shapefile.StartEditingShapes(); EditInsertShape(shape[i],i); i++; } } shapefile.StopEditingTable(); Save(); shapefile.Close(); intHandler1=axMap1.AddLayer(shapefile,true); axMap1.set_ShapeLayerFillColor(intHandler1,(UInt32)(System.Drawing.colorttranslator.ToOle(System.Drawing.Color.SaddleBrown)); axMap1.ZoomToMaxExtents(); axMap1.Refresh();_C#_Map - Fatal编程技术网

C# mapwingis形状未添加到shapefile inti=0; int j=0; int intHandler1=0; MapWinGIS.Shapefile Shapefile=新的MapWinGIS.Shapefile(); MapWinGIS.Field newField=新的MapWinGIS.Field(); newField.Name=“ID”; newField.Type=MapWinGIS.FieldType.INTEGER\u字段; newField.Width=10; newField.Precision=0; CreateNew(“dummy.shp”,MapWinGIS.ShpfileType.shp_POLYGON); EditInsertField(newField,0); 列表形状=新列表(); List pt=新列表(); foreach(图形中的int单元格。键) { foreach(图形中的int扇区[cell].Keys) { shape.Add(新的MapWinGIS.shape()); 形状[i]。创建(MapWinGIS.ShpfileType.SHP_POLYGON); 形状[i]。插入零件(0,0); pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X0”]; pt[j].y=图形[单元][扇区][“Y0”]; 形状[i]。插入点(pt[j],0); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X3”]; pt[j].y=图纸[单元][扇区][“Y3”]; 形状[i]。插入点(pt[j],1); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X2”]; pt[j].y=图纸[单元][扇区][“Y2”]; 形状[i]。插入点(pt[j],2); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X1”]; pt[j].y=图纸[单元][扇区][“Y1”]; 形状[i]。插入点(pt[j],3); j++; 形状[i].插入点(pt[j-4],4); shapefile.StartEditingShapes(); EditInsertShape(shape[i],i); i++; } } shapefile.StopEditingTable(); Save(); shapefile.Close(); intHandler1=axMap1.AddLayer(shapefile,true); axMap1.set_ShapeLayerFillColor(intHandler1,(UInt32)(System.Drawing.colorttranslator.ToOle(System.Drawing.Color.SaddleBrown)); axMap1.ZoomToMaxExtents(); axMap1.Refresh();

C# mapwingis形状未添加到shapefile inti=0; int j=0; int intHandler1=0; MapWinGIS.Shapefile Shapefile=新的MapWinGIS.Shapefile(); MapWinGIS.Field newField=新的MapWinGIS.Field(); newField.Name=“ID”; newField.Type=MapWinGIS.FieldType.INTEGER\u字段; newField.Width=10; newField.Precision=0; CreateNew(“dummy.shp”,MapWinGIS.ShpfileType.shp_POLYGON); EditInsertField(newField,0); 列表形状=新列表(); List pt=新列表(); foreach(图形中的int单元格。键) { foreach(图形中的int扇区[cell].Keys) { shape.Add(新的MapWinGIS.shape()); 形状[i]。创建(MapWinGIS.ShpfileType.SHP_POLYGON); 形状[i]。插入零件(0,0); pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X0”]; pt[j].y=图形[单元][扇区][“Y0”]; 形状[i]。插入点(pt[j],0); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X3”]; pt[j].y=图纸[单元][扇区][“Y3”]; 形状[i]。插入点(pt[j],1); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X2”]; pt[j].y=图纸[单元][扇区][“Y2”]; 形状[i]。插入点(pt[j],2); j++; pt.Add(新的MapWinGIS.Point()); pt[j].x=图纸[单元][扇区][“X1”]; pt[j].y=图纸[单元][扇区][“Y1”]; 形状[i]。插入点(pt[j],3); j++; 形状[i].插入点(pt[j-4],4); shapefile.StartEditingShapes(); EditInsertShape(shape[i],i); i++; } } shapefile.StopEditingTable(); Save(); shapefile.Close(); intHandler1=axMap1.AddLayer(shapefile,true); axMap1.set_ShapeLayerFillColor(intHandler1,(UInt32)(System.Drawing.colorttranslator.ToOle(System.Drawing.Color.SaddleBrown)); axMap1.ZoomToMaxExtents(); axMap1.Refresh();,c#,map,C#,Map,我试图在MapWinGIS控件中绘制多个多边形。绘图是一个“索引(int,DIctionary(int,DIctionary(string,float)))” 在上面的代码中,形状填充得很好。我查看了Shape对象的“IsValid”属性,它是真的。但当我运行代码将shape对象添加到shapefile obj时,它不会添加。shapefile对象的属性“numShapes”为零。请帮助确定我做错了什么。到目前为止没有错误。只需要一个空白映射就可以了。将CreateNew(string Shap

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


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

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

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();