Solved! Go to Solution.
Geodatabase geodatabase = Geodatabase.Create("b.gdb"); string template = File.ReadAllText("../../template.xml"); string tableDef = template.Replace("%Name%", "myTable").Replace("%ShapeType%", "esriGeometryPolygon"); Table table = geodatabase.CreateTable(tableDef); string fieldTemplate = File.ReadAllText("../../fieldTemplate.xml"); table.AddField(fieldTemplate.Replace("%Name%", "polygonField")); MultiPartShapeBuffer polygonShapeBuffer = new MultiPartShapeBuffer(); int polygonPartCount = 1; int polygonPointCount = 5; int[] parts = new int[polygonPartCount]; parts[0] = 0; List<Point> points = new List<Point>(); points.Add(new Point(0, 0)); points.Add(new Point(10, 0)); points.Add(new Point(10, 10)); points.Add(new Point(0, 10)); points.Add(new Point(0, 0)); polygonShapeBuffer.Setup(ShapeType.Polygon, polygonPartCount, polygonPointCount); polygonShapeBuffer.Parts = parts; polygonShapeBuffer.Points = points.ToArray(); Row row = table.CreateRowObject(); row.SetGeometry(polygonShapeBuffer); //NaN Console.WriteLine(string.Format("xMax:{0} yMax:{1} xMin:{2} yMin:{3}", table.Extent.xMax, table.Extent.yMax, table.Extent.xMin, table.Extent.yMin)); table.Insert(row); //0 Console.WriteLine(string.Format("xMax:{0} yMax:{1} xMin:{2} yMin:{3}", table.Extent.xMax, table.Extent.yMax, table.Extent.xMin, table.Extent.yMin)); Console.Read();
Geodatabase geodatabase = Geodatabase.Create("../../TableSchemaDemo.gdb"); string featureClassDef = ""; using (StreamReader sr = new StreamReader("../../Streets.xml")) { while (sr.Peek() >= 0) { featureClassDef += sr.ReadLine() + "\n"; } sr.Close(); } Table streetsTable = geodatabase.CreateTable(featureClassDef, ""); Row row = streetsTable.CreateRowObject(); MultiPartShapeBuffer line = new MultiPartShapeBuffer(); line.Setup(ShapeType.Polyline, 1, 3); line.Parts = new int[] { 0 }; Point[] points = new Point[3]; points[0] = new Point(0, 0); points[1] = new Point(10, 0); points[2] = new Point(10, 10); line.Points = points; row.SetGeometry(line); streetsTable.Insert(row); //this two ways cannot query anything. RowCollection rows = streetsTable.Search("*", "", streetsTable.Extent, RowInstance.Recycle); //RowCollection rows = streetsTable.Search("*", "", new Envelope(9, 5, 11, 7), RowInstance.Recycle); //this way it returns one record. //RowCollection rows = streetsTable.Search("*", "", new Envelope(-1, -1, 11, 11), RowInstance.Recycle); foreach (Row item in rows) { Console.WriteLine("Has row"); }