POST
|
Alright, I found another way to recreate the problem, attached is the xml file I tested, you can download it if you needed, the code is below,
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");
}
The Streets.xml is from the sample "\FileGDB_API_VS2010_1_3\samples\TableSchema\Streets.xml" and I haven't change anything, as you can see in the code I added a line into the table, and I want to query it by the table.Extent but failed, and then I changed the Envelope to (9, 5, 11, 7) which intersects the line, failed again, then I changed the Envelope to (-1, -1, 11, 11) which contains the line, it succeeded, so is there any way to query a record which is intersecting the specified Envelope? Thanks, Edgar
... View more
02-26-2013
03:44 PM
|
0
|
0
|
385
|
POST
|
As you can see, the extent before I insert the polygon is NaN, then I insert a polygon((0 0, 10 0, 10 10, 0 10, 0 0)), so the extent should be changed to xMax:10 xMin:0 yMax:10 yMin:0, but it doesn't, it's 0. If I use the xml from the FGDB sample, the extent is right,so I think there might be something wrong with my template, could you please have a look at that? The template is in the zip file in my first post. Thanks, Edgar
... View more
02-25-2013
07:05 PM
|
0
|
0
|
385
|
POST
|
Here is my code, still the same result with 1.3 API
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();
... View more
02-25-2013
05:10 PM
|
0
|
0
|
385
|
POST
|
Thanks for the answer about my last question, but can't I open the same database twice? It's a static method I thought I could do that but failed on the sequence. Regards, Edgar
... View more
02-25-2013
04:57 PM
|
0
|
0
|
279
|
POST
|
Hi, I can't get the right extent of a table after inserting row into it, attached is the sample, I'm using the 1.2.0.136 version, can anyone tell me where goes wrong? Thanks, Edgar
... View more
02-24-2013
10:45 PM
|
0
|
8
|
3657
|
POST
|
One more question, is there any way to get the table names from a database? It seems that I must specify a table name before querying it. Thanks, Edgar
... View more
02-24-2013
08:45 PM
|
0
|
0
|
279
|
POST
|
Thanks for your answer, I comment the Geodatabase.Create("a.gdb") or I change it to Geodatabase.Create("a.gdb").Close() and it works fine, however, there seems to be a bug in Opening the database? Here are the secnerios,
var b = Geodatabase.Open("a.gdb");
var a = Geodatabase.Open("a.gdb");
//stops here
a.Close();
b.Close();
var b = Geodatabase.Open("a.gdb");
var a = Geodatabase.Open("a.gdb");
//works fine.
b.Close();
a.Close(); Is the Close method supposed to be called in a specified sequence?
... View more
02-24-2013
05:22 PM
|
0
|
0
|
279
|
POST
|
Hi, I created a GeoDatabase and added a table and added a field and I cannot close it. Can anyone help on this? Attached is the sample, the version of dll is 1.2.0.136. Thanks, Edgar
... View more
02-21-2013
11:57 PM
|
0
|
6
|
3400
|
POST
|
Thanks for your reply, that solves my problem. Thanks, Edgar
... View more
01-15-2013
03:28 PM
|
0
|
0
|
302
|
POST
|
Thanks for your reply, here is my code and attached is the data, I'm using the FGDB API version 1.2.0.136.
Geodatabase geodatabase = Geodatabase.Open(@"../Database/FSD.gdb");
Table gdbTable = geodatabase.OpenTable("Sewerlines");
RowCollection rows = gdbTable.Search("ORIG_CONS_YR", "", RowInstance.Recycle);
foreach (var item in rows)
{
item.GetDouble("ORIG_CONS_YR");
}
Thanks, Edgar
... View more
01-14-2013
04:16 PM
|
0
|
0
|
302
|
POST
|
Thanks for your help on this, I've posted a new thread in the FGDB API forum. Regards, Edgar
... View more
01-13-2013
07:22 PM
|
0
|
0
|
216
|
POST
|
Hi, I've been suffered by a strange problem, I'm using FileGeoDatabase and reading a table, but the exception is thrown when getting the value, please see the sample from the attachment, can anybody help on this? Regards, Edgar
... View more
01-13-2013
04:03 PM
|
0
|
2
|
570
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|