ImportFromSupplementaryFile Method

WRAPPER_API void ImportFromSupplementaryFile(const BmgChar *fileName, bool loadAsCustom)

 

Description

This function will import the object data from the specified file.  If loadAsCustom is TRUE, the data will be added to the custom datasource (if no custom exists, and exception will be thrown).  If loadAsCustom is FALSE, the data will be added to the base datasource. If an object being imported has a GC code that matches an object already in the DataSource, it will be skipped.

Example

void DataSource_ImportFromSupplementaryFile(GEOCALCPBW_NAMESPACE::DataSource & data)

{

// Create a brand new AngularUnit and do not add it to the DataSource

AngularUnit* putAngularUnit = new AngularUnit();

putAngularUnit->set_Name(L"TESTING");

putAngularUnit->get_Identifiers().Add(L"GC", L"TESTING");

putAngularUnit->get_Identifiers().Add(L"EPSG", L"TESTING");

putAngularUnit->set_UnitsPerDegree(222);

 

// Export it to a file

std::list<GEOCALCPBW_NAMESPACE::Serializable*> objectsToExport;

objectsToExport.push_back(m_DataSource->GetAngularUnit(L"GC", L"DEGREES"));

objectsToExport.push_back(putAngularUnit);

m_DataSource->ExportToSupplementaryFile(suppFilePath, objectsToExport);

 

// Import that file, adding any objects not already in the datasource to custom

m_DataSource->ImportFromSupplementaryFile(suppFilePath, true);

 

// The new AngularUnit should now be in the DataSource

vector<const Serializable*> matchingObj = m_DataSource->FindByEPSG(L"TESTING");

vector<const Serializable*>::const_iterator iter;

for (iter = matchingObj.begin(); iter != matchingObj.end(); iter++)

{

const Serializable* thisObj = *iter;

const BmgChar* thisName = thisObj->get_Name(); // Should be TESTING

}

 

// Clean up

for (iter = matchingObj.begin(); iter != matchingObj.end(); iter++)

{

           GEOCALCPBW_NAMESPACE::Disposal::Dispose(*iter);

}

matchingObj.clear();

}