POST
|
#include <string>
#include <fstream>
#include <iostream>
#include <FileGDBAPI.h>
#include "CSchemas.h"
using namespace std;
using namespace FileGDBAPI;
int main()
{
int iexecuteStatus;
Geodatabase newFGDB;
//1.Create File Geodatabase(path,name,gdb)
iexecuteStatus =CreateFileGDB(L"C:/Temp",L"test1.gdb",newFGDB);
if(iexecuteStatus!=0)
{
wcout<<L"create file geodatabase error!"<<endl;
return -1;
}
return 0;
}
//Create File Geodatabase for Format Convertion
//Author: Hexz
//CreateTime:2011-10-13
//Version:1.0
//Revision:No
int CreateFileGDB(std::wstring filegdbPath,std::wstring filegdbName,Geodatabase& pnewFGDB)
{
fgdbError hr;
wstring errorText;
Geodatabase geodatabase;
wstring fgdb;
fgdb.empty();
fgdb.append(filegdbPath);
fgdb.append(L"/");
fgdb.append(filegdbName);
//Try to delete exist the same filegdb
hr = DeleteGeodatabase(fgdb);
if (hr == S_OK)
{
wcout << "Find the GDB exist,then the origin geodatabase has been deleted" << endl;
}
else if (hr == -2147024893)
{
wcout << "The geodatabase does not exist, no need to delete" << endl;
}
else
{
wcout << "An error occurred while deleting the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
// Create a new geodatabase in the parameter Path.
if ((hr = CreateGeodatabase(fgdb, geodatabase)) != S_OK)
{
wcout << "An error occurred while creating the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
wcout << "The geodatabase has been created." << endl;
return 0;
} I have used version1.1 ,but vs2010 show the same error! as code paste in the thread. could help my code error? Thanks
... View more
10-13-2011
08:14 PM
|
0
|
0
|
214
|
POST
|
int CreateFileGDB(std::wstring filegdbPath,std::wstring filegdbName,Geodatabase &newFGDB)
{
fgdbError hr;
wstring errorText;
Geodatabase geodatabase;
wstring fgdb;
fgdb.empty();
fgdb.append(filegdbPath);
fgdb.append(L"/");
fgdb.append(filegdbName);
//Try to delete exist the same filegdb
hr = DeleteGeodatabase(fgdb);
if (hr == S_OK)
{
wcout << "Find the GDB exist,then the origin geodatabase has been deleted" << endl;
}
else if (hr == -2147024893)
{
wcout << "The geodatabase does not exist, no need to delete" << endl;
}
else
{
wcout << "An error occurred while deleting the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
// Create a new geodatabase in the parameter Path.
if ((hr = CreateGeodatabase(fgdb, geodatabase)) != S_OK)
{
wcout << "An error occurred while creating the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return -1;
}
wcout << "The geodatabase has been created." << endl;
newFGDB = geodatabase;
return 0;
} In this code the error exist in line "newFGDB = geodatabase". the error is : IntelliSense: "FileGDBAPI::Geodatabase &FileGDBAPI::Geodatabase::operator=(const FileGDBAPI::Geodatabase &)" (code the line: 283,belong file: "F:\SoftWare\ArcGIS\FileGDB_API_VS2010_1_0Final\samples\..\include\Geodatabase.h") thanks very much!
... View more
10-13-2011
06:29 PM
|
0
|
4
|
431
|
POST
|
Hi ,lshipman Thank you for your reply. In my option , create xml schema will slow down coding effective . for one dataset have many Table and FeatureClass to created,so we must construct difference xml string for this . Why doing in this way?
... View more
08-26-2011
12:03 AM
|
0
|
0
|
141
|
POST
|
Hi, I used code that you supply to me The File Geodatabase API use 18 seconds to create points(50000) , faster 2 seconds than Arcobjects Thanks !
... View more
08-24-2011
07:31 AM
|
0
|
0
|
266
|
POST
|
Hi, I want to create workspace by File GDB API, but I found only construct xml before do this . It is not like ArcObjects createFeatureClass Function conveniency . Am I wrong ? Thank you!
... View more
08-24-2011
07:13 AM
|
0
|
2
|
2814
|
POST
|
Hi, I test insert 50,000 points to a FeatureClass use FGDB API & ArcObjects But the result is ArcObjects fast than FGDB API :
ArcObjects used time:
Testing with 50,000 points.
Total time taken: 20.5 s
FGDB API used time:
Testing with 50,000 points.
Total time taken: 80.4 s
My IDE is Visual studio 2010 C++ FGDB API is Final 1.0 version ArcObjects 10 version Is not FGDB API faster than ArcObjects ? Below is FGDB API code :
fgdbError hr;
wstring errorText;
// Open the geodatabase.
Geodatabase geodatabase;
if ((hr = OpenGeodatabase(L"F:/testData/Editing.gdb", geodatabase)) != S_OK)
{
wcout << "An error occurred while opening the geodatabase." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return ;
}
// Open the Cities table.
Table table;
if ((hr = geodatabase.OpenTable(L"\\Cities", table)) != S_OK)
{
wcout << "An error occurred while opening the table." << endl;
ErrorInfo::GetErrorDescription(hr, errorText);
wcout << errorText << "(" << hr << ")." << endl;
return ;
}
Row cabazonRow;
PointShapeBuffer cabazonGeom;
Point* point;
for (int i = 0; i < 50000; i++)
{
// Create a new feature for Cabazon.
table.CreateRowObject(cabazonRow);
// Set the row's attributes.
cabazonRow.SetString(L"AREANAME", L"Cabazon");
cabazonRow.SetString(L"CLASS", L"town");
cabazonRow.SetInteger(L"POP2000", 2939); // 2007
// Create and assign a point geometry.
hr = cabazonGeom.Setup(shapePoint);
hr = cabazonGeom.GetPoint(point);
point->x = -116.78443;
point->y = 33.919902;
cabazonRow.SetGeometry(cabazonGeom);
hr = table.Insert(cabazonRow);
//// Store the row.
//if ((hr = table.Insert(cabazonRow)) != S_OK)
//{
// wcout << "An error occurred while inserting a row." << endl;
// ErrorInfo::GetErrorDescription(hr, errorText);
// wcout << errorText << "(" << hr << ")." << endl;
// return ;
//}
//else
//{
// wcout << "Inserted two strings, one integer and a point." << endl;
//}
}
... View more
08-09-2011
10:56 PM
|
0
|
3
|
5303
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|