WRAPPER_API void *get_DSInstancePtr() const {return m_Inner;}
This function is used for interoperability between Blue Marble libraries. It returns a pointer to the internal datasource that can passed to a "set" function in another Blue Marble Geographics geodetic processing library. If you are using the GeoTransform raster image library, or the GeoTranslate vector processing library, it is possible to share the same GeoCalc datasource. This allows you to manage and maintain coordinate systems from multiple applications in one central repository.
The example below shows how to share a datasource between the GeoCalcPBW and GeoCore (or GeoTransform or GeoTranslate) libraries. The GeoCalcPBW DataSource is created and loaded first, and it is then passed to GeoCore. In this way, it is only necessary to load the datasource once, rather than having to load it for each library. Also, a change made in the GeoCalc datasource will be immediately available in GeoCore (and vice versa). In this example, m_datasource is a pointer to a GEOCALCPBW_NAMESPACE::DataSource, and m_datasourceBox and m_auxDataBox are .Net Windows Forms TextBoxes.
void m_initFromGeoCalcButton_Click(Object^ sender, EventArgs^ e)
{
try
{
bool success = true;
// First, if we have previously created a datasource or repository,
// delete it.
if(m_datasource)
{
GEOCALCPBW_NAMESPACE::Disposal::Dispose(m_datasource);
m_datasource = 0;
}
GeoCore::BCoordSysRepository::DestroyInstance();
// Next, load the datasource into the GeoCalc::DataSource.
try
{
pin_ptr<const BmgChar> pinnedDSPath =
PtrToStringChars(m_datasourceBox->Text);
m_datasource = GEOCALCPBW_NAMESPACE::DataSource::CreateDataSource();
m_datasource->LoadFile(pinnedDSPath);
}
catch(GEOCALCPBW_NAMESPACE::GeoCalcException& ex)
{
MessageBox::Show(gcnew String(ex.get_FullMessage()),
"Error Loading Datasource");
success = false;
}
// Now, we pass the datasource we just loaded from GeoCalcPBW over
// to GeoCore, so that both libraries can make use of the same in-
// memory datasource.
try
{
GeoCore::BCoordSysRepository::Instance()->SetDSInstancePtr(
m_datasource->get_DSInstancePtr());
}
catch(GeoCore::BException& ex)
{
MessageBox::Show(gcnew String(ex.GetDetailedMessage().Ascii()),
"Error Sharing Datasource");
success = false;
}
// Finally, we set the neceessary data paths for both GeoCalc and
// GeoCore.
try
{
pin_ptr<const BmgChar> pinnedAuxPath =
PtrToStringChars(m_auxDataBox->Text);
GeoCore::BCoordSysRepository::SetAuxDataPath(pinnedAuxPath);
pin_ptr<const BmgChar> pinnedDataPath =
PtrToStringChars(System::IO::Path::Combine(m_auxDataBox->Text, "shiftfiles"));
m_datasource->SetDataPath(pinnedDataPath);
}
catch(GeoCore::BException& ex)
{
MessageBox::Show(gcnew String(ex.GetDetailedMessage().Ascii()),
"Error Setting Data Paths");
success = false;
}
if(success)
{
MessageBox::Show("Initialization Successful");
}
}
catch(GEOCALCPBW_NAMESPACE::GeoCalcException& ex)
{
MessageBox::Show(gcnew String(ex.get_FullMessage()),
"Unexpected GeoCalc Exception");
}
catch(GeoCore::BException& ex)
{
MessageBox::Show(gcnew String(ex.GetDetailedMessage().Ascii()),
"Unexpected GeoCore Exception");
}
catch(...)
{
MessageBox::Show("Unexpected Error");
}
}