2
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)))"mapwingis 모양이 shapefile에 추가되지 않습니다.
위의 코드에서 모양이 잘 채워집니다. Shape 객체의 "IsValid"속성을 살펴 봤는데 사실이었습니다. 그러나 셰이프 오브젝트에 shape 객체를 추가하는 코드를 실행하면 추가되지 않습니다. shapefile 객체의 속성 "numShapes"는 0입니다. 제가 뭘 잘못하고 있는지 확인하십시오. 지금까지 오류가 없습니다. 그냥 빈지도 canvus.