bool GwsCommonFdoUtils::GetGeometryName (FdoClassDefinition *pClassDef, std::wstring &name) { if(pClassDef == NULL) return false; if(pClassDef->GetClassType() == FdoClassType_FeatureClass) { FdoFeatureClass* pFeatClass = dynamic_cast<FdoFeatureClass*>(pClassDef); if(!pFeatClass) { assert(false); return false; } FdoPtr<FdoGeometricPropertyDefinition> pgDef = pFeatClass->GetGeometryProperty(); if (pgDef != NULL) { name = pgDef->GetName(); return true; } } FdoInt32 idx; FdoPtr<FdoClassDefinition> classDef = pClassDef; FDO_SAFE_ADDREF(pClassDef); for (; classDef != NULL ; classDef = classDef->GetBaseClass ()) { FdoPtr<FdoPropertyDefinitionCollection> propdsc = classDef->GetProperties (); // discover geometric property name. Use the first one if there are many. for (idx = 0; idx < propdsc->GetCount(); idx ++) { FdoPtr<FdoPropertyDefinition> prop; prop = propdsc->GetItem(idx); if (prop->GetPropertyType () == FdoPropertyType_GeometricProperty) { name = prop->GetName (); return true; } } } return false; }
void MySqlSchemaMgrTests::VldGenGeom( FdoClassDefinitionP classDef ) { CPPUNIT_ASSERT( classDef->GetClassType() == FdoClassType_FeatureClass ); FdoFeatureClass* featClass = static_cast<FdoFeatureClass*>(classDef.p); FdoStringP className = featClass->GetName(); FdoGeometricPropertyP geomProp = featClass->GetGeometryProperty(); FdoStringP geomPropName = geomProp ? geomProp->GetName() : L""; CPPUNIT_ASSERT( (className == L"INDEX_WINS1") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_WINS2") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_WINS3") ? (geomPropName == L"GEOM2" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_WINS4") ? (geomPropName == L"GEOM2" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_TIE1") ? (geomPropName == L"GEOM2" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_TIE2") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"INDEX_TIE3") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"NNULL_WINS1") ? (geomPropName == L"GEOM1" ) : true ); CPPUNIT_ASSERT( (className == L"NNULL_WINS2") ? (geomPropName == L"GEOM2" ) : true ); CPPUNIT_ASSERT( (className == L"NNULL_TIE") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"NO_WIN") ? (geomPropName == L"" ) : true ); CPPUNIT_ASSERT( (className == L"ONE_GEOM") ? (geomPropName == L"GEOM1" ) : true ); }