孙高勇的BLOG
sungaoyong
全部博文(33)
2009年(10)
2008年(23)
yueyou啊
房管局的
powerriv
cqhanwei
yefeng00
zhangpei
kevinfwk
xpf0000
liyuxiao
分类: C/C++
2008-05-26 13:20:31
// fdotest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "Fdo.h" #include <cassert> #include <iomanip> #include <iostream> #include <string> #include <utility> #define LOCATION L"e://fdotest" //FdoPtr mConnection; void apply_schema() { std::wstring provider(L"OSGeo.SHP.3.3"); std::wstring ds(L"st_zd"); std::wstring connStr(L"DefaultFileLocation=E:\\shp\\st_zd.shp;TemporaryFileLocation=E:\\shp"); try { //获取注册的驱动 IProviderRegistry* providerReg = FdoFeatureAccessManager::GetProviderRegistry(); //创建一个连接管理器 IConnectionManager* connManager = FdoFeatureAccessManager::GetConnectionManager(); //创建一个连接 FdoIConnection* mConnection = connManager->CreateConnection(provider.c_str()); FdoString* fileName = L"test"; mConnection->Close (); FdoPtr<FdoIConnectionInfo> cinfo = mConnection->GetConnectionInfo(); FdoPtr<FdoIConnectionPropertyDictionary> didc = cinfo->GetConnectionProperties(); didc->SetProperty(L"DefaultFileLocation", LOCATION); didc->SetProperty(L"TemporaryFileLocation",L""); mConnection->Open(); //Generating default data property FdoPtr<FdoDataPropertyDefinition> featid = FdoDataPropertyDefinition::Create(L"FeatId",L"Default identity property"); featid->SetDataType(::FdoDataType_Int32); featid->SetIsAutoGenerated(false); featid->SetNullable(false); //Generating default geometric property FdoPtr<FdoGeometricPropertyDefinition> geometry=FdoGeometricPropertyDefinition::Create(L"Geometry",L"Default geometry property"); geometry->SetGeometryTypes(FdoGeometricType_Point); //Generating default feature class FdoPtr<FdoFeatureClass> featureclass1=FdoFeatureClass::Create(L"FeatureClass1",L"Default feature class"); FdoPtr<FdoPropertyDefinitionCollection> properties=featureclass1->GetProperties(); properties->Add(featid); properties->Add(geometry); FdoPtr<FdoDataPropertyDefinitionCollection> identifier=featureclass1->GetIdentityProperties(); identifier->Add(featid); featureclass1->SetGeometryProperty(geometry); //Generating default schema FdoPtr<FdoFeatureSchema> schema1=FdoFeatureSchema::Create(L"Schema1",L"Default schema"); FdoClassesP(schema1->GetClasses()->Add(featureclass1)); //FdoPtr schema = schema1->GetItem(0); FdoPtr<FdoClassCollection> coll = schema1->GetClasses(); FdoPtr<FdoClassDefinition> def = coll->GetItem(0); def->SetName(fileName); FdoPtr<FdoIApplySchema> apply = (FdoIApplySchema*) mConnection->CreateCommand(FdoCommandType_ApplySchema); apply->SetFeatureSchema(schema1); apply->Execute(); } catch (FdoException* ex) { std::wcout << L"*** FDO Error:\n"; int i = 5; FdoException* nex = ex; while (NULL != nex) { const wchar_t* msg = nex->GetExceptionMessage(); if (NULL == msg) { msg = L"NO MESSAGE"; } std::wcout << std::setw(++i) << L"*** " << msg << std::endl; FdoException* p = nex; nex = nex->GetCause(); p->Release(); } } catch(std::exception& ex) { std::cout << "*** Std Error: " << ex.what() << std::endl; } catch(...) { std::cout << "*** Undefined error!\n" << std::endl; } } int _tmain(int argc, _TCHAR* argv[]) { apply_schema(); return 0; }
上一篇:Ubuntu8.04成功安装Sis显卡驱动
下一篇:SQLServer更改sa用户名
chinaunix网友2009-03-27 17:32:37
如果创建sqlite的数据库的话,怎么总是提示 *** File does not exist!
登录 注册