EGwsStatus GwsCommonFdoUtils::DescribeClassSC ( FdoIConnection * conn, const GWSQualifiedName & classname, GwsSpatialContextDescription & desc ) { FdoPtr<FdoFeatureSchema> schema; FdoPtr<FdoClassDefinition> classDef; GwsCommonFdoUtils::GetClassDefinition (conn, classname, schema.p, classDef.p); for (; classDef != NULL ; classDef = classDef->GetBaseClass ()) { FdoPtr<FdoPropertyDefinitionCollection> propdsc = classDef->GetProperties (); // discover geometric property name. Use the first one if there are many. for (int idx = 0; idx < propdsc->GetCount(); idx ++) { FdoPtr<FdoPropertyDefinition> prop; prop = propdsc->GetItem (idx); if (prop->GetPropertyType () == FdoPropertyType_GeometricProperty) { FdoGeometricPropertyDefinition* geomProp = static_cast<FdoGeometricPropertyDefinition*>(prop.p); FdoString* pSC = geomProp->GetSpatialContextAssociation(); if(pSC != NULL) { return GwsCommonFdoUtils::DescribeSC (conn, pSC, desc); } } } } return eGwsSCNotFound; }
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; }
//serializes a collection of property values into a byte array //This function differs from WriteFeature() in that //it will merge property values specified in the given PropertyValueCollection //with property values in the given FeatureReader. The PropertyValueCollection //represents properties to be updated in an old feature record represented by //the given FeatureReader. void GwsBinaryFeatureWriter::WriteFeature(FdoClassDefinition* fc, FdoString* fcName, FdoPropertyValueCollection* pvc, FdoIFeatureReader* reader) { FdoPtr<FdoReadOnlyPropertyDefinitionCollection> bpdc = fc->GetBaseProperties(); FdoPtr<FdoPropertyDefinitionCollection> pdc = fc->GetProperties(); //find number of properties we will store into the data record //we will use this number to save an offset into the data records for each property //at the beginning of the data record int numProps = bpdc->GetCount() + pdc->GetCount();// - idpdc->GetCount(); //now generate the data value -- write all property values, except for the ones //we already wrote to the key -- we have to check if each one is in the ID prop //collection //write feature class ID m_wrtr.WriteString(fcName); int fcNameLen = m_wrtr.GetPosition(); //reserve space for offsets into property values in data record for (int i=0; i<numProps; i++) m_wrtr.WriteInt32(0); int index = 0; //base properties first for (int i=0; i<bpdc->GetCount(); i++) { FdoPtr<FdoPropertyDefinition> pd = (FdoPropertyDefinition*)bpdc->GetItem(i); //save offset of property data to the reserved position at the //beginning of the record //TODO: endian ((int*)(m_wrtr.GetData() + fcNameLen))[index++] = m_wrtr.GetPosition(); //if property is autogenerated, do not write //anything. We use the record number as autogen property value //so we can obtain it at read time //if (!pi->IsPropAutoGen(pd->GetName())) //{ if (pvc) { if( pd->GetPropertyType() == FdoPropertyType_AssociationProperty ) { if( ! WriteAssociationProperty((FdoAssociationPropertyDefinition*)pd.p, pvc) ) WriteAssociationProperty((FdoAssociationPropertyDefinition*)pd.p, reader); } else { FdoPtr<FdoPropertyValue> pv((FdoPropertyValue*)pvc->FindItem(pd->GetName())); if(pv != NULL) WriteProperty(pd, pv); else WriteProperty(pd, reader); } } else { WriteProperty(pd, reader); } //} } //class properties for (int i=0; i<pdc->GetCount(); i++) { FdoPtr<FdoPropertyDefinition> pd = (FdoPropertyDefinition*)pdc->GetItem(i); //save offset of property data to the reserved position at the //beginning of the record //TODO: endian ((int*)(m_wrtr.GetData() + fcNameLen))[index++] = m_wrtr.GetPosition(); //if property is autogenerated, do not write //anything. We use the record number as autogen property value //so we can obtain it at read time //if (!pi->IsPropAutoGen(pd->GetName())) //{ if (pvc) { if( pd->GetPropertyType() == FdoPropertyType_AssociationProperty ) { if( ! WriteAssociationProperty((FdoAssociationPropertyDefinition*)pd.p, pvc) ) WriteAssociationProperty((FdoAssociationPropertyDefinition*)pd.p, reader); } else { FdoPtr<FdoPropertyValue> pv((FdoPropertyValue*)pvc->GetItem(pd->GetName())); if(pv != NULL) WriteProperty(pd, pv); else WriteProperty(pd, reader); } } else { WriteProperty(pd, reader); } //} } }